1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-21 10:55:51 +02:00

vqavideo: check chunk sizes before reading chunks

Fixes out of array writes

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2013-01-25 06:11:59 +01:00
parent e9d443cf08
commit ab6c9332bf

View File

@ -537,6 +537,11 @@ static int vqa_decode_chunk(VqaContext *s)
bytestream2_seek(&s->gb, cbp0_chunk, SEEK_SET);
chunk_size = bytestream2_get_be32(&s->gb);
if (chunk_size > MAX_CODEBOOK_SIZE - s->next_codebook_buffer_index) {
av_log(s->avctx, AV_LOG_ERROR, "cbp0 chunk too large (0x%X bytes)\n", chunk_size);
return AVERROR_INVALIDDATA;
}
/* accumulate partial codebook */
bytestream2_get_buffer(&s->gb, &s->next_codebook_buffer[s->next_codebook_buffer_index],
chunk_size);
@ -560,6 +565,11 @@ static int vqa_decode_chunk(VqaContext *s)
bytestream2_seek(&s->gb, cbpz_chunk, SEEK_SET);
chunk_size = bytestream2_get_be32(&s->gb);
if (chunk_size > MAX_CODEBOOK_SIZE - s->next_codebook_buffer_index) {
av_log(s->avctx, AV_LOG_ERROR, "cbpz chunk too large (0x%X bytes)\n", chunk_size);
return AVERROR_INVALIDDATA;
}
/* accumulate partial codebook */
bytestream2_get_buffer(&s->gb, &s->next_codebook_buffer[s->next_codebook_buffer_index],
chunk_size);