From eae1b8451a4d606dd457736ce7240ee12535fb36 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Mon, 27 May 2013 19:11:09 +0200 Subject: [PATCH 1/2] wavpack: check that there aren't too many blocks per packet --- libavcodec/wavpack.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libavcodec/wavpack.c b/libavcodec/wavpack.c index 9c766ca181..7a14519bf9 100644 --- a/libavcodec/wavpack.c +++ b/libavcodec/wavpack.c @@ -1120,6 +1120,11 @@ static int wavpack_decode_block(AVCodecContext *avctx, int block_no, } } + if (wc->ch_offset + s->stereo >= avctx->channels) { + av_log(avctx, AV_LOG_WARNING, "Too many channels coded in a packet.\n"); + return (avctx->err_recognition & AV_EF_EXPLODE) ? AVERROR_INVALIDDATA : 0; + } + samples_l = frame->extended_data[wc->ch_offset]; if (s->stereo) samples_r = frame->extended_data[wc->ch_offset + 1]; From 89806691b1c39181c63d95e0fddc30f11e2a7b04 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Mon, 27 May 2013 19:13:14 +0200 Subject: [PATCH 2/2] wavpack: check that all the channels were coded. --- libavcodec/wavpack.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libavcodec/wavpack.c b/libavcodec/wavpack.c index 7a14519bf9..0847238595 100644 --- a/libavcodec/wavpack.c +++ b/libavcodec/wavpack.c @@ -1212,6 +1212,11 @@ static int wavpack_decode_frame(AVCodecContext *avctx, void *data, buf_size -= frame_size; } + if (s->ch_offset != avctx->channels) { + av_log(avctx, AV_LOG_ERROR, "Not enough channels coded in a packet.\n"); + return AVERROR_INVALIDDATA; + } + *got_frame_ptr = 1; return avpkt->size;