[FFmpeg-devel,2/3] avcodec/adpcm: Fix undefined behavior with negative predictions in IMA OKI

Submitted by Michael Niedermayer on Oct. 25, 2019, 1:02 p.m.

Details

Message ID 20191025130218.26463-2-michael@niedermayer.cc
State Accepted
Commit 7786f6c30e77a393b72ded01baa4250738925509
Headers show

Commit Message

Michael Niedermayer Oct. 25, 2019, 1:02 p.m.
Fixes: left shift of negative value -30
Fixes: 18392/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ADPCM_IMA_OKI_fuzzer-5631771831435264

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 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Michael Niedermayer Nov. 9, 2019, 5:04 p.m.
On Fri, Oct 25, 2019 at 03:02:17PM +0200, Michael Niedermayer wrote:
> Fixes: left shift of negative value -30
> Fixes: 18392/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ADPCM_IMA_OKI_fuzzer-5631771831435264
> 
> 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 | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

will apply

[...]

Patch hide | download patch | download mbox

diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c
index a8e74522b3..373115df75 100644
--- a/libavcodec/adpcm.c
+++ b/libavcodec/adpcm.c
@@ -342,7 +342,7 @@  static inline int16_t adpcm_ima_oki_expand_nibble(ADPCMChannelStatus *c, int nib
     c->predictor = av_clip_intp2(predictor, 11);
     c->step_index = step_index;
 
-    return c->predictor << 4;
+    return c->predictor * 16;
 }
 
 static inline int16_t adpcm_ct_expand_nibble(ADPCMChannelStatus *c, int8_t nibble)