summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-01-20 18:08:18 +0100
committerMichael Niedermayer <michaelni@gmx.at>2014-01-21 16:59:06 +0100
commit32262ca7d781cc82126e848cc200cef36afd3f8c (patch)
tree19d1225c5a9d18a3bedef50983cf5073e5c8eaad
parent5f56e495aea44bd43d24e237e898b8a8aa6726e6 (diff)
downloadffmpeg-32262ca7d781cc82126e848cc200cef36afd3f8c.tar.gz
avcodec/vmnc: Check that rectangles are within the picture
Prevents out of array accesses with CODEC_FLAG_EMU_EDGE Signed-off-by: Michael Niedermayer <michaelni@gmx.at> (cherry picked from commit 6ba02602aa7fc7d38db582e75b8b093fb3c1608d) Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavcodec/vmnc.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/libavcodec/vmnc.c b/libavcodec/vmnc.c
index 5f91ab1b31..46bd52ee26 100644
--- a/libavcodec/vmnc.c
+++ b/libavcodec/vmnc.c
@@ -291,6 +291,11 @@ static int decode_hextile(VmncContext *c, uint8_t* dst, GetByteContext *gb,
fg = vmnc_get_pixel(gb, bpp, c->bigendian);
xy = bytestream2_get_byte(gb);
wh = bytestream2_get_byte(gb);
+ if ( (xy >> 4) + (wh >> 4) + 1 > w - i
+ || (xy & 0xF) + (wh & 0xF)+1 > h - j) {
+ av_log(c->avctx, AV_LOG_ERROR, "Rectangle outside picture\n");
+ return AVERROR_INVALIDDATA;
+ }
paint_rect(dst2, xy >> 4, xy & 0xF,
(wh>>4)+1, (wh & 0xF)+1, fg, bpp, stride);
}