[FFmpeg-cvslog] adpcm: check buffer size in Funcom ISS decoder before reading header.

Justin Ruggles git at videolan.org
Sat Oct 1 03:06:40 CEST 2011


ffmpeg | branch: master | Justin Ruggles <justin.ruggles at gmail.com> | Sat Sep 10 14:24:00 2011 -0400| [9662539c103d54cacf9adbf1345013e011c08d4f] | committer: Justin Ruggles

adpcm: check buffer size in Funcom ISS decoder before reading header.

Also use the post-header data size to control termination of the main
decoding loop.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9662539c103d54cacf9adbf1345013e011c08d4f
---

 libavcodec/adpcm.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c
index e4e0627..75d3263 100644
--- a/libavcodec/adpcm.c
+++ b/libavcodec/adpcm.c
@@ -593,6 +593,12 @@ static int adpcm_decode_frame(AVCodecContext *avctx,
         }
         break;
     case CODEC_ID_ADPCM_IMA_ISS:
+        n = buf_size - 4 * avctx->channels;
+        if (n < 0) {
+            av_log(avctx, AV_LOG_ERROR, "packet is too small\n");
+            return AVERROR(EINVAL);
+        }
+
         for (channel = 0; channel < avctx->channels; channel++) {
             cs = &c->status[channel];
             cs->predictor  = (int16_t)bytestream_get_le16(&src);
@@ -600,7 +606,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx,
             src++;
         }
 
-        while (src < buf + buf_size) {
+        while (n-- > 0) {
             uint8_t v1, v2;
             uint8_t v = *src++;
             /* nibbles are swapped for mono */



More information about the ffmpeg-cvslog mailing list