nellymoserdec: fail if output buffer is too small
authorJustin Ruggles <justin.ruggles@gmail.com>
Mon, 17 Oct 2011 14:22:46 +0000 (10:22 -0400)
committerJustin Ruggles <justin.ruggles@gmail.com>
Fri, 28 Oct 2011 18:40:52 +0000 (14:40 -0400)
avoids silently truncating the output

libavcodec/nellymoserdec.c

index ec045af..3812d78 100644 (file)
@@ -176,8 +176,12 @@ static int decode_tag(AVCodecContext * avctx,
         return buf_size;
     }
     block_size = NELLY_SAMPLES * av_get_bytes_per_sample(avctx->sample_fmt);
-    blocks     = FFMIN(buf_size / NELLY_BLOCK_LEN, *data_size / block_size);
+    blocks     = buf_size / NELLY_BLOCK_LEN;
     if (blocks <= 0) {
+        av_log(avctx, AV_LOG_ERROR, "Packet is too small\n");
+        return AVERROR_INVALIDDATA;
+    }
+    if (*data_size < blocks * block_size) {
         av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n");
         return AVERROR(EINVAL);
     }