aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2018-01-07 20:43:24 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2018-01-08 23:19:15 +0100
commita9fb75893bc7b8033f629b336e30ec06b819fd0e (patch)
tree8a3cf9112fa3daf6ecf45aeeef876489e9d5d65b /libavcodec
parentc28752f03a9ea7d37099f6b36f121a355e608f82 (diff)
downloadffmpeg-a9fb75893bc7b8033f629b336e30ec06b819fd0e.tar.gz
avcodec/diracdec: Fix integer overflow with quant
Fixes: signed integer overflow: 2 + 2147483646 cannot be represented in type 'int' Fixes: 4792/clusterfuzz-testcase-minimized-6322450775146496 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 eaa93175895568ef6c2542b13104874907d9c4ef) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/diracdec.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/libavcodec/diracdec.c b/libavcodec/diracdec.c
index 0b8b799dc0..4b5081ec18 100644
--- a/libavcodec/diracdec.c
+++ b/libavcodec/diracdec.c
@@ -502,16 +502,16 @@ static inline void codeblock(DiracContext *s, SubBand *b,
}
if (s->codeblock_mode && !(s->old_delta_quant && blockcnt_one)) {
- int quant = b->quant;
+ int quant;
if (is_arith)
- quant += dirac_get_arith_int(c, CTX_DELTA_Q_F, CTX_DELTA_Q_DATA);
+ quant = dirac_get_arith_int(c, CTX_DELTA_Q_F, CTX_DELTA_Q_DATA);
else
- quant += dirac_get_se_golomb(gb);
- if (quant < 0) {
+ quant = dirac_get_se_golomb(gb);
+ if (quant > INT_MAX - b->quant || b->quant + quant < 0) {
av_log(s->avctx, AV_LOG_ERROR, "Invalid quant\n");
return;
}
- b->quant = quant;
+ b->quant += quant;
}
if (b->quant > (DIRAC_MAX_QUANT_INDEX - 1)) {