[FFmpeg-cvslog] avcodec/eac3dec: avoid float noise in fixed mode addition to overflow

Michael Niedermayer git at videolan.org
Sun Jun 4 22:04:57 EEST 2023


ffmpeg | branch: release/3.4 | Michael Niedermayer <michael at niedermayer.cc> | Fri Jan  6 23:36:12 2023 +0100| [1552773f07565321648cfee1ee4d4108927670c4] | committer: Michael Niedermayer

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 at niedermayer.cc>
(cherry picked from commit 2f48d227c153fa6f0a2156f3e8d18ea1bfedf18d)
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1552773f07565321648cfee1ee4d4108927670c4
---

 libavcodec/ac3.h     | 2 ++
 libavcodec/eac3dec.c | 4 +++-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/libavcodec/ac3.h b/libavcodec/ac3.h
index 5c9c37727e..d405b2bf20 100644
--- a/libavcodec/ac3.h
+++ b/libavcodec/ac3.h
@@ -74,6 +74,7 @@
 #define AC3_DYNAMIC_RANGE1      0
 
 typedef int                     INTFLOAT;
+typedef unsigned int            UINTFLOAT;
 typedef int16_t                 SHORTFLOAT;
 
 #else /* USE_FIXED */
@@ -93,6 +94,7 @@ typedef int16_t                 SHORTFLOAT;
 #define AC3_DYNAMIC_RANGE1      1.0f
 
 typedef float                   INTFLOAT;
+typedef float                   UINTFLOAT;
 typedef float                   SHORTFLOAT;
 
 #endif /* USE_FIXED */
diff --git a/libavcodec/eac3dec.c b/libavcodec/eac3dec.c
index c971879b2d..7764e19b4d 100644
--- a/libavcodec/eac3dec.c
+++ b/libavcodec/eac3dec.c
@@ -146,9 +146,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;
             }



More information about the ffmpeg-cvslog mailing list