Browse Source

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>
tags/n2.1
Martin Storsjö 12 years ago
parent
commit
d1d99e3bef
1 changed files with 6 additions and 0 deletions
  1. +6
    -0
      libavcodec/pcx.c

+ 6
- 0
libavcodec/pcx.c View File

@@ -169,6 +169,12 @@ static int pcx_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
} else if (nplanes == 1 && bits_per_pixel == 8) { } else if (nplanes == 1 && bits_per_pixel == 8) {
const uint8_t *palstart = bufstart + buf_size - 769; 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) { for (y = 0; y < h; y++, ptr += stride) {
buf = pcx_rle_decode(buf, buf_end, buf = pcx_rle_decode(buf, buf_end,
scanline, bytes_per_scanline, compressed); scanline, bytes_per_scanline, compressed);


Loading…
Cancel
Save