summaryrefslogtreecommitdiff
path: root/libavformat
diff options
context:
space:
mode:
authorBela Bodecs <bodecsb@vivanet.hu>2019-06-19 10:25:36 +0200
committerSteven Liu <lq@chinaffmpeg.org>2019-06-22 18:02:42 +0800
commit1beeb3b877d00385c80b1750b45fa4f5e2d96301 (patch)
tree3e8c27d72f7bada9f1aef58172c4cb8f81d2be99 /libavformat
parent01d8c72b95b96498543c84757a593140085aab71 (diff)
avformat/hlsenc: better checking var_stream_map content
When multiple variant streams are specified by var_stream_map option, implementation assumes that each elementary stream is assigned only once to any variant. But this is not checked. This patch makes this checking. Signed-off-by: Bela Bodecs <bodecsb@vivanet.hu> Reviewed-by: Steven Liu<lq@onvideo.cn>
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/hlsenc.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index b4cb0364b4..f6330ec2d5 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -1885,7 +1885,7 @@ static int parse_variant_stream_mapstring(AVFormatContext *s)
{
HLSContext *hls = s->priv_data;
VariantStream *vs;
- int stream_index;
+ int stream_index, i, j;
enum AVMediaType codec_type;
int nb_varstreams, nb_streams;
char *p, *q, *saveptr1, *saveptr2, *varstr, *keyval;
@@ -1987,6 +1987,23 @@ static int parse_variant_stream_mapstring(AVFormatContext *s)
atoi(val));
if (stream_index >= 0 && nb_streams < vs->nb_streams) {
+ for(i = 0; nb_streams > 0 && i < nb_streams; i++) {
+ if (vs->streams[i] == s->streams[stream_index]) {
+ av_log(s, AV_LOG_ERROR, "Same elementary stream found more than once inside "
+ "variant definition #%d\n", nb_varstreams - 1);
+ return AVERROR(EINVAL);
+ }
+ }
+ for(j = 0; nb_varstreams > 1 && j < nb_varstreams - 1; j++) {
+ for(i = 0; i < hls->var_streams[j].nb_streams; i++) {
+ if (hls->var_streams[j].streams[i] == s->streams[stream_index]) {
+ av_log(s, AV_LOG_ERROR, "Same elementary stream found more than once "
+ "in two different variant definitions #%d and #%d\n",
+ j, nb_varstreams - 1);
+ return AVERROR(EINVAL);
+ }
+ }
+ }
vs->streams[nb_streams++] = s->streams[stream_index];
} else {
av_log(s, AV_LOG_ERROR, "Unable to map stream at %s\n", keyval);