avcodec/magicyuv: Check that vlc len is not too large
authorMichael Niedermayer <michael@niedermayer.cc>
Wed, 12 Jul 2017 15:25:16 +0000 (17:25 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Wed, 19 Jul 2017 01:53:22 +0000 (03:53 +0200)
Fixes: runtime error: shift exponent -95 is negative
Fixes: 2568/clusterfuzz-testcase-minimized-4926115716005888

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 341f01290c2353669ed2263f56e1a9f4c67cc597)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/magicyuv.c

index 2c312be..742e6ec 100644 (file)
@@ -84,6 +84,8 @@ static int huff_build(VLC *vlc, uint8_t *len)
     for (i = 0; i < 256; i++) {
         he[i].sym = 255 - i;
         he[i].len = len[i];
+        if (len[i] == 0 || len[i] > 32)
+            return AVERROR_INVALIDDATA;
     }
     AV_QSORT(he, 256, HuffEntry, huff_cmp_len);