url: Fixed crash when no username or password supplied for proxy
authorSteve Holme <steve_holme@hotmail.com>
Sun, 21 Apr 2013 15:55:19 +0000 (16:55 +0100)
committerSteve Holme <steve_holme@hotmail.com>
Sun, 21 Apr 2013 15:55:19 +0000 (16:55 +0100)
Fixed an issue in parse_proxy(), introduced in commit 11332577b3cb,
where an empty username or password (For example: http://:@example.com)
would cause a crash.

lib/url.c

index 863e5a8f06e4661bfb0af23af72f9f1a9dd83287..50b00e78333f0faa125099c861131f5ca2f1a5b3 100644 (file)
--- a/lib/url.c
+++ b/lib/url.c
@@ -4208,13 +4208,19 @@ static CURLcode parse_proxy(struct SessionHandle *data,
          username or password with reserved characters like ':' in
          them. */
       Curl_safefree(conn->proxyuser);
-      conn->proxyuser = curl_easy_unescape(data, proxyuser, 0, NULL);
+      if(proxyuser)
+        conn->proxyuser = curl_easy_unescape(data, proxyuser, 0, NULL);
+      else
+        conn->proxyuser = strdup("");
 
       if(!conn->proxyuser)
         res = CURLE_OUT_OF_MEMORY;
       else {
         Curl_safefree(conn->proxypasswd);
-        conn->proxypasswd = curl_easy_unescape(data, proxypasswd, 0, NULL);
+        if(proxypasswd)
+          conn->proxypasswd = curl_easy_unescape(data, proxypasswd, 0, NULL);
+        else
+          conn->proxypasswd = strdup("");
 
         if(!conn->proxypasswd)
           res = CURLE_OUT_OF_MEMORY;