[FFmpeg-cvslog] avcodec/mace: check buffer size
Michael Niedermayer
git at videolan.org
Thu Jan 2 22:17:28 CET 2014
ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Thu Jan 2 19:10:57 2014 +0100| [2e59ffbb7964214e192a9f77c4445ff29c6510d7] | committer: Michael Niedermayer
avcodec/mace: check buffer size
Fixes use of uninitialized memory
Fixes: msan_uninit-mem_7f9d2775e090_8782_surge-2-8-MAC3.mov
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2e59ffbb7964214e192a9f77c4445ff29c6510d7
---
libavcodec/mace.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/libavcodec/mace.c b/libavcodec/mace.c
index fbd932e..6eaa296 100644
--- a/libavcodec/mace.c
+++ b/libavcodec/mace.c
@@ -244,6 +244,13 @@ static int mace_decode_frame(AVCodecContext *avctx, void *data,
int i, j, k, l, ret;
int is_mace3 = (avctx->codec_id == AV_CODEC_ID_MACE3);
+ if (buf_size % (avctx->channels << is_mace3)) {
+ av_log(avctx, AV_LOG_ERROR, "buffer size %d is odd\n", buf_size);
+ buf_size -= buf_size % (avctx->channels << is_mace3);
+ if (!buf_size)
+ return AVERROR_INVALIDDATA;
+ }
+
/* get output buffer */
frame->nb_samples = 3 * (buf_size << (1 - is_mace3)) / avctx->channels;
if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
More information about the ffmpeg-cvslog
mailing list