aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>2015-12-15 23:43:03 +0100
committerAndreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>2015-12-20 15:39:20 +0100
commit46e7a63b6e011b47d87b54659b2a3799056e5753 (patch)
tree0a6689e4f7d782683f45b04da642c34f20fa2d7b
parent31d6900161221f6b83b76aa85221de49b7adbf32 (diff)
downloadffmpeg-46e7a63b6e011b47d87b54659b2a3799056e5753.tar.gz
sonic: make sure num_taps * channels is not larger than frame_size
If that is the case, the loop setting predictor_state in sonic_decode_frame causes out of bounds reads of int_samples, which has only frame_size number of elements. Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com> (cherry picked from commit 9637c2531f7eb040ad1c3cb46cb40a63dfc77b80) Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
-rw-r--r--libavcodec/sonic.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/libavcodec/sonic.c b/libavcodec/sonic.c
index c5076f9d8e..ab947c47b0 100644
--- a/libavcodec/sonic.c
+++ b/libavcodec/sonic.c
@@ -925,6 +925,13 @@ static av_cold int sonic_decode_init(AVCodecContext *avctx)
s->frame_size = s->channels*s->block_align*s->downsampling;
// avctx->frame_size = s->block_align;
+ if (s->num_taps * s->channels > s->frame_size) {
+ av_log(avctx, AV_LOG_ERROR,
+ "number of taps times channels (%d * %d) larger than frame size %d\n",
+ s->num_taps, s->channels, s->frame_size);
+ return AVERROR_INVALIDDATA;
+ }
+
av_log(avctx, AV_LOG_INFO, "Sonic: ver: %d.%d ls: %d dr: %d taps: %d block: %d frame: %d downsamp: %d\n",
s->version, s->minor_version, s->lossless, s->decorrelation, s->num_taps, s->block_align, s->frame_size, s->downsampling);