]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/cfhd: Fix negative shift in cfhd_decode()
authorMichael Niedermayer <michael@niedermayer.cc>
Tue, 16 Feb 2021 23:02:04 +0000 (00:02 +0100)
committerMichael Niedermayer <michael@niedermayer.cc>
Sun, 14 Mar 2021 22:29:51 +0000 (23:29 +0100)
Fixes: left shift of negative value -1
Fixes: 30714/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CFHD_fuzzer-4867823371419648
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/cfhd.c

index dfd56ae6ed8fe364a2130a4a91c93b45be06cd2c..1f2ee853c12d04b7649a17d7ec3cf61634163dd1 100644 (file)
@@ -811,7 +811,7 @@ static int cfhd_decode(AVCodecContext *avctx, void *data, int *got_frame,
                             const uint16_t q = s->quantisation;
 
                             for (i = 0; i < run; i++) {
-                                *coeff_data |= coeff << 8;
+                                *coeff_data |= coeff * 256;
                                 *coeff_data++ *= q;
                             }
                         } else {
@@ -842,7 +842,7 @@ static int cfhd_decode(AVCodecContext *avctx, void *data, int *got_frame,
                             const uint16_t q = s->quantisation;
 
                             for (i = 0; i < run; i++) {
-                                *coeff_data |= coeff << 8;
+                                *coeff_data |= coeff * 256;
                                 *coeff_data++ *= q;
                             }
                         } else {