diff options
author | Michael Niedermayer <michael@niedermayer.cc> | 2017-07-24 15:48:37 +0200 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2017-07-26 17:24:25 +0200 |
commit | 2f75ebe24a775b00236f34a083a806f60e162c57 (patch) | |
tree | d690d358f1690b90c37ae6dc6acfcbbea102e024 /libavcodec | |
parent | a9081b36f4d2193b2d9df059bf668f752dbfd636 (diff) | |
download | ffmpeg-2f75ebe24a775b00236f34a083a806f60e162c57.tar.gz |
avcodec/hevc_ps: fix integer overflow in log2_parallel_merge_level_minus2
Fixes: runtime error: signed integer overflow: -2147483647 - 2 cannot be represented in type 'int'
Fixes: 2702/clusterfuzz-testcase-minimized-4511932591636480
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 74c1c22d7f0d25f527ed2ebf62493be5ad52c972)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/hevc_ps.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c index 65de6f0f81..19e61977b5 100644 --- a/libavcodec/hevc_ps.c +++ b/libavcodec/hevc_ps.c @@ -1438,6 +1438,7 @@ int ff_hevc_decode_nal_pps(GetBitContext *gb, AVCodecContext *avctx, int i, ret = 0; unsigned int pps_id = 0; ptrdiff_t nal_size; + unsigned log2_parallel_merge_level_minus2; AVBufferRef *pps_buf; HEVCPPS *pps = av_mallocz(sizeof(*pps)); @@ -1635,13 +1636,14 @@ int ff_hevc_decode_nal_pps(GetBitContext *gb, AVCodecContext *avctx, goto err; } pps->lists_modification_present_flag = get_bits1(gb); - pps->log2_parallel_merge_level = get_ue_golomb_long(gb) + 2; - if (pps->log2_parallel_merge_level > sps->log2_ctb_size) { + log2_parallel_merge_level_minus2 = get_ue_golomb_long(gb); + if (log2_parallel_merge_level_minus2 > sps->log2_ctb_size) { av_log(avctx, AV_LOG_ERROR, "log2_parallel_merge_level_minus2 out of range: %d\n", - pps->log2_parallel_merge_level - 2); + log2_parallel_merge_level_minus2); ret = AVERROR_INVALIDDATA; goto err; } + pps->log2_parallel_merge_level = log2_parallel_merge_level_minus2 + 2; pps->slice_header_extension_present_flag = get_bits1(gb); |