[02/11] asvdec: Verify the amount of extradata

Message ID 1379599756-27062-2-git-send-email-martin@martin.st
State Committed
Commit f50803354c6acb4575379d7c54ca48ec5d36dd61
Headers show

Commit Message

Martin Storsjö Sept. 19, 2013, 2:09 p.m.
The init function reads one byte of extradata.

Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC: libav-stable@libav.org
---
 libavcodec/asvdec.c |    5 +++++
 1 file changed, 5 insertions(+)

Comments

Luca Barbato Sept. 19, 2013, 2:26 p.m. | #1
On 19/09/13 16:09, Martin Storsjö wrote:
> The init function reads one byte of extradata.
> 
Ok.

Patch

diff --git a/libavcodec/asvdec.c b/libavcodec/asvdec.c
index 9f74abb..9ba2755 100644
--- a/libavcodec/asvdec.c
+++ b/libavcodec/asvdec.c
@@ -274,6 +274,11 @@  static av_cold int decode_init(AVCodecContext *avctx)
     const int scale       = avctx->codec_id == AV_CODEC_ID_ASV1 ? 1 : 2;
     int i;
 
+    if (avctx->extradata_size < 1) {
+        av_log(avctx, AV_LOG_ERROR, "No extradata provided\n");
+        return AVERROR_INVALIDDATA;
+    }
+
     ff_asv_common_init(avctx);
     init_vlcs(a);
     ff_init_scantable(a->dsp.idct_permutation, &a->scantable, ff_asv_scantab);