[FFmpeg-cvslog] vqavideo: check chunk sizes before reading chunks
Michael Niedermayer
git at videolan.org
Fri Jan 25 06:24:43 CET 2013
ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Fri Jan 25 06:11:59 2013 +0100| [ab6c9332bfa1e20127a16392a0b85a4aa4840889] | committer: Michael Niedermayer
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 at gmx.at>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ab6c9332bfa1e20127a16392a0b85a4aa4840889
---
libavcodec/vqavideo.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/libavcodec/vqavideo.c b/libavcodec/vqavideo.c
index 7075199..e89d4d1 100644
--- a/libavcodec/vqavideo.c
+++ b/libavcodec/vqavideo.c
@@ -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);
More information about the ffmpeg-cvslog
mailing list