diff options
author | Martin Storsjö <martin@martin.st> | 2013-09-29 13:02:27 +0300 |
---|---|---|
committer | Martin Storsjö <martin@martin.st> | 2013-09-29 20:03:12 +0300 |
commit | d1d99e3befea5d411ac3aae72dbdecce94f8b547 (patch) | |
tree | cff11c4424c2399156b7e49acbba2a639919b092 /libavcodec/pcx.c | |
parent | 7ba0cedbfeff5671b264d1d7e90777057b5714c6 (diff) | |
download | ffmpeg-d1d99e3befea5d411ac3aae72dbdecce94f8b547.tar.gz |
pcx: Check the packet size before assuming it fits a palette
This fixes reads out of bounds.
Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC: libav-stable@libav.org
Signed-off-by: Martin Storsjö <martin@martin.st>
Diffstat (limited to 'libavcodec/pcx.c')
-rw-r--r-- | libavcodec/pcx.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/libavcodec/pcx.c b/libavcodec/pcx.c index fd8bb2a6cb..837f268efa 100644 --- a/libavcodec/pcx.c +++ b/libavcodec/pcx.c @@ -169,6 +169,12 @@ static int pcx_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, } else if (nplanes == 1 && bits_per_pixel == 8) { const uint8_t *palstart = bufstart + buf_size - 769; + if (buf_size < 769) { + av_log(avctx, AV_LOG_ERROR, "File is too short\n"); + ret = buf_size; + goto end; + } + for (y = 0; y < h; y++, ptr += stride) { buf = pcx_rle_decode(buf, buf_end, scanline, bytes_per_scanline, compressed); |