summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2017-02-20 23:59:26 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2017-02-21 00:40:20 +0100
commit0a65dae9d0c01730323695fdc45eb1c1f5a978f7 (patch)
tree3d341c6e32c42f35b1956c40929d990e5c434bef
parente04108dfa6d13d171b0e1b5646cc10ce51050bed (diff)
avcodec/flacdec: reduce limit for golomb so that the max value does not overflow
Fixes: runtime error: left shift of 32 by 26 places cannot be represented in type 'int' Fixes: 628/clusterfuzz-testcase-6187747641393152 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/targets/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavcodec/flacdec.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/libavcodec/flacdec.c b/libavcodec/flacdec.c
index 6ea86d4eb1..f73a32b461 100644
--- a/libavcodec/flacdec.c
+++ b/libavcodec/flacdec.c
@@ -258,8 +258,9 @@ static int decode_residuals(FLACContext *s, int32_t *decoded, int pred_order)
for (; i < samples; i++)
*decoded++ = get_sbits_long(&s->gb, tmp);
} else {
+ int real_limit = tmp ? (INT_MAX >> tmp) + 2 : INT_MAX;
for (; i < samples; i++) {
- int v = get_sr_golomb_flac(&s->gb, tmp, INT_MAX, 0);
+ int v = get_sr_golomb_flac(&s->gb, tmp, real_limit, 0);
if (v == 0x80000000){
av_log(s->avctx, AV_LOG_ERROR, "invalid residual\n");
return AVERROR_INVALIDDATA;