summaryrefslogtreecommitdiff
path: root/libavcodec/pcx.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2013-11-15 19:06:23 +0100
committerAnton Khirnov <anton@khirnov.net>2013-11-21 20:58:27 +0100
commit430d12196432ded13f011a3bf7690f03c9b2e5d6 (patch)
tree2c7eac9540e5cbb1cc0ab4e1203a8a0e65b0cfba /libavcodec/pcx.c
parentc918e08b9cc9ce8d06159c51da55ec5ab018039a (diff)
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@libav.org
Diffstat (limited to 'libavcodec/pcx.c')
-rw-r--r--libavcodec/pcx.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/libavcodec/pcx.c b/libavcodec/pcx.c
index 1a5357b012..61c971e073 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;