aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2017-11-27 13:39:42 -0300
committerJames Almer <jamrial@gmail.com>2017-12-01 01:25:45 -0300
commit8d51090dcb8be6acfa37fe43439218b278063f1c (patch)
tree8b317b47bb375225592040da2667fa5c33a1b8df
parent5ab992cd3875a5a34d4c30a9d08f2eec95a3fd80 (diff)
downloadffmpeg-8d51090dcb8be6acfa37fe43439218b278063f1c.tar.gz
avformat/matroskaenc: actually enforce the stream limit
Prevents out of array accesses. Adressess ticket #6873 Reviewed-by: Michael Niedermayer <michael@niedermayer.cc> Signed-off-by: James Almer <jamrial@gmail.com> (cherry picked from commit 9d464dc3fccb53f1e7c83e3453084c1a7fb90503)
-rw-r--r--libavformat/matroskaenc.c7
1 files changed, 7 insertions, 0 deletions
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 ||