Patrick Williams | b48b7b4 | 2016-08-17 15:04:38 -0500 | [diff] [blame^] | 1 | From 2cac35086c9e103fa98960c546d5017e7363803a Mon Sep 17 00:00:00 2001 |
| 2 | From: Michael Niedermayer <michaelni@gmx.at> |
| 3 | Date: Fri, 25 Jan 2013 06:11:59 +0100 |
| 4 | Subject: [PATCH] vqavideo: check chunk sizes before reading chunks |
| 5 | |
| 6 | Upstream-Status: Backport |
| 7 | |
| 8 | Commit 2cac35086c9e103fa98960c546d5017e7363803a release/0.7 |
| 9 | |
| 10 | Fixes out of array writes |
| 11 | |
| 12 | Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind |
| 13 | Signed-off-by: Michael Niedermayer <michaelni@gmx.at> |
| 14 | (cherry picked from commit ab6c9332bfa1e20127a16392a0b85a4aa4840889) |
| 15 | |
| 16 | Signed-off-by: Michael Niedermayer <michaelni@gmx.at> |
| 17 | --- |
| 18 | libavcodec/vqavideo.c | 10 ++++++++++ |
| 19 | 1 files changed, 10 insertions(+), 0 deletions(-) |
| 20 | |
| 21 | diff --git a/libavcodec/vqavideo.c b/libavcodec/vqavideo.c |
| 22 | index d1eab5b..6e1ce6c 100644 |
| 23 | --- a/gst-libs/ext/libav/libavcodec/vqavideo.c |
| 24 | +++ b/gst-libs/ext/libav/libavcodec/vqavideo.c |
| 25 | @@ -527,6 +527,11 @@ static void vqa_decode_chunk(VqaContext *s) |
| 26 | chunk_size = AV_RB32(&s->buf[cbp0_chunk + 4]); |
| 27 | cbp0_chunk += CHUNK_PREAMBLE_SIZE; |
| 28 | |
| 29 | + if (chunk_size > MAX_CODEBOOK_SIZE - s->next_codebook_buffer_index) { |
| 30 | + av_log(s->avctx, AV_LOG_ERROR, "cbp0 chunk too large (0x%X bytes)\n", chunk_size); |
| 31 | + return AVERROR_INVALIDDATA; |
| 32 | + } |
| 33 | + |
| 34 | /* accumulate partial codebook */ |
| 35 | memcpy(&s->next_codebook_buffer[s->next_codebook_buffer_index], |
| 36 | &s->buf[cbp0_chunk], chunk_size); |
| 37 | @@ -550,6 +555,11 @@ static void vqa_decode_chunk(VqaContext *s) |
| 38 | chunk_size = AV_RB32(&s->buf[cbpz_chunk + 4]); |
| 39 | cbpz_chunk += CHUNK_PREAMBLE_SIZE; |
| 40 | |
| 41 | + if (chunk_size > MAX_CODEBOOK_SIZE - s->next_codebook_buffer_index) { |
| 42 | + av_log(s->avctx, AV_LOG_ERROR, "cbpz chunk too large (0x%X bytes)\n", chunk_size); |
| 43 | + return AVERROR_INVALIDDATA; |
| 44 | + } |
| 45 | + |
| 46 | /* accumulate partial codebook */ |
| 47 | memcpy(&s->next_codebook_buffer[s->next_codebook_buffer_index], |
| 48 | &s->buf[cbpz_chunk], chunk_size); |
| 49 | -- |
| 50 | 1.7.5.4 |
| 51 | |