From dfeef3a209ecb3dcf01a1ad14e7fc4586e630e93 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Wed, 20 Feb 2013 00:19:39 +0100 Subject: [PATCH] cook: check js_subband_start for validity Fixes out of array read Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Signed-off-by: Michael Niedermayer (cherry picked from commit c69315a5deb0f8095e6b4746b69171d6f3059b2f) Signed-off-by: Michael Niedermayer --- libavcodec/cook.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libavcodec/cook.c b/libavcodec/cook.c index a5da74efcc..14614c9316 100644 --- a/libavcodec/cook.c +++ b/libavcodec/cook.c @@ -1086,6 +1086,11 @@ static av_cold int cook_decode_init(AVCodecContext *avctx) if (extradata_size >= 8){ bytestream_get_be32(&edata_ptr); //Unknown unused q->subpacket[s].js_subband_start = bytestream_get_be16(&edata_ptr); + if (q->subpacket[s].js_subband_start >= 51) { + av_log(avctx, AV_LOG_ERROR, "js_subband_start %d is too large\n", q->subpacket[s].js_subband_start); + return AVERROR_INVALIDDATA; + } + q->subpacket[s].js_vlc_bits = bytestream_get_be16(&edata_ptr); extradata_size -= 8; }