[FFmpeg-cvslog] avcodec/rscc: Check side data size before use

Michael Niedermayer git at videolan.org
Mon Oct 31 03:13:37 EET 2016


ffmpeg | branch: master | Michael Niedermayer <michael at niedermayer.cc> | Sun Oct 30 15:12:12 2016 +0100| [0f64b6cd22411f574cbc75cab3b6db7dba023ed6] | committer: Michael Niedermayer

avcodec/rscc: Check side data size before use

Fixes out of array read

Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0f64b6cd22411f574cbc75cab3b6db7dba023ed6
---

 libavcodec/rscc.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/libavcodec/rscc.c b/libavcodec/rscc.c
index 7f280a9..7eb8776 100644
--- a/libavcodec/rscc.c
+++ b/libavcodec/rscc.c
@@ -310,12 +310,15 @@ static int rscc_decode_frame(AVCodecContext *avctx, void *data,
         frame->pict_type = AV_PICTURE_TYPE_P;
     }
     if (avctx->pix_fmt == AV_PIX_FMT_PAL8) {
+        int size;
         const uint8_t *pal = av_packet_get_side_data(avpkt,
                                                      AV_PKT_DATA_PALETTE,
-                                                     NULL);
-        if (pal) {
+                                                     &size);
+        if (pal && size == AV_PKT_DATA_PALETTE) {
             frame->palette_has_changed = 1;
             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);
     }



More information about the ffmpeg-cvslog mailing list