aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/eac3dec.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2023-01-06 23:36:12 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2023-04-15 22:38:04 +0200
commit8488b49faf82d3337ebcabc2d7830f8dadd40d38 (patch)
tree0a49a12cd07c95a1f2923bbc8c0809d1f254141f /libavcodec/eac3dec.c
parent4c9ba64d5468ced00c4bfaf795bb31397b16fdf3 (diff)
downloadffmpeg-8488b49faf82d3337ebcabc2d7830f8dadd40d38.tar.gz
avcodec/eac3dec: avoid float noise in fixed mode addition to overflow
Fixes: 2.28595e+09 is outside the range of representable values of type 'int' Fixes: 54644/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AC3_FIXED_fuzzer-4816961584627712 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit 2f48d227c153fa6f0a2156f3e8d18ea1bfedf18d) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec/eac3dec.c')
-rw-r--r--libavcodec/eac3dec.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/libavcodec/eac3dec.c b/libavcodec/eac3dec.c
index 3a5c7989b9..33b9c88bb2 100644
--- a/libavcodec/eac3dec.c
+++ b/libavcodec/eac3dec.c
@@ -139,9 +139,11 @@ static void ff_eac3_apply_spectral_extension(AC3DecodeContext *s)
// spx_noise_blend and spx_signal_blend are both FP.23
nscale *= 1.0 / (1<<23);
sscale *= 1.0 / (1<<23);
+ if (nscale < -1.0)
+ nscale = -1.0;
#endif
for (i = 0; i < s->spx_band_sizes[bnd]; i++) {
- float noise = nscale * (int32_t)av_lfg_get(&s->dith_state);
+ UINTFLOAT noise = (INTFLOAT)(nscale * (int32_t)av_lfg_get(&s->dith_state));
s->transform_coeffs[ch][bin] *= sscale;
s->transform_coeffs[ch][bin++] += noise;
}