X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fmss2.c;h=c6409349869500d928daf20887eb991a233da5db;hb=0be4377333d8a9104eadd8b297605a6e95b22047;hp=74e52af6cd83069274879b835bc44aea1ada7bd6;hpb=5242cc878a7ac471ab0a8c42bb8945f072765fd6;p=ffmpeg diff --git a/libavcodec/mss2.c b/libavcodec/mss2.c index 74e52af6cd8..c6409349869 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;