summaryrefslogtreecommitdiff
path: root/libavcodec/c93.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-04-16 16:41:21 +0200
committerMichael Niedermayer <michaelni@gmx.at>2013-04-16 17:04:16 +0200
commit6b657ac7889738b9ab38924cca4e7c418f6fbc38 (patch)
treec9e89a63c76e86d34d3e5e2319c44aa330505196 /libavcodec/c93.c
parente701cd96c2d5dc034e7615967d208db3d953e111 (diff)
downloadffmpeg-6b657ac7889738b9ab38924cca4e7c418f6fbc38.tar.gz
avcodec/c93: Check for block overlap.
Fixes overlapping memcpy() Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/c93.c')
-rw-r--r--libavcodec/c93.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/libavcodec/c93.c b/libavcodec/c93.c
index 9aaa3ee780..c51f2fa9de 100644
--- a/libavcodec/c93.c
+++ b/libavcodec/c93.c
@@ -168,7 +168,14 @@ static int decode_frame(AVCodecContext *avctx, void *data,
case C93_4X4_FROM_PREV:
for (j = 0; j < 8; j += 4) {
for (i = 0; i < 8; i += 4) {
- offset = bytestream2_get_le16(&gb);
+ int offset = bytestream2_get_le16(&gb);
+ int from_x = offset % WIDTH;
+ int from_y = offset / WIDTH;
+ if (block_type == C93_4X4_FROM_CURR && from_y == y+j &&
+ (FFABS(from_x - x-i) < 4 || FFABS(from_x - x-i) > WIDTH-4)) {
+ avpriv_request_sample(avctx, "block overlap %d %d %d %d\n", from_x, x+i, from_y, y+j);
+ return AVERROR_INVALIDDATA;
+ }
if ((ret = copy_block(avctx, &out[j*stride+i],
copy_from, offset, 4, stride)) < 0)
return ret;