aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Fandrich <dan@coneharvesters.com>2008-07-31 22:46:29 +0000
committerDan Fandrich <dan@coneharvesters.com>2008-07-31 22:46:29 +0000
commitb4a5ce89c24a8015c1cb3226fd7a53a7af2048bc (patch)
treeedffcd4c32f67bb352f4b51a0e47a08ec64fb417
parent660516914e35631714c73a2002ccfa4d854a0290 (diff)
Fixed a problem with any FTP URL or any URLs containing an IPv6 address
being mangled when passed to proxies when CURLOPT_PORT is also set (reported by Pramod Sharma).
-rw-r--r--CHANGES4
-rw-r--r--RELEASE-NOTES3
-rw-r--r--lib/url.c20
3 files changed, 20 insertions, 7 deletions
diff --git a/CHANGES b/CHANGES
index 1970b56c1..608151445 100644
--- a/CHANGES
+++ b/CHANGES
@@ -11,6 +11,10 @@ Daniel Fandrich (31 Jul 2008)
as well as IPv4 addresses in IPv6 format. Also, better handle the case
of a malformatted IPv6 address (avoid empty and NULL strings).
+- Fixed a problem with any FTP URL or any URLs containing an IPv6 address
+ being mangled when passed to proxies when CURLOPT_PORT is also set
+ (reported by Pramod Sharma).
+
Daniel Stenberg (30 Jul 2008)
- Phil Blundell added the CURLOPT_SCOPE option, as well as adjusted the URL
parser to allow numerical IPv6-addresses to be specified with the scope
diff --git a/RELEASE-NOTES b/RELEASE-NOTES
index 40fb77ff8..76b545f3e 100644
--- a/RELEASE-NOTES
+++ b/RELEASE-NOTES
@@ -40,6 +40,7 @@ This release includes the following bugfixes:
o CURL_READFUNC_PAUSE problems fixed
o --use-ascii now works on Symbian OS, MS-DOS and OS/2
o CURLINFO_SSL_VERIFYRESULT is fixed
+ o FTP URLs and IPv6 URLs mangled when sent to proxy with CURLOPT_PORT set
This release includes the following known bugs:
@@ -60,7 +61,7 @@ advice from friends like these:
Rob Crittenden, Dengminwen, Christopher Palow, Hans-Jurgen May,
Phil Pellouchoud, Eduard Bloch, John Lightsey, Stephen Collyer, Tor Arntsen,
Rolland Dudemaine, Phil Blundell, Scott Barrett, Andreas Schuldei,
- Peter Lamberg, David Bau
+ Peter Lamberg, David Bau, Pramod Sharma
Thanks! (and sorry if I forgot to mention someone)
diff --git a/lib/url.c b/lib/url.c
index 2aec5656d..abad3ba97 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -3863,15 +3863,14 @@ static CURLcode create_conn(struct SessionHandle *data,
* The conn->host.name is currently [user:passwd@]host[:port] where host
* could be a hostname, IPv4 address or IPv6 address.
*************************************************************/
- if((1 == sscanf(conn->host.name, "[%*39[0123456789abcdefABCDEF:.]%c", &endbracket)) &&
+ if((1 == sscanf(conn->host.name, "[%*39[0123456789abcdefABCDEF:.%]%c", &endbracket)) &&
(']' == endbracket)) {
/* this is a RFC2732-style specified IP-address */
conn->bits.ipv6_ip = TRUE;
- conn->host.name++; /* pass the starting bracket */
+ conn->host.name++; /* skip over the starting bracket */
tmp = strchr(conn->host.name, ']');
- *tmp = 0; /* zero terminate */
- tmp++; /* pass the ending bracket */
+ *tmp++ = 0; /* zero terminate, killing the bracket */
if(':' != *tmp)
tmp = NULL; /* no port number available */
}
@@ -3887,9 +3886,18 @@ static CURLcode create_conn(struct SessionHandle *data,
if(conn->bits.httpproxy) {
/* we need to create new URL with the new port number */
char *url;
+ bool isftp = strequal("ftp", conn->protostr) ||
+ strequal("ftps", conn->protostr);
- url = aprintf("%s://%s:%d%s", conn->protostr, conn->host.name,
- conn->remote_port, data->state.path);
+ /*
+ * This synthesized URL isn't always right--suffixes like ;type=A
+ * are stripped off. It would be better to work directly from the
+ * original URL and simply replace the port part of it.
+ */
+ url = aprintf("%s://%s%s%s:%d%s%s", conn->protostr,
+ conn->bits.ipv6_ip?"[":"", conn->host.name,
+ conn->bits.ipv6_ip?"]":"", conn->remote_port,
+ isftp?"/":"", data->state.path);
if(!url)
return CURLE_OUT_OF_MEMORY;