aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2019-11-15 23:00:51 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2020-07-02 19:55:08 +0200
commit57c602ab246a5ed2fb14d0bd0180c76a1984d494 (patch)
treecf2282aea8ffb4cf1973d6b162b73b0a8003b8ad
parentbc73f923e23d7e0ebcc64dac11b1309d3be3ed82 (diff)
downloadffmpeg-57c602ab246a5ed2fb14d0bd0180c76a1984d494.tar.gz
avformat/rmdec: Initialize and sanity check offset in ivr_read_header()
Fixes: signed integer overflow: -9223372036854775808 - 17 cannot be represented in type 'long' Fixes: 18768/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5674385247830016 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit 7e665e4a81e2e96eb45138a1dfa38617de2631a4) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavformat/rmdec.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/libavformat/rmdec.c b/libavformat/rmdec.c
index f3fa550c63..9db163d392 100644
--- a/libavformat/rmdec.c
+++ b/libavformat/rmdec.c
@@ -1175,7 +1175,7 @@ static int ivr_read_header(AVFormatContext *s)
uint8_t key[256], val[256];
AVIOContext *pb = s->pb;
AVStream *st;
- int64_t pos, offset, temp;
+ int64_t pos, offset=0, temp;
pos = avio_tell(pb);
tag = avio_rl32(pb);
@@ -1192,6 +1192,8 @@ static int ivr_read_header(AVFormatContext *s)
offset = temp;
temp = avio_rb64(pb);
}
+ if (offset <= 0)
+ return AVERROR_INVALIDDATA;
avio_skip(pb, offset - avio_tell(pb));
if (avio_r8(pb) != 1)
return AVERROR_INVALIDDATA;