History

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

Michael Niedermayer committed 3 years ago

Commit 2f48d221 parent 9ea6d932 files · +5 −1Browse files

Showing the changes to libavcodec (2 of 2 files). Show all

Unified · Split

2 files
  1. libavcodec/ac3.h +2 −0
  2. libavcodec/eac3dec.c +3 −1
libavcodec/ac3.h+2−0
@@ -53,6 +53,7 @@ · 52 unmodified lines
5353 #define AC3_DYNAMIC_RANGE1 0
5454
5555 typedef int INTFLOAT;
56+typedef unsigned int UINTFLOAT;
5657 typedef int16_t SHORTFLOAT;
5758
5859 #else /* USE_FIXED */
@@ -73,6 +74,7 @@ typedef int16_t SHORTFLOAT; · 14 unmodified lines
7374 #define AC3_DYNAMIC_RANGE1 1.0f
7475
7576 typedef float INTFLOAT;
77+typedef float UINTFLOAT;
7678 typedef float SHORTFLOAT;
7779
7880 #endif /* USE_FIXED */
libavcodec/eac3dec.c+3−1
@@ -138,9 +138,11 @@ static void ff_eac3_apply_spectral_extension(AC3DecodeContext *s) · 137 unmodified lines
138138 // spx_noise_blend and spx_signal_blend are both FP.23
139139 nscale *= 1.0 / (1<<23);
140140 sscale *= 1.0 / (1<<23);
141+ if (nscale < -1.0)
142+ nscale = -1.0;
141143 #endif
142144 for (i = 0; i < s->spx_band_sizes[bnd]; i++) {
143− float noise = nscale * (int32_t)av_lfg_get(&s->dith_state);
145+ UINTFLOAT noise = (INTFLOAT)(nscale * (int32_t)av_lfg_get(&s->dith_state));
144146 s->transform_coeffs[ch][bin] *= sscale;
145147 s->transform_coeffs[ch][bin++] += noise;
146148 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t