]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/dpcm: clip exponent into supported range in XAN DPCM
authorMichael Niedermayer <michael@niedermayer.cc>
Thu, 9 Apr 2020 13:37:55 +0000 (15:37 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Sat, 11 Apr 2020 16:15:58 +0000 (18:15 +0200)
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>
libavcodec/dpcm.c

index 069bf1dcd8ab014278c4f4a88a64c1c1845624df..7078419f080b45b9e535afcf65809cdbb86f606e 100644 (file)
@@ -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;