Commit 29b17528 authored by Andreas Cadhalpun's avatar Andreas Cadhalpun Committed by Vittorio Giovara

dds: validate compressed source buffer size

A too small buffer will cause segfaults somewhere below
decompress_texture_thread.
Signed-off-by: 's avatarAndreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
parent e6459c65
......@@ -642,9 +642,18 @@ static int dds_decode(AVCodecContext *avctx, void *data,
return ret;
if (ctx->compressed) {
int size = (avctx->coded_height / TEXTURE_BLOCK_H) *
(avctx->coded_width / TEXTURE_BLOCK_W) * ctx->tex_ratio;
ctx->slice_count = av_clip(avctx->thread_count, 1,
avctx->coded_height / TEXTURE_BLOCK_H);
if (bytestream2_get_bytes_left(gbc) < size) {
av_log(avctx, AV_LOG_ERROR,
"Compressed Buffer is too small (%d < %d).\n",
bytestream2_get_bytes_left(gbc), size);
return AVERROR_INVALIDDATA;
}
/* Use the decompress function on the texture, one block per thread. */
ctx->tex_data = gbc->buffer;
avctx->execute2(avctx, decompress_texture_thread, frame, NULL, ctx->slice_count);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment