avcodec/vmdvideo: Check len before using it in method 3
authorMichael Niedermayer <michaelni@gmx.at>
Tue, 16 Dec 2014 15:24:55 +0000 (16:24 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Sun, 21 Dec 2014 03:40:35 +0000 (04:40 +0100)
Fixes out of array access
Fixes: asan_heap-oob_4d23ba_91_cov_3853393937_128.vmd

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit 3030fb7e0d41836f8add6399e9a7c7b740b48bfd)

Conflicts:

libavcodec/vmdav.c

libavcodec/vmdav.c

index 9c24a01..f17bd49 100644 (file)
@@ -340,8 +340,12 @@ static int vmd_decode(VmdVideoContext *s)
                         len = rle_unpack(gb.buffer, &dp[ofs],
                                          len, bytestream2_get_bytes_left(&gb),
                                          frame_width - ofs);
-                    else
+                    else {
+                        if (ofs + len > frame_width ||
+                            bytestream2_get_bytes_left(&gb) < len)
+                            return AVERROR_INVALIDDATA;
                         bytestream2_get_buffer(&gb, &dp[ofs], len);
+                    }
                     bytestream2_skip(&gb, len);
                 } else {
                     /* interframe pixel copy */