avcodec/jpeglsdec: check shift for values that cause overflow later
authorMichael Niedermayer <michael@niedermayer.cc>
Thu, 23 Feb 2017 22:13:24 +0000 (23:13 +0100)
committerMichael Niedermayer <michael@niedermayer.cc>
Thu, 23 Feb 2017 23:38:45 +0000 (00:38 +0100)
Fixes: 657/clusterfuzz-testcase-6674741433729024
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/targets/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/jpeglsdec.c

index 68151cb..c8550e4 100644 (file)
@@ -375,6 +375,11 @@ int ff_jpegls_decode_picture(MJpegDecodeContext *s, int near,
     else
         shift = point_transform + (16 - s->bits);
 
+    if (shift >= 16) {
+        ret = AVERROR_INVALIDDATA;
+        goto end;
+    }
+
     if (s->avctx->debug & FF_DEBUG_PICT_INFO) {
         av_log(s->avctx, AV_LOG_DEBUG,
                "JPEG-LS params: %ix%i NEAR=%i MV=%i T(%i,%i,%i) "