[libav-stable] pcx: round up in bits->bytes conversion in a buffer size check

Anton Khirnov git at libav.org
Thu Nov 21 21:14:30 CET 2013


Module: libav
Branch: master
Commit: 430d12196432ded13f011a3bf7690f03c9b2e5d6

Author:    Anton Khirnov <anton at khirnov.net>
Committer: Anton Khirnov <anton at khirnov.net>
Date:      Fri Nov 15 19:06:23 2013 +0100

pcx: round up in bits->bytes conversion in a buffer size check

Fixes invalid reads.
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC:libav-stable at libav.org

---

 libavcodec/pcx.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/pcx.c b/libavcodec/pcx.c
index 1a5357b..61c971e 100644
--- a/libavcodec/pcx.c
+++ b/libavcodec/pcx.c
@@ -109,7 +109,7 @@ static int pcx_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
     nplanes            = buf[65];
     bytes_per_scanline = nplanes * bytes_per_line;
 
-    if (bytes_per_scanline < w * bits_per_pixel * nplanes / 8 ||
+    if (bytes_per_scanline < (w * bits_per_pixel * nplanes + 7) / 8 ||
         (!compressed && bytes_per_scanline > buf_size / h)) {
         av_log(avctx, AV_LOG_ERROR, "PCX data is corrupted\n");
         return AVERROR_INVALIDDATA;



More information about the libav-stable mailing list