[FFmpeg-devel,07/11] avcodec/apedec: Fix integer overflow in predictor_update_3930()

Submitted by Michael Niedermayer on Sept. 27, 2019, 5:23 p.m.

Details

Message ID 20190927172350.2095-7-michael@niedermayer.cc
State Accepted
Commit 5c072c9ed7c6f173b8a0a886fb7fe1e8e4c1fadd
Headers show

Commit Message

Michael Niedermayer Sept. 27, 2019, 5:23 p.m.
Fixes: signed integer overflow: -69555262 * 31 cannot be represented in type 'int'
Fixes: 17698/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_APE_fuzzer-5728970447781888

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/apedec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/libavcodec/apedec.c b/libavcodec/apedec.c
index ed22f0f019..087c281c49 100644
--- a/libavcodec/apedec.c
+++ b/libavcodec/apedec.c
@@ -1051,7 +1051,7 @@  static av_always_inline int predictor_update_3930(APEPredictor *p,
                   d3 * p->coeffsA[filter][3];
 
     p->lastA[filter] = decoded + (predictionA >> 9);
-    p->filterA[filter] = p->lastA[filter] + ((p->filterA[filter] * 31) >> 5);
+    p->filterA[filter] = p->lastA[filter] + ((int)(p->filterA[filter] * 31U) >> 5);
 
     sign = APESIGN(decoded);
     p->coeffsA[filter][0] += ((d0 < 0) * 2 - 1) * sign;