From 3ccd7d8c8e85aaae0c6d6cc88ea6cb5309d56cdc Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Mon, 28 Jul 2025 20:45:59 +0200 Subject: [PATCH] avcodec/sanm: Check decoded_size for old_codec48 Fixes: writing over the end of the array Fixes: BIGSLEEP-434637586/payload Regression since: b22ce90d42 Found-by: Google Big Sleep Signed-off-by: Michael Niedermayer --- libavcodec/sanm.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libavcodec/sanm.c b/libavcodec/sanm.c index 02bb78859a..617b977ab7 100644 --- a/libavcodec/sanm.c +++ b/libavcodec/sanm.c @@ -1601,6 +1601,11 @@ static int old_codec48(SANMVideoContext *ctx, int width, int height) } break; case 2: + if (decoded_size > ctx->buf_size) { + av_log(ctx->avctx, AV_LOG_ERROR, "Decoded size %u is too large.\n", decoded_size); + return AVERROR_INVALIDDATA; + } + if (rle_decode(ctx, &ctx->gb, dst, decoded_size)) return AVERROR_INVALIDDATA; break;