[FFmpeg-devel] [PATCH] sonic: make sure num_taps is not larger than frame_size

Andreas Cadhalpun andreas.cadhalpun at googlemail.com
Tue Dec 15 23:50:21 CET 2015


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.

Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun at googlemail.com>
---
 libavcodec/sonic.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/libavcodec/sonic.c b/libavcodec/sonic.c
index 4ec7d89..8522de3 100644
--- a/libavcodec/sonic.c
+++ b/libavcodec/sonic.c
@@ -928,6 +928,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->frame_size) {
+        av_log(avctx, AV_LOG_ERROR,
+               "number of taps %d larger than frame size %d\n",
+               s->num_taps, 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);
 
-- 
2.6.2


More information about the ffmpeg-devel mailing list