sanm: add forgotten check for decoded_size in old_codec37()
authorMichael Niedermayer <michaelni@gmx.at>
Tue, 12 Feb 2013 00:09:03 +0000 (01:09 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Sun, 3 Mar 2013 01:41:07 +0000 (02:41 +0100)
Fixes out of array accesses

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

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavcodec/sanm.c

index 21073e2..1d5d064 100644 (file)
@@ -415,6 +415,11 @@ static int old_codec37(SANMVideoContext *ctx, int top,
     flags        = bytestream2_get_byte(&ctx->gb);
     bytestream2_skip(&ctx->gb, 3);
 
+    if (decoded_size > height * stride - left - top * stride) {
+        decoded_size = height * stride - left - top * stride;
+        av_log(ctx->avctx, AV_LOG_WARNING, "decoded size is too large\n");
+    }
+
     ctx->rotate_code = 0;
 
     if (((seq & 1) || !(flags & 1)) && (compr && compr != 2))