From 8154cb7c2ff2afcb1a0842de8c215b7714c814d0 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Thu, 30 Jun 2022 00:00:32 +0200 Subject: [PATCH] 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 --- libavutil/channel_layout.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libavutil/channel_layout.c b/libavutil/channel_layout.c index 21b70173b7..1887987789 100644 --- a/libavutil/channel_layout.c +++ b/libavutil/channel_layout.c @@ -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, ")");