aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2020-07-06 20:18:42 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2021-09-11 21:23:48 +0200
commita86e6a6a987bc4e4274e753d92ae3364117a938c (patch)
treeb8b67018ccf13a4d67a4da7479372f0c74868ce8 /libavformat
parentfa3702fbaf39513a6563313eb79efce6e165dcfb (diff)
downloadffmpeg-a86e6a6a987bc4e4274e753d92ae3364117a938c.tar.gz
avformat/smjpegdec: Check the existence of referred streams
Fixes: Assertion failure Fixes: 23758/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5160954605338624.fuzz 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 321ea59dac6538f92206bab0a2688fa24a25c4d2) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/smjpegdec.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/libavformat/smjpegdec.c b/libavformat/smjpegdec.c
index c184c0d9fd..ec5f2957e5 100644
--- a/libavformat/smjpegdec.c
+++ b/libavformat/smjpegdec.c
@@ -51,6 +51,9 @@ static int smjpeg_read_header(AVFormatContext *s)
uint32_t version, htype, hlength, duration;
char *comment;
+ sc->audio_stream_index =
+ sc->video_stream_index = -1;
+
avio_skip(pb, 8); // magic
version = avio_rb32(pb);
if (version)
@@ -147,6 +150,8 @@ static int smjpeg_read_packet(AVFormatContext *s, AVPacket *pkt)
dtype = avio_rl32(s->pb);
switch (dtype) {
case SMJPEG_SNDD:
+ if (sc->audio_stream_index < 0)
+ return AVERROR_INVALIDDATA;
timestamp = avio_rb32(s->pb);
size = avio_rb32(s->pb);
ret = av_get_packet(s->pb, pkt, size);
@@ -155,6 +160,8 @@ static int smjpeg_read_packet(AVFormatContext *s, AVPacket *pkt)
pkt->pos = pos;
break;
case SMJPEG_VIDD:
+ if (sc->video_stream_index < 0)
+ return AVERROR_INVALIDDATA;
timestamp = avio_rb32(s->pb);
size = avio_rb32(s->pb);
ret = av_get_packet(s->pb, pkt, size);