aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2016-01-10 12:19:48 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2016-01-15 12:30:40 +0100
commitdf4ee166f1a3a9b52a9df3b3720b056430619fc5 (patch)
tree9ab2cd4f6720f5dd313883d48278f954e04631f5
parentcb4ba7456a7901c08887ee20e8591753bf906bdd (diff)
downloadffmpeg-df4ee166f1a3a9b52a9df3b3720b056430619fc5.tar.gz
avcodec/mss2: Check for repeat overflow
Fixes: mss2_left_shift.wmv Found-by: Piotr Bandurski <ami_stuff@o2.pl> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit e273dade78943e22b71d0ddb67cd0d737fc26edf) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavcodec/mss2.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/libavcodec/mss2.c b/libavcodec/mss2.c
index 74e52af6cd..c640934986 100644
--- a/libavcodec/mss2.c
+++ b/libavcodec/mss2.c
@@ -210,8 +210,13 @@ static int decode_555(GetByteContext *gB, uint16_t *dst, int stride,
last_symbol = b << 8 | bytestream2_get_byte(gB);
else if (b > 129) {
repeat = 0;
- while (b-- > 130)
+ while (b-- > 130) {
+ if (repeat >= (INT_MAX >> 8) - 1) {
+ av_log(NULL, AV_LOG_ERROR, "repeat overflow\n");
+ return AVERROR_INVALIDDATA;
+ }
repeat = (repeat << 8) + bytestream2_get_byte(gB) + 1;
+ }
if (last_symbol == -2) {
int skip = FFMIN((unsigned)repeat, dst + w - p);
repeat -= skip;