From 26e3ed6080daffd2cbb14167cb060e94dc15998a Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Fri, 19 Sep 2025 00:18:30 +0200 Subject: [PATCH] avcodec/exr: Check that DWA has 3 channels The implementation hardcodes access to 3 channels, so we need to check that Fixes: out of array access Fixes: BIGSLEEP-445394503-crash.exr Found-by: Google Big Sleep Signed-off-by: Michael Niedermayer (cherry picked from commit 7896cc67c13037abba8941e39a74c56d26b775a7) Signed-off-by: Michael Niedermayer --- libavcodec/exr.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libavcodec/exr.c b/libavcodec/exr.c index 85c925fb66..fc1d150e4d 100644 --- a/libavcodec/exr.c +++ b/libavcodec/exr.c @@ -1007,6 +1007,11 @@ static int dwa_uncompress(EXRContext *s, const uint8_t *src, int compressed_size if (version != 2) return AVERROR_INVALIDDATA; + if (s->nb_channels < 3) { + avpriv_request_sample(s->avctx, "Gray DWA"); + return AVERROR_PATCHWELCOME; + } + lo_usize = AV_RL64(src + 8); lo_size = AV_RL64(src + 16); ac_size = AV_RL64(src + 24);