summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2012-01-20 23:32:43 +0100
committerDaniel Stenberg <daniel@haxx.se>2012-01-20 23:32:43 +0100
commit7883cd5af38a824e41b42c94890ea94bf4356fd3 (patch)
tree055a72a9e9bc24550c0dd423eab97a5f70421beb /lib
parentd7af7de5b2d9aee7e41fc45d502c082918abd4bd (diff)
downloadcurl-7883cd5af38a824e41b42c94890ea94bf4356fd3.tar.gz
URL parse: user name with ipv6 numerical address
Using a URL with embedded user name and password didn't work if the host was given as a numerical IPv6 string, like ftp://user:password@[::1]/ Reported by: Brandon Wang Bug: http://curl.haxx.se/mail/archive-2012-01/0047.html
Diffstat (limited to 'lib')
-rw-r--r--lib/url.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/lib/url.c b/lib/url.c
index fd46a7e03..466748bfc 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -137,7 +137,9 @@ static long ConnectionKillOne(struct SessionHandle *data);
static void conn_free(struct connectdata *conn);
static void signalPipeClose(struct curl_llist *pipeline, bool pipe_broke);
static CURLcode do_init(struct connectdata *conn);
-
+static CURLcode parse_url_userpass(struct SessionHandle *data,
+ struct connectdata *conn,
+ char *user, char *passwd);
/*
* Protocol table.
*/
@@ -3666,7 +3668,9 @@ static CURLcode findprotocol(struct SessionHandle *data,
*/
static CURLcode parseurlandfillconn(struct SessionHandle *data,
struct connectdata *conn,
- bool *prot_missing)
+ bool *prot_missing,
+ char *user,
+ char *passwd)
{
char *at;
char *fragment;
@@ -3675,6 +3679,7 @@ static CURLcode parseurlandfillconn(struct SessionHandle *data,
int rc;
char protobuf[16];
const char *protop;
+ CURLcode result;
*prot_missing = FALSE;
@@ -3841,6 +3846,14 @@ static CURLcode parseurlandfillconn(struct SessionHandle *data,
path[0] = '/';
}
+ /*************************************************************
+ * Parse a user name and password in the URL and strip it out
+ * of the host name
+ *************************************************************/
+ result = parse_url_userpass(data, conn, user, passwd);
+ if(result != CURLE_OK)
+ return result;
+
if(conn->host.name[0] == '[') {
/* This looks like an IPv6 address literal. See if there is an address
scope. */
@@ -4783,7 +4796,7 @@ static CURLcode create_conn(struct SessionHandle *data,
conn->host.name = conn->host.rawalloc;
conn->host.name[0] = 0;
- result = parseurlandfillconn(data, conn, &prot_missing);
+ result = parseurlandfillconn(data, conn, &prot_missing, user, passwd);
if(result != CURLE_OK)
return result;
@@ -4813,15 +4826,6 @@ static CURLcode create_conn(struct SessionHandle *data,
}
/*************************************************************
- * Parse a user name and password in the URL and strip it out
- * of the host name
- *************************************************************/
- result = parse_url_userpass(data, conn, user, passwd);
- if(result != CURLE_OK)
- return result;
-
-
- /*************************************************************
* If the protocol can't handle url query strings, then cut
* of the unhandable part
*************************************************************/