aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2018-02-17 21:42:34 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2018-06-18 01:16:03 +0200
commit4597b51e8a43c40fabf834904a9f0d376427c8ff (patch)
tree792eb517916f3001968a91c22168bef958b23fce /libavcodec
parentfcc6932e098445f081530f2251ccd3dc81ffc630 (diff)
downloadffmpeg-4597b51e8a43c40fabf834904a9f0d376427c8ff.tar.gz
avcodec/hevcdec: Check luma/chroma_log2_weight_denom
Fixes: signed integer overflow: 3 + 2147483647 cannot be represented in type 'int' Fixes: 5888/clusterfuzz-testcase-minimized-5634701067812864 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 f82dd4c09b2decb033f1e339d4be81efd38554f1) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/hevcdec.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index 67ac9ab262..89b121d2f0 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -150,12 +150,18 @@ static int pred_weight_table(HEVCContext *s, GetBitContext *gb)
int luma_log2_weight_denom;
luma_log2_weight_denom = get_ue_golomb_long(gb);
- if (luma_log2_weight_denom < 0 || luma_log2_weight_denom > 7)
+ if (luma_log2_weight_denom < 0 || luma_log2_weight_denom > 7) {
av_log(s->avctx, AV_LOG_ERROR, "luma_log2_weight_denom %d is invalid\n", luma_log2_weight_denom);
+ return AVERROR_INVALIDDATA;
+ }
s->sh.luma_log2_weight_denom = av_clip_uintp2(luma_log2_weight_denom, 3);
if (s->ps.sps->chroma_format_idc != 0) {
- int delta = get_se_golomb(gb);
- s->sh.chroma_log2_weight_denom = av_clip_uintp2(s->sh.luma_log2_weight_denom + delta, 3);
+ int64_t chroma_log2_weight_denom = luma_log2_weight_denom + (int64_t)get_se_golomb(gb);
+ if (chroma_log2_weight_denom < 0 || chroma_log2_weight_denom > 7) {
+ av_log(s->avctx, AV_LOG_ERROR, "chroma_log2_weight_denom %"PRId64" is invalid\n", chroma_log2_weight_denom);
+ return AVERROR_INVALIDDATA;
+ }
+ s->sh.chroma_log2_weight_denom = chroma_log2_weight_denom;
}
for (i = 0; i < s->sh.nb_refs[L0]; i++) {