aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Rummell <jrummell@chromium.org>2020-03-30 21:30:33 -0700
committerMichael Niedermayer <michael@niedermayer.cc>2020-07-01 13:33:44 +0200
commite75f8b51ea2a49b03392a794bc7c6bd1704b7203 (patch)
tree3a2182ea6f9623b9f65721febe0d55d171d52d05
parent9954fbe2739dc4a5daeb9fcb42637ca0d6c8b8ea (diff)
downloadffmpeg-e75f8b51ea2a49b03392a794bc7c6bd1704b7203.tar.gz
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@niedermayer.cc> (cherry picked from commit 5b967f56b6d85f62446836fc8ef64d0dcfcbda17) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavformat/amr.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/libavformat/amr.c b/libavformat/amr.c
index f954803d46..3321be4f52 100644
--- a/libavformat/amr.c
+++ b/libavformat/amr.c
@@ -90,13 +90,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;
}