[FFmpeg-devel] [PATCH] libopenmpt: add missing avio_read return value check

Andreas Cadhalpun andreas.cadhalpun at googlemail.com
Sun Jan 1 21:27:50 EET 2017


This fixes heap-buffer-overflows in libopenmpt caused by interpreting
the negative size value as unsigned size_t.

Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun at googlemail.com>
---
 libavformat/libopenmpt.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/libavformat/libopenmpt.c b/libavformat/libopenmpt.c
index e7091ef9fc..35fd28f5f4 100644
--- a/libavformat/libopenmpt.c
+++ b/libavformat/libopenmpt.c
@@ -82,6 +82,11 @@ static int read_header_openmpt(AVFormatContext *s)
     if (!buf)
         return AVERROR(ENOMEM);
     size = avio_read(s->pb, buf, size);
+    if (size < 0) {
+        av_log(s, AV_LOG_ERROR, "Reading input buffer failed.\n");
+        av_freep(&buf);
+        return size;
+    }
 
     openmpt->module = openmpt_module_create_from_memory(buf, size, openmpt_logfunc, s, NULL);
     av_freep(&buf);
-- 
2.11.0


More information about the ffmpeg-devel mailing list