diff options
author | Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com> | 2015-11-11 00:05:02 +0100 |
---|---|---|
committer | Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com> | 2015-11-11 21:49:51 +0100 |
commit | 1675809d2df76b1a185c78ca0a7a1c8ccb493167 (patch) | |
tree | 456c7ec9e5b654d83d754bc69e0357da7cf61b80 | |
parent | 0e36a14a423b7cb32d54d1b621cc9136cccc3dc5 (diff) | |
download | ffmpeg-1675809d2df76b1a185c78ca0a7a1c8ccb493167.tar.gz |
dds: validate source buffer size before copying
If it is too small av_image_copy_plane segfaults.
Reviewed-by: Vittorio Giovara <vittorio.giovara@gmail.com>
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 a604d5690f..324e6657a6 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); |