aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2016-10-30 15:12:12 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2017-08-23 13:15:16 +0200
commit63cd1b05ede13c9e83ca765dee16bc656135cd48 (patch)
tree40128c21d16dac77ce6f328798cfdc7d41c74711
parent3d46ce10b6e664d52e4d6894e09afbce0da04269 (diff)
downloadffmpeg-63cd1b05ede13c9e83ca765dee16bc656135cd48.tar.gz
avcodec/qpeg: Check side data size before use
Fixes out of array read Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit 16793504dfba44e738655807db3274301b9bc690) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavcodec/qpeg.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/libavcodec/qpeg.c b/libavcodec/qpeg.c
index 71f322b828..3d083ae76c 100644
--- a/libavcodec/qpeg.c
+++ b/libavcodec/qpeg.c
@@ -260,7 +260,8 @@ static int decode_frame(AVCodecContext *avctx,
AVFrame * const ref = a->ref;
uint8_t* outdata;
int delta, ret;
- const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL);
+ int pal_size;
+ const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, &pal_size);
if (avpkt->size < 0x86) {
av_log(avctx, AV_LOG_ERROR, "Packet is too small\n");
@@ -287,9 +288,11 @@ static int decode_frame(AVCodecContext *avctx,
}
/* make the palette available on the way out */
- if (pal) {
+ if (pal && pal_size == AVPALETTE_SIZE) {
p->palette_has_changed = 1;
memcpy(a->pal, pal, AVPALETTE_SIZE);
+ } else if (pal) {
+ av_log(avctx, AV_LOG_ERROR, "Palette size %d is wrong\n", pal_size);
}
memcpy(p->data[1], a->pal, AVPALETTE_SIZE);