Commit 430d1219 authored by Anton Khirnov's avatar Anton Khirnov

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
parent c918e08b
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment