diff mbox series

[FFmpeg-devel,1/4] avcodec/adpcm: Clip predictor for IMA_APM

Message ID 20200510104058.10321-1-michael@niedermayer.cc
State Accepted
Commit 8ee264e6844518a0f1e23bd5808a60a7c54af429
Headers show
Series [FFmpeg-devel,1/4] avcodec/adpcm: Clip predictor for IMA_APM | expand

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Michael Niedermayer May 10, 2020, 10:40 a.m. UTC
Fixes: signed integer overflow: -2147483647 - 61436 cannot be represented in type 'int'
Fixes: 20492/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ADPCM_IMA_APM_fuzzer-5092176004644864

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

Comments

Michael Niedermayer May 11, 2020, 5:04 p.m. UTC | #1
On Sun, May 10, 2020 at 12:40:55PM +0200, Michael Niedermayer wrote:
> Fixes: signed integer overflow: -2147483647 - 61436 cannot be represented in type 'int'
> Fixes: 20492/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ADPCM_IMA_APM_fuzzer-5092176004644864
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/adpcm.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

will apply patchset

[...]
diff mbox series

Patch

diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c
index c6735a49c9..846ec5ef9c 100644
--- a/libavcodec/adpcm.c
+++ b/libavcodec/adpcm.c
@@ -163,9 +163,9 @@  static av_cold int adpcm_decode_init(AVCodecContext * avctx)
         break;
     case AV_CODEC_ID_ADPCM_IMA_APM:
         if (avctx->extradata && avctx->extradata_size >= 16) {
-            c->status[0].predictor  = AV_RL32(avctx->extradata +  0);
+            c->status[0].predictor  = av_clip_intp2(AV_RL32(avctx->extradata +  0), 18);
             c->status[0].step_index = av_clip(AV_RL32(avctx->extradata +  4), 0, 88);
-            c->status[1].predictor  = AV_RL32(avctx->extradata +  8);
+            c->status[1].predictor  = av_clip_intp2(AV_RL32(avctx->extradata +  8), 18);
             c->status[1].step_index = av_clip(AV_RL32(avctx->extradata + 12), 0, 88);
         }
         break;