sanm: Check decoded_size.
authorMichael Niedermayer <michaelni@gmx.at>
Wed, 23 Jan 2013 23:27:10 +0000 (00:27 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Tue, 5 Feb 2013 15:47:41 +0000 (16:47 +0100)
This prevents a buffer overflow in rle_decode()

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

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

index ff70f20..0f68e1d 100644 (file)
@@ -639,6 +639,11 @@ static int old_codec47(SANMVideoContext *ctx, int top,
     decoded_size = bytestream2_get_le32(&ctx->gb);
     bytestream2_skip(&ctx->gb, 8);
 
+    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");
+    }
+
     if (skip & 1)
         bytestream2_skip(&ctx->gb, 0x8080);
     if (!seq) {