mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2026-06-16 04:32:47 +02:00
avformat/iamf_parse: bound substream count by remaining OBU size
also check for nb_substreams == 0
Fixes: 472641765/clusterfuzz-testcase-minimized-ffmpeg_dem_IAMF_fuzzer-6390897173659648
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 fe2dabbbf4)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
@@ -776,6 +776,13 @@ static int audio_element_obu(void *s, IAMFContext *c, AVIOContext *pb, int len)
|
||||
}
|
||||
|
||||
nb_substreams = ffio_read_leb(pbc);
|
||||
/* Each substream consumes at least one byte (its leb128 id) from the
|
||||
* remaining OBU buffer, so a count larger than that cannot be valid and
|
||||
* would only serve to force an oversized allocation. */
|
||||
if (nb_substreams > len - avio_tell(pbc) || !nb_substreams) {
|
||||
ret = AVERROR_INVALIDDATA;
|
||||
goto fail;
|
||||
}
|
||||
audio_element->codec_config_id = codec_config_id;
|
||||
audio_element->audio_element_id = audio_element_id;
|
||||
audio_element->substreams = av_calloc(nb_substreams, sizeof(*audio_element->substreams));
|
||||
|
||||
Reference in New Issue
Block a user