aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-12-16 16:24:55 +0100
committerMichael Niedermayer <michaelni@gmx.at>2015-03-12 18:03:49 +0100
commit87ec3c615689e3d8bce36f1a168d908c7502b867 (patch)
tree850aa4084cd310d41a091cbe89ba376ffff02160
parentadf2f2166e7e713e5702bc58e97866060578c2d9 (diff)
downloadffmpeg-87ec3c615689e3d8bce36f1a168d908c7502b867.tar.gz
avcodec/vmdvideo: Check len before using it in method 3
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
-rw-r--r--libavcodec/vmdav.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/libavcodec/vmdav.c b/libavcodec/vmdav.c
index 1e5f2caab8..2b491ad86a 100644
--- a/libavcodec/vmdav.c
+++ b/libavcodec/vmdav.c
@@ -319,8 +319,12 @@ static void 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;
bytestream2_get_buffer(&gb, &dp[ofs], len);
+ }
bytestream2_skip(&gb, len);
} else {
/* interframe pixel copy */