avcodec/hevc_ps: Check log2_sao_offset_scale_*
authorMichael Niedermayer <michael@niedermayer.cc>
Wed, 24 Jan 2018 02:15:23 +0000 (03:15 +0100)
committerMichael Niedermayer <michael@niedermayer.cc>
Tue, 30 Jan 2018 21:08:32 +0000 (22:08 +0100)
Fixes: 4868/clusterfuzz-testcase-minimized-6236542906400768
Fixes: runtime error: shift exponent 126 is too large for 32-bit type 'int'

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/hevc_ps.c

index 4787312..1f18d03 100644 (file)
@@ -1324,6 +1324,11 @@ static int pps_range_extensions(GetBitContext *gb, AVCodecContext *avctx,
     pps->log2_sao_offset_scale_luma = get_ue_golomb_long(gb);
     pps->log2_sao_offset_scale_chroma = get_ue_golomb_long(gb);
 
+    if (   pps->log2_sao_offset_scale_luma   > FFMAX(sps->bit_depth        - 10, 0)
+        || pps->log2_sao_offset_scale_chroma > FFMAX(sps->bit_depth_chroma - 10, 0)
+    )
+        return AVERROR_INVALIDDATA;
+
     return(0);
 }