[FFmpeg-devel] [PATCH] Use avio_read instead of get_strz to read mov string.

Reimar Döffinger Reimar.Doeffinger
Sun Mar 6 14:08:23 CET 2011


This makes more sense because we have a length of a string,
so it works better in case 0-termination is missing or corrupted,
matches other string read functions in mov.c and also adds a check
that avoids an integer overflow (even though it does not cause issues
due to signed types used properly).
---
 libavformat/mov.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index be799a4..1d32f31 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -2331,7 +2331,9 @@ static void mov_read_chapters(AVFormatContext *s)
             avio_get_str16le(sc->pb, len, title, title_len);
         else {
             AV_WB16(title, ch);
-            get_strz(sc->pb, title + 2, len - 1);
+            if (len > 2)
+                avio_read(sc->pb, title + 2, len - 2);
+            title[len] = 0;
         }
 
         ff_new_chapter(s, i, st->time_base, sample->timestamp, end, title);
-- 
1.7.4.1




More information about the ffmpeg-devel mailing list