pcx: fix rounding in bytes_per_scanline check
authorMichael Niedermayer <michaelni@gmx.at>
Sun, 10 Feb 2013 15:52:04 +0000 (16:52 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Sun, 10 Feb 2013 15:52:38 +0000 (16:52 +0100)
Fixes out of array reads

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libavcodec/pcx.c

index d60e502..6163c6e 100644 (file)
@@ -119,7 +119,7 @@ static int pcx_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
     bytes_per_line     = bytestream2_get_le16u(&gb);
     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) {
         av_log(avctx, AV_LOG_ERROR, "PCX data is corrupted\n");
         return AVERROR_INVALIDDATA;
     }