[FFmpeg-devel] [PATCH] avformat/matroskaenc: actually enforce the stream limit

James Almer jamrial at gmail.com
Sun Nov 26 19:03:09 EET 2017


Prevents out of array accesses. Adressess ticket #6873

Signed-off-by: James Almer <jamrial at gmail.com>
---
 libavformat/matroskaenc.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index dad6d6c93f..06126781f8 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -1859,6 +1859,13 @@ static int mkv_write_header(AVFormatContext *s)
         av_dict_get(s->metadata, "alpha_mode", NULL, 0))
         version = 4;
 
+    if (s->nb_streams > MAX_TRACKS) {
+        av_log(s, AV_LOG_ERROR,
+               "At most %d streams are supported for muxing in Matroska\n",
+               MAX_TRACKS);
+        return AVERROR(EINVAL);
+    }
+
     for (i = 0; i < s->nb_streams; i++) {
         if (s->streams[i]->codecpar->codec_id == AV_CODEC_ID_ATRAC3 ||
             s->streams[i]->codecpar->codec_id == AV_CODEC_ID_COOK ||
-- 
2.15.0



More information about the ffmpeg-devel mailing list