[FFmpeg-cvslog] nellymoserdec: fail if output buffer is too small

Justin Ruggles git at videolan.org
Sat Oct 29 02:31:40 CEST 2011


ffmpeg | branch: master | Justin Ruggles <justin.ruggles at gmail.com> | Mon Oct 17 10:22:46 2011 -0400| [0aaa85dbedbd4029dac0e78f10a412c7ec9a0d4d] | committer: Justin Ruggles

nellymoserdec: fail if output buffer is too small

avoids silently truncating the output

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

 libavcodec/nellymoserdec.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/libavcodec/nellymoserdec.c b/libavcodec/nellymoserdec.c
index ec045af..3812d78 100644
--- a/libavcodec/nellymoserdec.c
+++ b/libavcodec/nellymoserdec.c
@@ -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);
     }



More information about the ffmpeg-cvslog mailing list