avcodec/utvideodec: Fix bytes left check in decode_frame()
authorMichael Niedermayer <michael@niedermayer.cc>
Fri, 2 Feb 2018 20:44:57 +0000 (21:44 +0100)
committerMichael Niedermayer <michael@niedermayer.cc>
Mon, 5 Feb 2018 01:54:02 +0000 (02:54 +0100)
Fixes: out of array read
Fixes: poc-2017.avi

Found-by: GwanYeong Kim <gy741.kim@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/utvideodec.c

index 608c8c4..1bcd14e 100644 (file)
@@ -676,7 +676,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
             for (j = 0; j < c->slices; j++) {
                 slice_end   = bytestream2_get_le32u(&gb);
                 if (slice_end < 0 || slice_end < slice_start ||
-                    bytestream2_get_bytes_left(&gb) < slice_end) {
+                    bytestream2_get_bytes_left(&gb) < slice_end + 1024LL) {
                     av_log(avctx, AV_LOG_ERROR, "Incorrect slice size\n");
                     return AVERROR_INVALIDDATA;
                 }