From 4458488ce246ccd1937d716d9ec9400becc71d3e Mon Sep 17 00:00:00 2001 From: sscobici Date: Sat, 18 Jan 2025 19:54:05 +0200 Subject: [PATCH] alac: validate mid_side_shift to not overflow --- symphonia-codec-alac/src/lib.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/symphonia-codec-alac/src/lib.rs b/symphonia-codec-alac/src/lib.rs index ccb7d54f..374bc924 100644 --- a/symphonia-codec-alac/src/lib.rs +++ b/symphonia-codec-alac/src/lib.rs @@ -658,6 +658,12 @@ fn decode_sce_or_cpe( elem1.predict(&mut out1[..num_samples])?; if mid_side_weight != 0 { + // mid_side_shift should not be bigger than 31 bits as we are shifting i32 to the right + // TODO Validate whether it should also not be greater than config.bit_depth. + if mid_side_shift > 31 { + return decode_error("alac: mid_side_shift is greater than 31 bit"); + } + decorrelate_mid_side(out0, out1, mid_side_weight, mid_side_shift); } }