avcodec/rscc: Check side data size before use

Fixes out of array read

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Michael Niedermayer 2016-10-30 15:12:12 +01:00
parent 161ccdaa06
commit 0f64b6cd22

View File

@ -310,12 +310,15 @@ static int rscc_decode_frame(AVCodecContext *avctx, void *data,
frame->pict_type = AV_PICTURE_TYPE_P; frame->pict_type = AV_PICTURE_TYPE_P;
} }
if (avctx->pix_fmt == AV_PIX_FMT_PAL8) { if (avctx->pix_fmt == AV_PIX_FMT_PAL8) {
int size;
const uint8_t *pal = av_packet_get_side_data(avpkt, const uint8_t *pal = av_packet_get_side_data(avpkt,
AV_PKT_DATA_PALETTE, AV_PKT_DATA_PALETTE,
NULL); &size);
if (pal) { if (pal && size == AV_PKT_DATA_PALETTE) {
frame->palette_has_changed = 1; frame->palette_has_changed = 1;
memcpy(ctx->pal, pal, AVPALETTE_SIZE); memcpy(ctx->pal, pal, AVPALETTE_SIZE);
} else if (pal) {
av_log(avctx, AV_LOG_ERROR, "Palette size %d is wrong\n", size);
} }
memcpy (frame->data[1], ctx->pal, AVPALETTE_SIZE); memcpy (frame->data[1], ctx->pal, AVPALETTE_SIZE);
} }