From 8e96e9bc27f332cf41589d97687f5cafbfda06c5 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Mon, 27 Mar 2017 12:20:33 +0100 Subject: [PATCH] nsurl: Don't allow credentials or host for file: URLs. --- utils/nsurl/parse.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/utils/nsurl/parse.c b/utils/nsurl/parse.c index 453c56523..a56a78d2d 100644 --- a/utils/nsurl/parse.c +++ b/utils/nsurl/parse.c @@ -818,6 +818,11 @@ static nserror nsurl__create_from_section(const char * const url_s, url->username = NULL; url->password = NULL; + /* file: URLs don't have credentials */ + if (url->scheme_type == NSURL_SCHEME_FILE) { + break; + } + if (length != 0 && *norm_start != ':') { char *sec_start = norm_start; if (pegs->colon_first != pegs->authority && @@ -854,6 +859,11 @@ static nserror nsurl__create_from_section(const char * const url_s, url->host = NULL; url->port = NULL; + /* file: URLs don't have a host */ + if (url->scheme_type == NSURL_SCHEME_FILE) { + break; + } + if (length != 0) { size_t colon = 0; char *sec_start = norm_start;