summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <[email protected]>2020-09-07 00:09:33 +0200
committerMichael Niedermayer <[email protected]>2021-10-09 22:02:19 +0200
commit033936fc4acfb75535f065722c1cccf1d7d7ed25 (patch)
treeeb788359c104d8f1a5dbf90abec4849ec5a09dfd
parenta681e5f131ff3091bdd5b161a7082dbe33a6ed28 (diff)
avformat/electronicarts: Check if there are any streams
Fixes: Assertion failure (invalid stream index) Fixes: 25120/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-6565251898933248 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <[email protected]> (cherry picked from commit 39a98623edbbdcf9d9b76e9d7aff3ce086ebfbfe) Signed-off-by: Michael Niedermayer <[email protected]>
-rw-r--r--libavformat/electronicarts.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/libavformat/electronicarts.c b/libavformat/electronicarts.c
index a07786ded8..508194bbf8 100644
--- a/libavformat/electronicarts.c
+++ b/libavformat/electronicarts.c
@@ -530,20 +530,17 @@ static int ea_read_header(AVFormatContext *s)
if (ea->num_channels <= 0 || ea->num_channels > 2) {
av_log(s, AV_LOG_WARNING,
"Unsupported number of channels: %d\n", ea->num_channels);
- ea->audio_codec = 0;
- return 1;
+ goto no_audio;
}
if (ea->sample_rate <= 0) {
av_log(s, AV_LOG_ERROR,
"Unsupported sample rate: %d\n", ea->sample_rate);
- ea->audio_codec = 0;
- return 1;
+ goto no_audio;
}
if (ea->bytes <= 0) {
av_log(s, AV_LOG_ERROR,
"Invalid number of bytes per sample: %d\n", ea->bytes);
- ea->audio_codec = AV_CODEC_ID_NONE;
- return 1;
+ goto no_audio;
}
/* initialize the audio decoder stream */
@@ -564,8 +561,13 @@ static int ea_read_header(AVFormatContext *s)
st->codecpar->bits_per_coded_sample;
ea->audio_stream_index = st->index;
st->start_time = 0;
+ return 1;
}
+no_audio:
+ ea->audio_codec = AV_CODEC_ID_NONE;
+ if (!ea->video.codec)
+ return AVERROR_INVALIDDATA;
return 1;
}