Commit 225e84e7 authored by Anton Khirnov's avatar Anton Khirnov

hls: disallow opening nested files in child demuxers

parent e192cd9c
...@@ -494,6 +494,16 @@ static int save_avio_options(AVFormatContext *s) ...@@ -494,6 +494,16 @@ static int save_avio_options(AVFormatContext *s)
return ret; return ret;
} }
static int nested_io_open(AVFormatContext *s, AVIOContext **pb, const char *url,
int flags, AVDictionary **opts)
{
av_log(s, AV_LOG_ERROR,
"A HLS playlist item '%s' referred to an external file '%s'. "
"Opening this file was forbidden for security reasons\n",
s->filename, url);
return AVERROR(EPERM);
}
static int hls_read_header(AVFormatContext *s) static int hls_read_header(AVFormatContext *s)
{ {
HLSContext *c = s->priv_data; HLSContext *c = s->priv_data;
...@@ -579,6 +589,7 @@ static int hls_read_header(AVFormatContext *s) ...@@ -579,6 +589,7 @@ static int hls_read_header(AVFormatContext *s)
goto fail; goto fail;
} }
v->ctx->pb = &v->pb; v->ctx->pb = &v->pb;
v->ctx->io_open = nested_io_open;
v->stream_offset = stream_offset; v->stream_offset = stream_offset;
ret = avformat_open_input(&v->ctx, v->segments[0]->url, in_fmt, NULL); ret = avformat_open_input(&v->ctx, v->segments[0]->url, in_fmt, NULL);
if (ret < 0) if (ret < 0)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment