[FFmpeg-cvslog] r10485 - in trunk/libavcodec: smacker.c truespeech.c ws-snd1.c

kostya subversion
Thu Sep 13 07:59:59 CEST 2007


Author: kostya
Date: Thu Sep 13 07:59:58 2007
New Revision: 10485

Log:
Add checks on input/output buffers size for some audio decoders

Modified:
   trunk/libavcodec/smacker.c
   trunk/libavcodec/truespeech.c
   trunk/libavcodec/ws-snd1.c

Modified: trunk/libavcodec/smacker.c
==============================================================================
--- trunk/libavcodec/smacker.c	(original)
+++ trunk/libavcodec/smacker.c	Thu Sep 13 07:59:58 2007
@@ -590,6 +590,10 @@ static int smka_decode_frame(AVCodecCont
     }
     stereo = get_bits1(&gb);
     bits = get_bits1(&gb);
+    if ((unp_size << !bits) > *data_size) {
+        av_log(avctx, AV_LOG_ERROR, "Frame is too large to fit in buffer\n");
+        return -1;
+    }
 
     memset(vlc, 0, sizeof(VLC) * 4);
     memset(h, 0, sizeof(HuffContext) * 4);

Modified: trunk/libavcodec/truespeech.c
==============================================================================
--- trunk/libavcodec/truespeech.c	(original)
+++ trunk/libavcodec/truespeech.c	Thu Sep 13 07:59:58 2007
@@ -333,15 +333,17 @@ static int truespeech_decode_frame(AVCod
 {
     TSContext *c = avctx->priv_data;
 
-    int i;
+    int i, j;
     short *samples = data;
     int consumed = 0;
     int16_t out_buf[240];
+    int iterations;
 
     if (!buf_size)
         return 0;
 
-    while (consumed < buf_size) {
+    iterations = FFMIN(buf_size / 32, *data_size / 480);
+    for(j = 0; j < iterations; j++) {
         truespeech_read_frame(c, buf + consumed);
         consumed += 32;
 
@@ -366,7 +368,7 @@ static int truespeech_decode_frame(AVCod
 
     *data_size = consumed * 15;
 
-    return buf_size;
+    return consumed;
 }
 
 AVCodec truespeech_decoder = {

Modified: trunk/libavcodec/ws-snd1.c
==============================================================================
--- trunk/libavcodec/ws-snd1.c	(original)
+++ trunk/libavcodec/ws-snd1.c	Thu Sep 13 07:59:58 2007
@@ -62,6 +62,14 @@ static int ws_snd_decode_frame(AVCodecCo
     in_size = AV_RL16(&buf[2]);
     buf += 4;
 
+    if (out_size > *data_size) {
+        av_log(avctx, AV_LOG_ERROR, "Frame is too large to fit in buffer\n");
+        return -1;
+    }
+    if (in_size > buf_size) {
+        av_log(avctx, AV_LOG_ERROR, "Frame data is larger than input buffer\n");
+        return -1;
+    }
     if (in_size == out_size) {
         for (i = 0; i < out_size; i++)
             *samples++ = (*buf++ - 0x80) << 8;




More information about the ffmpeg-cvslog mailing list