aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2020-11-08 00:17:09 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2021-10-09 22:02:19 +0200
commitecd4013d80388a56c42ea7a2587fa9a64d1bb49b (patch)
treed6e36a6b3f18fbb1cf0ba2ae1b77c42348438c38
parente298bc59802646ad783944c793e9b343ca56fb35 (diff)
downloadffmpeg-ecd4013d80388a56c42ea7a2587fa9a64d1bb49b.tar.gz
avformat/lvfdec: Check stream_index before use
Fixes: assertion failure Fixes: 26905/clusterfuzz-testcase-minimized-ffmpeg_dem_LVF_fuzzer-5724267599364096.fuzz Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit b1d99ab14f2fd273e678dcb618dabfb38aab91b6) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavformat/lvfdec.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/libavformat/lvfdec.c b/libavformat/lvfdec.c
index b8af25609f..0ff531ddde 100644
--- a/libavformat/lvfdec.c
+++ b/libavformat/lvfdec.c
@@ -106,6 +106,7 @@ static int lvf_read_packet(AVFormatContext *s, AVPacket *pkt)
unsigned size, flags, timestamp, id;
int64_t pos;
int ret, is_video = 0;
+ int stream_index;
pos = avio_tell(s->pb);
while (!avio_feof(s->pb)) {
@@ -121,12 +122,15 @@ static int lvf_read_packet(AVFormatContext *s, AVPacket *pkt)
case MKTAG('0', '1', 'w', 'b'):
if (size < 8)
return AVERROR_INVALIDDATA;
+ stream_index = is_video ? 0 : 1;
+ if (stream_index >= s->nb_streams)
+ return AVERROR_INVALIDDATA;
timestamp = avio_rl32(s->pb);
flags = avio_rl32(s->pb);
ret = av_get_packet(s->pb, pkt, size - 8);
if (flags & (1 << 12))
pkt->flags |= AV_PKT_FLAG_KEY;
- pkt->stream_index = is_video ? 0 : 1;
+ pkt->stream_index = stream_index;
pkt->pts = timestamp;
pkt->pos = pos;
return ret;