]> git.sesse.net Git - ffmpeg/commitdiff
libavformat/oggdec.c: Check return value from avio_read()
authorJohn Rummell <jrummell@chromium.org>
Mon, 30 Mar 2020 21:56:11 +0000 (14:56 -0700)
committerMichael Niedermayer <michael@niedermayer.cc>
Wed, 1 Apr 2020 20:21:26 +0000 (22:21 +0200)
If the buffer doesn't contain enough bytes when reading a stream,
fail rather than continuing on with unitialized data. Caught by
Chromium fuzzers (crbug.com/1054229).

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavformat/oggdec.c

index 4f4b5fe386e9c197a45a069cc87f4660b4991ec7..de2f24b967b41d68ad96bb7229534c6401f6e3c4 100644 (file)
@@ -216,7 +216,8 @@ static int ogg_replace_stream(AVFormatContext *s, uint32_t serial, int nsegs)
         uint8_t magic[8];
         int64_t pos = avio_tell(s->pb);
         avio_skip(s->pb, nsegs);
-        avio_read(s->pb, magic, sizeof(magic));
+        if (avio_read(s->pb, magic, sizeof(magic)) != sizeof(magic))
+            return AVERROR_INVALIDDATA;
         avio_seek(s->pb, pos, SEEK_SET);
         codec = ogg_find_codec(magic, sizeof(magic));
         if (!codec) {