From 50cf5a7fb78846fc39b3ecdaa896a10bcd74da2a Mon Sep 17 00:00:00 2001 From: Luca Barbato Date: Tue, 9 Jul 2013 04:44:26 +0200 Subject: [PATCH 1/2] atrac3: Error on impossible encoding/channel combinations Joint stereo encoded mono is impossible. Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind CC: libav-stable@libav.org --- libavcodec/atrac3.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libavcodec/atrac3.c b/libavcodec/atrac3.c index cd120e9f6a..6a8fae72d8 100644 --- a/libavcodec/atrac3.c +++ b/libavcodec/atrac3.c @@ -941,9 +941,11 @@ static av_cold int atrac3_decode_init(AVCodecContext *avctx) if (q->coding_mode == STEREO) av_log(avctx, AV_LOG_DEBUG, "Normal stereo detected.\n"); - else if (q->coding_mode == JOINT_STEREO) + else if (q->coding_mode == JOINT_STEREO) { + if (avctx->channels != 2) + return AVERROR_INVALIDDATA; av_log(avctx, AV_LOG_DEBUG, "Joint stereo detected.\n"); - else { + } else { av_log(avctx, AV_LOG_ERROR, "Unknown channel coding mode %x!\n", q->coding_mode); return AVERROR_INVALIDDATA; From bbf6a4aa20bfe3d7869b2218e66063602dfb8aa7 Mon Sep 17 00:00:00 2001 From: Luca Barbato Date: Tue, 9 Jul 2013 09:18:16 +0200 Subject: [PATCH 2/2] imc: Catch a division by zero Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind CC: libav-stable@libav.org --- libavcodec/imc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libavcodec/imc.c b/libavcodec/imc.c index 2749099d22..e3f5e15324 100644 --- a/libavcodec/imc.c +++ b/libavcodec/imc.c @@ -449,6 +449,10 @@ static int bit_allocation(IMCContext *q, IMCChannel *chctx, iacc += chctx->bandWidthT[i]; summa += chctx->bandWidthT[i] * chctx->flcoeffs4[i]; } + + if (!iacc) + return AVERROR_INVALIDDATA; + chctx->bandWidthT[BANDS - 1] = 0; summa = (summa * 0.5 - freebits) / iacc;