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

James Almer git at videolan.org
Fri Dec 1 06:31:20 EET 2017


ffmpeg | branch: release/3.4 | James Almer <jamrial at gmail.com> | Mon Nov 27 13:39:42 2017 -0300| [8d51090dcb8be6acfa37fe43439218b278063f1c] | committer: James Almer

avformat/matroskaenc: actually enforce the stream limit

Prevents out of array accesses. Adressess ticket #6873

Reviewed-by: Michael Niedermayer <michael at niedermayer.cc>
Signed-off-by: James Almer <jamrial at gmail.com>
(cherry picked from commit 9d464dc3fccb53f1e7c83e3453084c1a7fb90503)

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

 libavformat/matroskaenc.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 6f094c458c..3c6bb6816a 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -1858,6 +1858,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 ||



More information about the ffmpeg-cvslog mailing list