diff options
author | Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com> | 2015-11-11 01:14:57 +0100 |
---|---|---|
committer | Vittorio Giovara <vittorio.giovara@gmail.com> | 2015-11-12 04:39:14 +0100 |
commit | e6459c655e110cd9acb5d0658d89c415eaca847b (patch) | |
tree | 86b79e69ae428a344635252bd31f83f3dba9587c | |
parent | b5f963bfec1f452c37eee900c7b11f065d10dd60 (diff) | |
download | ffmpeg-e6459c655e110cd9acb5d0658d89c415eaca847b.tar.gz |
dds: validate source buffer size before copying
If it is too small av_image_copy_plane segfaults.
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
-rw-r--r-- | libavcodec/dds.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/libavcodec/dds.c b/libavcodec/dds.c index 04b1dd2de8..0f045d6a07 100644 --- a/libavcodec/dds.c +++ b/libavcodec/dds.c @@ -668,6 +668,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); |