1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

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>
This commit is contained in:
Michael Niedermayer 2020-07-06 20:18:42 +02:00
parent f1feb3bd9d
commit 321ea59dac

View File

@ -51,6 +51,9 @@ static int smjpeg_read_header(AVFormatContext *s)
uint32_t version, htype, hlength, duration; uint32_t version, htype, hlength, duration;
char *comment; char *comment;
sc->audio_stream_index =
sc->video_stream_index = -1;
avio_skip(pb, 8); // magic avio_skip(pb, 8); // magic
version = avio_rb32(pb); version = avio_rb32(pb);
if (version) if (version)
@ -147,6 +150,8 @@ static int smjpeg_read_packet(AVFormatContext *s, AVPacket *pkt)
dtype = avio_rl32(s->pb); dtype = avio_rl32(s->pb);
switch (dtype) { switch (dtype) {
case SMJPEG_SNDD: case SMJPEG_SNDD:
if (sc->audio_stream_index < 0)
return AVERROR_INVALIDDATA;
timestamp = avio_rb32(s->pb); timestamp = avio_rb32(s->pb);
size = avio_rb32(s->pb); size = avio_rb32(s->pb);
ret = av_get_packet(s->pb, pkt, size); ret = av_get_packet(s->pb, pkt, size);
@ -155,6 +160,8 @@ static int smjpeg_read_packet(AVFormatContext *s, AVPacket *pkt)
pkt->pos = pos; pkt->pos = pos;
break; break;
case SMJPEG_VIDD: case SMJPEG_VIDD:
if (sc->video_stream_index < 0)
return AVERROR_INVALIDDATA;
timestamp = avio_rb32(s->pb); timestamp = avio_rb32(s->pb);
size = avio_rb32(s->pb); size = avio_rb32(s->pb);
ret = av_get_packet(s->pb, pkt, size); ret = av_get_packet(s->pb, pkt, size);