1
mirror of https://git.videolan.org/git/ffmpeg.git synced 2024-10-05 18:01:59 +02:00

avcodec/aacsbr_fixed: Fix multiple runtime error: left shift of negative value -407

Fixes: 1674/clusterfuzz-testcase-minimized-6092531563495424
Fixes: 1686/clusterfuzz-testcase-minimized-6282691643179008

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/targets/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Michael Niedermayer 2017-05-19 12:14:59 +02:00
parent 55b56a8d6a
commit 2ccd2c9003
3 changed files with 8 additions and 8 deletions

View File

@ -2800,9 +2800,9 @@ static void spectral_to_sample(AACContext *ac, int samples)
int j; int j;
/* preparation for resampler */ /* preparation for resampler */
for(j = 0; j<samples; j++){ for(j = 0; j<samples; j++){
che->ch[0].ret[j] = (int32_t)av_clip64((int64_t)che->ch[0].ret[j]<<7, INT32_MIN, INT32_MAX-0x8000)+0x8000; che->ch[0].ret[j] = (int32_t)av_clip64((int64_t)che->ch[0].ret[j]*128, INT32_MIN, INT32_MAX-0x8000)+0x8000;
if(type == TYPE_CPE) if(type == TYPE_CPE)
che->ch[1].ret[j] = (int32_t)av_clip64((int64_t)che->ch[1].ret[j]<<7, INT32_MIN, INT32_MAX-0x8000)+0x8000; che->ch[1].ret[j] = (int32_t)av_clip64((int64_t)che->ch[1].ret[j]*128, INT32_MIN, INT32_MAX-0x8000)+0x8000;
} }
} }
#endif /* USE_FIXED */ #endif /* USE_FIXED */

View File

@ -289,7 +289,7 @@ static void sbr_hf_inverse_filter(SBRDSPContext *dsp,
if (shift >= 3) if (shift >= 3)
alpha0[k][0] = 0x7fffffff; alpha0[k][0] = 0x7fffffff;
else { else {
a00.mant <<= 1; a00.mant *= 2;
shift = 2-shift; shift = 2-shift;
if (shift == 0) if (shift == 0)
alpha0[k][0] = a00.mant; alpha0[k][0] = a00.mant;
@ -303,7 +303,7 @@ static void sbr_hf_inverse_filter(SBRDSPContext *dsp,
if (shift >= 3) if (shift >= 3)
alpha0[k][1] = 0x7fffffff; alpha0[k][1] = 0x7fffffff;
else { else {
a01.mant <<= 1; a01.mant *= 2;
shift = 2-shift; shift = 2-shift;
if (shift == 0) if (shift == 0)
alpha0[k][1] = a01.mant; alpha0[k][1] = a01.mant;
@ -316,7 +316,7 @@ static void sbr_hf_inverse_filter(SBRDSPContext *dsp,
if (shift >= 3) if (shift >= 3)
alpha1[k][0] = 0x7fffffff; alpha1[k][0] = 0x7fffffff;
else { else {
a10.mant <<= 1; a10.mant *= 2;
shift = 2-shift; shift = 2-shift;
if (shift == 0) if (shift == 0)
alpha1[k][0] = a10.mant; alpha1[k][0] = a10.mant;
@ -330,7 +330,7 @@ static void sbr_hf_inverse_filter(SBRDSPContext *dsp,
if (shift >= 3) if (shift >= 3)
alpha1[k][1] = 0x7fffffff; alpha1[k][1] = 0x7fffffff;
else { else {
a11.mant <<= 1; a11.mant *= 2;
shift = 2-shift; shift = 2-shift;
if (shift == 0) if (shift == 0)
alpha1[k][1] = a11.mant; alpha1[k][1] = a11.mant;

View File

@ -116,7 +116,7 @@ static av_always_inline SoftFloat autocorr_calc(int64_t accu)
} else { } else {
nz = 0; nz = 0;
while (FFABS(i) < 0x40000000) { while (FFABS(i) < 0x40000000) {
i <<= 1; i *= 2;
nz++; nz++;
} }
nz = 32-nz; nz = 32-nz;
@ -125,7 +125,7 @@ static av_always_inline SoftFloat autocorr_calc(int64_t accu)
round = 1U << (nz-1); round = 1U << (nz-1);
mant = (int)((accu + round) >> nz); mant = (int)((accu + round) >> nz);
mant = (mant + 0x40)>>7; mant = (mant + 0x40)>>7;
mant <<= 6; mant *= 64;
expo = nz + 15; expo = nz + 15;
return av_int2sf(mant, 30 - expo); return av_int2sf(mant, 30 - expo);
} }