aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2020-12-18 23:05:22 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2021-10-09 22:02:20 +0200
commite46b067199d74bcb8476a159916011c130e3ddbc (patch)
tree35f833a629cf6f77b2d3d16e12bd14f24d3d8441
parenta9fe6abe0a1c86717c1b80df00af458d2d6e97d4 (diff)
downloadffmpeg-e46b067199d74bcb8476a159916011c130e3ddbc.tar.gz
avcodec/hevc_ps: check scaling_list_dc_coef
Fixes: signed integer overflow: 2147483640 + 8 cannot be represented in type 'int' Fixes: 28449/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HEVC_fuzzer-5686013259284480 Reviewed-by: James Almer <jamrial@gmail.com> 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 f1700bd8bb983bb3b56c3a1f8b9078cb62a44f65) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavcodec/hevc_ps.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
index 166471fe38..9ddf667c6a 100644
--- a/libavcodec/hevc_ps.c
+++ b/libavcodec/hevc_ps.c
@@ -755,7 +755,11 @@ static int scaling_list_data(GetBitContext *gb, AVCodecContext *avctx, ScalingLi
next_coef = 8;
coef_num = FFMIN(64, 1 << (4 + (size_id << 1)));
if (size_id > 1) {
- scaling_list_dc_coef[size_id - 2][matrix_id] = get_se_golomb(gb) + 8;
+ int scaling_list_coeff_minus8 = get_se_golomb(gb);
+ if (scaling_list_coeff_minus8 < -7 ||
+ scaling_list_coeff_minus8 > 247)
+ return AVERROR_INVALIDDATA;
+ scaling_list_dc_coef[size_id - 2][matrix_id] = scaling_list_coeff_minus8 + 8;
next_coef = scaling_list_dc_coef[size_id - 2][matrix_id];
sl->sl_dc[size_id - 2][matrix_id] = next_coef;
}