diff options
author | Michael Niedermayer <michael@niedermayer.cc> | 2016-01-30 02:17:50 +0100 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2016-02-02 03:39:34 +0100 |
commit | 1dba8371d93cf1c83bcd5c432d921905206a60f3 (patch) | |
tree | cf349434cd61e6fc77160e28bf076768fc1af019 /libavformat/utils.c | |
parent | 838abfc1d711b42beaf401153b36ef80922b85b8 (diff) | |
download | ffmpeg-1dba8371d93cf1c83bcd5c432d921905206a60f3.tar.gz |
avformat: add protocol_whitelist
Note to maintainers: update tools
Note to maintainers: set a default whitelist for your protocol
If that makes no sense then consider to set "none" and thus require the user to specify a white-list
for sub-protocols to be opened
Note, testing and checking for missing changes is needed
Reviewed-by: Andreas Cadhalpun <andreas.cadhalpun@googlemail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavformat/utils.c')
-rw-r--r-- | libavformat/utils.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c index 6bf2fd17a9..f8846b7115 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -139,11 +139,15 @@ void av_format_inject_global_side_data(AVFormatContext *s) int ff_copy_whitelists(AVFormatContext *dst, AVFormatContext *src) { - av_assert0(!dst->codec_whitelist && !dst->format_whitelist); + av_assert0(!dst->codec_whitelist && + !dst->format_whitelist && + !dst->protocol_whitelist); dst-> codec_whitelist = av_strdup(src->codec_whitelist); dst->format_whitelist = av_strdup(src->format_whitelist); + dst->protocol_whitelist = av_strdup(src->protocol_whitelist); if ( (src-> codec_whitelist && !dst-> codec_whitelist) - || (src->format_whitelist && !dst->format_whitelist)) { + || (src-> format_whitelist && !dst-> format_whitelist) + || (src->protocol_whitelist && !dst->protocol_whitelist)) { av_log(dst, AV_LOG_ERROR, "Failed to duplicate whitelist\n"); return AVERROR(ENOMEM); } @@ -352,9 +356,11 @@ static int init_input(AVFormatContext *s, const char *filename, (!s->iformat && (s->iformat = av_probe_input_format2(&pd, 0, &score)))) return score; - if ((ret = avio_open2(&s->pb, filename, AVIO_FLAG_READ | s->avio_flags, - &s->interrupt_callback, options)) < 0) + if ((ret = ffio_open_whitelist(&s->pb, filename, AVIO_FLAG_READ | s->avio_flags, + &s->interrupt_callback, options, + s->protocol_whitelist)) < 0) return ret; + if (s->iformat) return 0; return av_probe_input_buffer2(s->pb, &s->iformat, filename, @@ -441,6 +447,14 @@ int avformat_open_input(AVFormatContext **ps, const char *filename, goto fail; s->probe_score = ret; + if (!s->protocol_whitelist && s->pb && s->pb->protocol_whitelist) { + s->protocol_whitelist = av_strdup(s->pb->protocol_whitelist); + if (!s->protocol_whitelist) { + ret = AVERROR(ENOMEM); + goto fail; + } + } + if (s->format_whitelist && av_match_list(s->iformat->name, s->format_whitelist, ',') <= 0) { av_log(s, AV_LOG_ERROR, "Format not on whitelist \'%s\'\n", s->format_whitelist); ret = AVERROR(EINVAL); |