aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/dpcm.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2020-04-09 15:37:55 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2020-04-11 18:15:58 +0200
commit20ade59d9633def4ebf84ec170f56367bfb6aa6c (patch)
tree85d1b42056e93bb4920e13d54b8dbc8ddf59e6b2 /libavcodec/dpcm.c
parent995d937827dda228e68eeffca10feeea32463cf7 (diff)
downloadffmpeg-20ade59d9633def4ebf84ec170f56367bfb6aa6c.tar.gz
avcodec/dpcm: clip exponent into supported range in XAN DPCM
Fixes: shift exponent 32 is too large for 32-bit type 'int' Fixes: 21200/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_XAN_DPCM_fuzzer-5754704894361600 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Reviewed-by: Anton Khirnov <anton@khirnov.net> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec/dpcm.c')
-rw-r--r--libavcodec/dpcm.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/libavcodec/dpcm.c b/libavcodec/dpcm.c
index 069bf1dcd8..7078419f08 100644
--- a/libavcodec/dpcm.c
+++ b/libavcodec/dpcm.c
@@ -321,9 +321,8 @@ static int dpcm_decode_frame(AVCodecContext *avctx, void *data,
shift[ch] -= (2 * n);
diff = sign_extend((diff &~ 3) << 8, 16);
- /* saturate the shifter to a lower limit of 0 */
- if (shift[ch] < 0)
- shift[ch] = 0;
+ /* saturate the shifter to 0..31 */
+ shift[ch] = av_clip_uintp2(shift[ch], 5);
diff >>= shift[ch];
predictor[ch] += diff;