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-07-01 12:49:26 +0200
commit7164a168fb91d8f2168a0e34b79f3f016e573d89 (patch)
tree0eb71ee01eddda7ffae647b7d40465428cd40e38 /libavcodec/dpcm.c
parent51e0e2deafa391b7a053293eb94cd37cf00237a6 (diff)
downloadffmpeg-7164a168fb91d8f2168a0e34b79f3f016e573d89.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> (cherry picked from commit 20ade59d9633def4ebf84ec170f56367bfb6aa6c) 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 2edd4d5b0a..0e7375a320 100644
--- a/libavcodec/dpcm.c
+++ b/libavcodec/dpcm.c
@@ -286,9 +286,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;