avutil/channel_layout: av_channel_layout_describe_bprint: Check for buffer end

Fixes: Timeout printing a billion channels
Fixes: 48099/clusterfuzz-testcase-minimized-ffmpeg_dem_MATROSKA_fuzzer-6754782204788736

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 2022-06-30 00:00:32 +02:00
parent c6f1e48b86
commit 8154cb7c2f

View File

@ -757,6 +757,10 @@ int av_channel_layout_describe_bprint(const AVChannelLayout *channel_layout,
if (channel_layout->order == AV_CHANNEL_ORDER_CUSTOM &&
channel_layout->u.map[i].name[0])
av_bprintf(bp, "@%s", channel_layout->u.map[i].name);
if (!av_bprint_is_complete(bp))
return AVERROR(ENOMEM);
}
if (channel_layout->nb_channels) {
av_bprintf(bp, ")");