aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
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 17:23:55 +0100
commitaa5ae8b2136f9390dcc7e4dd31b1a2e557045449 (patch)
tree3e1d82465d6f488d636aec385ce803c12b3a2c7d /libavcodec
parentc0315b74e2563f8c3b97e8ff99cd9bd12654c143 (diff)
downloadffmpeg-aa5ae8b2136f9390dcc7e4dd31b1a2e557045449.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>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/mss2.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/libavcodec/mss2.c b/libavcodec/mss2.c
index 4d53f8ab8f..ea448dabc5 100644
--- a/libavcodec/mss2.c
+++ b/libavcodec/mss2.c
@@ -209,8 +209,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;