[FFmpeg-cvslog] alac: Limit max_samples_per_frame

Martin Storsjö git at videolan.org
Tue Jun 3 02:49:38 CEST 2014


ffmpeg | branch: release/0.10 | Martin Storsjö <martin at martin.st> | Tue Sep  3 11:54:03 2013 +0300| [110680c5a2098505400f4fdff4c994020a377d19] | committer: Reinhard Tartler

alac: Limit max_samples_per_frame

Otherwise buffer size calculations in allocate_buffers could
overflow later, making the code think a large enough buffer
actually was allocated.

Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC: libav-stable at libav.org
Signed-off-by: Martin Storsjö <martin at martin.st>

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

 libavcodec/alac.c |    6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/libavcodec/alac.c b/libavcodec/alac.c
index da78908..23b8951 100644
--- a/libavcodec/alac.c
+++ b/libavcodec/alac.c
@@ -584,6 +584,12 @@ static int alac_set_info(ALACContext *alac)
 
     /* buffer size / 2 ? */
     alac->setinfo_max_samples_per_frame = bytestream_get_be32(&ptr);
+    if (!alac->setinfo_max_samples_per_frame ||
+        alac->setinfo_max_samples_per_frame > INT_MAX / sizeof(int32_t)) {
+        av_log(alac->avctx, AV_LOG_ERROR, "max samples per frame invalid: %u\n",
+               alac->setinfo_max_samples_per_frame);
+        return AVERROR_INVALIDDATA;
+    }
     ptr++;                          /* compatible version */
     alac->setinfo_sample_size           = *ptr++;
     alac->setinfo_rice_historymult      = *ptr++;



More information about the ffmpeg-cvslog mailing list