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

John Rummell git at videolan.org
Fri Apr 3 01:59:07 EEST 2020


ffmpeg | branch: master | John Rummell <jrummell at chromium.org> | Mon Mar 30 21:30:33 2020 -0700| [5b967f56b6d85f62446836fc8ef64d0dcfcbda17] | committer: Michael Niedermayer

libavformat/amr.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 initialized data. Caught by
Chromium fuzzeras (crbug.com/1065731).

Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

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

 libavformat/amr.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavformat/amr.c b/libavformat/amr.c
index eccbbde5b0..b8a5debb16 100644
--- a/libavformat/amr.c
+++ b/libavformat/amr.c
@@ -89,13 +89,15 @@ static int amr_read_header(AVFormatContext *s)
     AVStream *st;
     uint8_t header[9];
 
-    avio_read(pb, header, 6);
+    if (avio_read(pb, header, 6) != 6)
+        return AVERROR_INVALIDDATA;
 
     st = avformat_new_stream(s, NULL);
     if (!st)
         return AVERROR(ENOMEM);
     if (memcmp(header, AMR_header, 6)) {
-        avio_read(pb, header + 6, 3);
+        if (avio_read(pb, header + 6, 3) != 3)
+            return AVERROR_INVALIDDATA;
         if (memcmp(header, AMRWB_header, 9)) {
             return -1;
         }



More information about the ffmpeg-cvslog mailing list