You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-15 14:13:16 +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>
(cherry picked from commit ab6c9332bf
)
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
@@ -526,6 +526,11 @@ static void vqa_decode_chunk(VqaContext *s)
|
|||||||
chunk_size = AV_RB32(&s->buf[cbp0_chunk + 4]);
|
chunk_size = AV_RB32(&s->buf[cbp0_chunk + 4]);
|
||||||
cbp0_chunk += CHUNK_PREAMBLE_SIZE;
|
cbp0_chunk += CHUNK_PREAMBLE_SIZE;
|
||||||
|
|
||||||
|
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 */
|
/* accumulate partial codebook */
|
||||||
memcpy(&s->next_codebook_buffer[s->next_codebook_buffer_index],
|
memcpy(&s->next_codebook_buffer[s->next_codebook_buffer_index],
|
||||||
&s->buf[cbp0_chunk], chunk_size);
|
&s->buf[cbp0_chunk], chunk_size);
|
||||||
@@ -549,6 +554,11 @@ static void vqa_decode_chunk(VqaContext *s)
|
|||||||
chunk_size = AV_RB32(&s->buf[cbpz_chunk + 4]);
|
chunk_size = AV_RB32(&s->buf[cbpz_chunk + 4]);
|
||||||
cbpz_chunk += CHUNK_PREAMBLE_SIZE;
|
cbpz_chunk += CHUNK_PREAMBLE_SIZE;
|
||||||
|
|
||||||
|
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 */
|
/* accumulate partial codebook */
|
||||||
memcpy(&s->next_codebook_buffer[s->next_codebook_buffer_index],
|
memcpy(&s->next_codebook_buffer[s->next_codebook_buffer_index],
|
||||||
&s->buf[cbpz_chunk], chunk_size);
|
&s->buf[cbpz_chunk], chunk_size);
|
||||||
|
Reference in New Issue
Block a user