Browse Source

avcodec/rawdec: Check side data size before use

Fixes out of array read

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
tags/n3.3
Michael Niedermayer 8 years ago
parent
commit
5f0bc0215a
1 changed files with 8 additions and 1 deletions
  1. +8
    -1
      libavcodec/rawdec.c

+ 8
- 1
libavcodec/rawdec.c View File

@@ -364,9 +364,16 @@ static int raw_decode(AVCodecContext *avctx, void *data, int *got_frame,
} }


if (avctx->pix_fmt == AV_PIX_FMT_PAL8) { if (avctx->pix_fmt == AV_PIX_FMT_PAL8) {
int pal_size;
const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE,
NULL);
&pal_size);
int ret; int ret;

if (pal_size != AVPALETTE_SIZE) {
av_log(avctx, AV_LOG_ERROR, "Palette size %d is wrong\n", pal_size);
pal = NULL;
}

if (!context->palette) if (!context->palette)
context->palette = av_buffer_alloc(AVPALETTE_SIZE); context->palette = av_buffer_alloc(AVPALETTE_SIZE);
if (!context->palette) { if (!context->palette) {


Loading…
Cancel
Save