[FFmpeg-cvslog] pcx: fix rounding in bytes_per_scanline check

Michael Niedermayer git at videolan.org
Sun Feb 10 17:08:43 CET 2013


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Sun Feb 10 16:52:04 2013 +0100| [6462268e74fa2c935c2936904cc1da9f499c04f3] | committer: Michael Niedermayer

pcx: fix rounding in bytes_per_scanline check

Fixes out of array reads

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

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6462268e74fa2c935c2936904cc1da9f499c04f3
---

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

diff --git a/libavcodec/pcx.c b/libavcodec/pcx.c
index d60e502..6163c6e 100644
--- a/libavcodec/pcx.c
+++ b/libavcodec/pcx.c
@@ -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;
     }



More information about the ffmpeg-cvslog mailing list