CURLOPT_PROXY: IPv6 address without port #415

Closed
MarcelRaad opened this Issue Sep 7, 2015 · 2 comments

Projects

None yet

2 participants

@MarcelRaad
Member

The following code doesn't work:

curl_easy_setopt(easy_handle, CURLOPT_PROXY, "2a00:fac0:a000::7:13");
curl_easy_setopt(easy_handle, CURLOPT_PROXYPORT, 8080L);

url.c:parse_proxy sets the proxy name to "2a00" and overrides the port with 0, as it tries to parse "fac0:a000::7:13" as a port number. Is this a bug or expected behavior?

Unfortunately the documentation at http://curl.haxx.se/libcurl/c/CURLOPT_PROXY.html doesn't mention if IPv6 addresses have to be in square brackets even if they don't contain a port number or a scheme. If so, probably the documentation should reflect that and parse_proxy should return an error if the port string is invalid.

@bagder bagder self-assigned this Sep 8, 2015
@bagder
Member
bagder commented Sep 8, 2015

Thanks! I completely agree. I have a fix that makes the parser stricter and adds the bracket requirement to the man page, will push in a second.

@bagder bagder added a commit that closed this issue Sep 8, 2015
@bagder bagder parse_proxy: reject illegal port numbers
If the port number in the proxy string ended weirdly or the number is
too large, skip it. Mostly as a means to bail out early if a "bare" IPv6
numerical address is used without enclosing brackets.

Also mention the bracket requirement for IPv6 numerical addresses to the
man page for CURLOPT_PROXY.

Closes #415

Reported-by: Marcel Raad
87e533a
@bagder bagder closed this in 87e533a Sep 8, 2015
@MarcelRaad
Member

Great, thank you!

@jgsogo jgsogo added a commit to jgsogo/curl that referenced this issue Oct 19, 2015
@bagder @jgsogo bagder + jgsogo parse_proxy: reject illegal port numbers
If the port number in the proxy string ended weirdly or the number is
too large, skip it. Mostly as a means to bail out early if a "bare" IPv6
numerical address is used without enclosing brackets.

Also mention the bracket requirement for IPv6 numerical addresses to the
man page for CURLOPT_PROXY.

Closes #415

Reported-by: Marcel Raad
daccb6d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment