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/aviobuf.c | |
parent | 838abfc1d711b42beaf401153b36ef80922b85b8 (diff) |
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/aviobuf.c')
-rw-r--r-- | libavformat/aviobuf.c | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index 9851981cee..213ee96f91 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -53,7 +53,11 @@ static const AVClass *ff_avio_child_class_next(const AVClass *prev) return prev ? NULL : &ffurl_context_class; } +#define OFFSET(x) offsetof(AVIOContext,x) +#define E AV_OPT_FLAG_ENCODING_PARAM +#define D AV_OPT_FLAG_DECODING_PARAM static const AVOption ff_avio_options[] = { + {"protocol_whitelist", "List of protocols that are allowed to be used", OFFSET(protocol_whitelist), AV_OPT_TYPE_STRING, { .str = NULL }, CHAR_MIN, CHAR_MAX, D }, { NULL }, }; @@ -800,6 +804,11 @@ int ffio_fdopen(AVIOContext **s, URLContext *h) av_free(buffer); return AVERROR(ENOMEM); } + (*s)->protocol_whitelist = av_strdup(h->protocol_whitelist); + if (!(*s)->protocol_whitelist && h->protocol_whitelist) { + avio_closep(s); + return AVERROR(ENOMEM); + } (*s)->direct = h->flags & AVIO_FLAG_DIRECT; (*s)->seekable = h->is_streamed ? 0 : AVIO_SEEKABLE_NORMAL; (*s)->max_packet_size = max_packet_size; @@ -919,13 +928,15 @@ int avio_open(AVIOContext **s, const char *filename, int flags) return avio_open2(s, filename, flags, NULL, NULL); } -int avio_open2(AVIOContext **s, const char *filename, int flags, - const AVIOInterruptCB *int_cb, AVDictionary **options) +int ffio_open_whitelist(AVIOContext **s, const char *filename, int flags, + const AVIOInterruptCB *int_cb, AVDictionary **options, + const char *whitelist + ) { URLContext *h; int err; - err = ffurl_open(&h, filename, flags, int_cb, options); + err = ffurl_open_whitelist(&h, filename, flags, int_cb, options, whitelist); if (err < 0) return err; err = ffio_fdopen(s, h); @@ -936,10 +947,16 @@ int avio_open2(AVIOContext **s, const char *filename, int flags, return 0; } +int avio_open2(AVIOContext **s, const char *filename, int flags, + const AVIOInterruptCB *int_cb, AVDictionary **options) +{ + return ffio_open_whitelist(s, filename, flags, int_cb, options, NULL); +} + int ffio_open2_wrapper(struct AVFormatContext *s, AVIOContext **pb, const char *url, int flags, const AVIOInterruptCB *int_cb, AVDictionary **options) { - return avio_open2(pb, url, flags, int_cb, options); + return ffio_open_whitelist(pb, url, flags, int_cb, options, s->protocol_whitelist); } int avio_close(AVIOContext *s) |