mirror of
https://github.com/librempeg/librempeg
synced 2024-11-23 19:58:59 +00:00
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
This commit is contained in:
parent
c918e08b9c
commit
430d121964
@ -109,7 +109,7 @@ static int pcx_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
|
|||||||
nplanes = buf[65];
|
nplanes = buf[65];
|
||||||
bytes_per_scanline = nplanes * bytes_per_line;
|
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)) {
|
(!compressed && bytes_per_scanline > buf_size / h)) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "PCX data is corrupted\n");
|
av_log(avctx, AV_LOG_ERROR, "PCX data is corrupted\n");
|
||||||
return AVERROR_INVALIDDATA;
|
return AVERROR_INVALIDDATA;
|
||||||
|
Loading…
Reference in New Issue
Block a user