[FFmpeg-cvslog] libavformat/oggdec.c: Check return value from avio_read()

John Rummell git at videolan.org
Fri Apr 24 02:14:18 EEST 2020


ffmpeg | branch: release/2.8 | John Rummell <jrummell at chromium.org> | Mon Mar 30 14:56:11 2020 -0700| [e11e62a80a0a3a0336d5e4ce0861cecc4a2d5c3a] | committer: Michael Niedermayer

libavformat/oggdec.c: Check return value from avio_read()

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 at niedermayer.cc>
(cherry picked from commit b7c67b1ae3657058b32b9235119d07529ad5cce1)
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e11e62a80a0a3a0336d5e4ce0861cecc4a2d5c3a
---

 libavformat/oggdec.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c
index 18248b7727..7ace0d1c16 100644
--- a/libavformat/oggdec.c
+++ b/libavformat/oggdec.c
@@ -196,7 +196,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) {



More information about the ffmpeg-cvslog mailing list