diff options
author | Derek Buitenhuis <derek.buitenhuis@gmail.com> | 2017-04-20 16:17:44 +0100 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2017-08-23 13:15:17 +0200 |
commit | a82e65f0ae55651d0cdefb651c6fd7e7cef96adb (patch) | |
tree | f0fb6762524edc44e11b6dcbfa4a84f68357ea6b | |
parent | 6918b400c5a99928cabe8c0f782d5983a3806872 (diff) | |
download | ffmpeg-a82e65f0ae55651d0cdefb651c6fd7e7cef96adb.tar.gz |
avformat/webmdashenc: Validate the 'streams' adaptation sets parameter
It should not be a value larger than the number of streams we have,
or it will cause invalid reads and/or SIGSEGV.
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit ec07efa70012845e8642df67a4a773f510a17088)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r-- | libavformat/webmdashenc.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/libavformat/webmdashenc.c b/libavformat/webmdashenc.c index 16fb2db98d..91b2af354a 100644 --- a/libavformat/webmdashenc.c +++ b/libavformat/webmdashenc.c @@ -245,7 +245,11 @@ static int parse_adaptation_sets(AVFormatContext *s) as->streams = av_realloc(as->streams, sizeof(*as->streams) * ++as->nb_streams); if (as->streams == NULL) return -1; as->streams[as->nb_streams - 1] = to_integer(p, q - p + 1); - if (as->streams[as->nb_streams - 1] < 0) return -1; + if (as->streams[as->nb_streams - 1] < 0 || + as->streams[as->nb_streams - 1] >= s->nb_streams) { + av_log(s, AV_LOG_ERROR, "Invalid value for 'streams' in adapation_sets.\n"); + return AVERROR(EINVAL); + } if (*q == '\0') break; if (*q == ' ') state = new_set; p = ++q; |