Commit 8bdc64d4 authored by Michael Niedermayer's avatar Michael Niedermayer

avformat/4xm: Check that a video stream was created before returning packets for it

Fixes: assertion failure
Fixes: 23434/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5227750851084288.fuzz

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpegSigned-off-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit c517c3f4741b6897ea952d1fba199c93c5217cfe)
Signed-off-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
parent a3e0c9f8
...@@ -218,6 +218,7 @@ static int fourxm_read_header(AVFormatContext *s) ...@@ -218,6 +218,7 @@ static int fourxm_read_header(AVFormatContext *s)
fourxm->track_count = 0; fourxm->track_count = 0;
fourxm->tracks = NULL; fourxm->tracks = NULL;
fourxm->fps = (AVRational){1,1}; fourxm->fps = (AVRational){1,1};
fourxm->video_stream_index = -1;
/* skip the first 3 32-bit numbers */ /* skip the first 3 32-bit numbers */
avio_skip(pb, 12); avio_skip(pb, 12);
...@@ -326,6 +327,8 @@ static int fourxm_read_packet(AVFormatContext *s, ...@@ -326,6 +327,8 @@ static int fourxm_read_packet(AVFormatContext *s,
* and size */ * and size */
if (size > INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE - 8) if (size > INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE - 8)
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
if (fourxm->video_stream_index < 0)
return AVERROR_INVALIDDATA;
if ((ret = av_new_packet(pkt, size + 8)) < 0) if ((ret = av_new_packet(pkt, size + 8)) < 0)
return ret; return ret;
pkt->stream_index = fourxm->video_stream_index; pkt->stream_index = fourxm->video_stream_index;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment