aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Holme <steve_holme@hotmail.com>2013-04-21 12:08:35 +0100
committerSteve Holme <steve_holme@hotmail.com>2013-04-21 12:12:29 +0100
commit11332577b3cbd76f9fc418f3ae11133e4089fa1c (patch)
tree39e317fccda8fdcfd452c77983e88120382e165b
parent702b0dd408d5e847aad99d44dcd79366c61835eb (diff)
url: Updated proxy URL parsing to use parse_login_details()
-rw-r--r--lib/url.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/lib/url.c b/lib/url.c
index 7a489e60e..863e5a8f0 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -4196,16 +4196,13 @@ static CURLcode parse_proxy(struct SessionHandle *data,
/* Is there a username and password given in this proxy url? */
atsign = strchr(proxyptr, '@');
if(atsign) {
- char proxyuser[MAX_CURL_USER_LENGTH];
- char proxypasswd[MAX_CURL_PASSWORD_LENGTH];
- proxypasswd[0] = 0;
-
- if(1 <= sscanf(proxyptr,
- "%" MAX_CURL_USER_LENGTH_TXT"[^:@]:"
- "%" MAX_CURL_PASSWORD_LENGTH_TXT "[^@]",
- proxyuser, proxypasswd)) {
- CURLcode res = CURLE_OK;
+ CURLcode res = CURLE_OK;
+ char *proxyuser = NULL;
+ char *proxypasswd = NULL;
+ res = parse_login_details(proxyptr, atsign - proxyptr,
+ &proxyuser, &proxypasswd, NULL);
+ if(!res) {
/* found user and password, rip them out. note that we are
unescaping them, as there is otherwise no way to have a
username or password with reserved characters like ':' in
@@ -4223,7 +4220,7 @@ static CURLcode parse_proxy(struct SessionHandle *data,
res = CURLE_OUT_OF_MEMORY;
}
- if(CURLE_OK == res) {
+ if(!res) {
conn->bits.proxy_user_passwd = TRUE; /* enable it */
atsign++; /* the right side of the @-letter */
@@ -4232,10 +4229,13 @@ static CURLcode parse_proxy(struct SessionHandle *data,
else
res = CURLE_OUT_OF_MEMORY;
}
-
- if(res)
- return res;
}
+
+ Curl_safefree(proxyuser);
+ Curl_safefree(proxypasswd);
+
+ if(res)
+ return res;
}
/* start scanning for port number at this point */