[FFmpeg-cvslog] dds: validate source buffer size before copying

Andreas Cadhalpun git at videolan.org
Thu Nov 26 01:42:17 CET 2015


ffmpeg | branch: release/2.8 | Andreas Cadhalpun <Andreas.Cadhalpun at googlemail.com> | Wed Nov 11 00:05:02 2015 +0100| [a8513826dda2a6ace68a3819eec1d9c6b1f3b98f] | committer: Andreas Cadhalpun

dds: validate source buffer size before copying

If it is too small av_image_copy_plane segfaults.

Reviewed-by: Vittorio Giovara <vittorio.giovara at gmail.com>
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun at googlemail.com>
(cherry picked from commit 1675809d2df76b1a185c78ca0a7a1c8ccb493167)
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun at googlemail.com>

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

 libavcodec/dds.c |    6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/libavcodec/dds.c b/libavcodec/dds.c
index a604d56..324e665 100644
--- a/libavcodec/dds.c
+++ b/libavcodec/dds.c
@@ -666,6 +666,12 @@ static int dds_decode(AVCodecContext *avctx, void *data,
             frame->palette_has_changed = 1;
         }
 
+        if (bytestream2_get_bytes_left(gbc) < frame->height * linesize) {
+            av_log(avctx, AV_LOG_ERROR, "Buffer is too small (%d < %d).\n",
+                   bytestream2_get_bytes_left(gbc), frame->height * linesize);
+            return AVERROR_INVALIDDATA;
+        }
+
         av_image_copy_plane(frame->data[0], frame->linesize[0],
                             gbc->buffer, linesize,
                             linesize, frame->height);



More information about the ffmpeg-cvslog mailing list