aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2019-12-14 15:27:44 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2020-04-23 21:29:01 +0200
commite4c08e941907f0036e70ebcd7d9d15ec7e82c355 (patch)
tree6636b51fad2f9154bcfbb28853481ca2d0161446
parentbfdc0b24a91138b8d80c3ea8c0cf7133d864b83d (diff)
downloadffmpeg-e4c08e941907f0036e70ebcd7d9d15ec7e82c355.tar.gz
avcodec/wmavoice: Fix rounding and integer anomalies in calc_input_response()
Fixes: out of array access Fixes: inf is outside the range of representable values of type 'int' Fixes: signed integer overflow: -9223372036854775808 - 1 cannot be represented in type 'long' Fixes: 19316/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WMAVOICE_fuzzer-5677369365102592 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 38d37584448731f90977132b838d50ff1a28811b) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavcodec/wmavoice.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/libavcodec/wmavoice.c b/libavcodec/wmavoice.c
index 799f719283..1ab93bb19c 100644
--- a/libavcodec/wmavoice.c
+++ b/libavcodec/wmavoice.c
@@ -607,12 +607,14 @@ static void calc_input_response(WMAVoiceContext *s, float *lpcs,
for (n = 0; n <= 64; n++) {
float pwr;
- idx = FFMAX(0, lrint((max - lpcs[n]) * irange) - 1);
+ idx = lrint((max - lpcs[n]) * irange - 1);
+ idx = FFMAX(0, idx);
pwr = wmavoice_denoise_power_table[s->denoise_strength][idx];
lpcs[n] = angle_mul * pwr;
/* 70.57 =~ 1/log10(1.0331663) */
- idx = (pwr * gain_mul - 0.0295) * 70.570526123;
+ idx = av_clipf((pwr * gain_mul - 0.0295) * 70.570526123, 0, INT_MAX / 2);
+
if (idx > 127) { // fall back if index falls outside table range
coeffs[n] = wmavoice_energy_table[127] *
powf(1.0331663, idx - 127);