-
-
Notifications
You must be signed in to change notification settings - Fork 261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for IPv6 literal hostname in url #181
Conversation
Axel was previously unable to parse ipv6 address as hostname of url. This has been fixed, conforming to RFC 2732 Closes #169 Signed-off-by: Shankar <shankar_m@protonmail.com>
Axel failed to add port number to the absolute-url in the request-target message to the proxy if the port number is not the default value to that specific protocol. This has been fixed. Signed-off-by: Shankar <shankar_m@protonmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be improved.
if (strrchr(conn->host, '@') != NULL) { | ||
strncpy(conn->user, conn->host, sizeof(conn->user) - 1); | ||
if (strrchr(url, '@') != NULL) { | ||
strncpy(conn->user, url, sizeof(conn->user) - 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please replace strncpy
with strlcpy
.
if (strrchr(conn->host, '@') != NULL) { | ||
strncpy(conn->user, conn->host, sizeof(conn->user) - 1); | ||
if (strrchr(url, '@') != NULL) { | ||
strncpy(conn->user, url, sizeof(conn->user) - 1); | ||
i = strrchr(conn->user, '@'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be accomplished by reducing the size to be copied.
i = strrchr(conn->user, '@'); | ||
*i = 0; | ||
strncpy(conn->host, i + 1, sizeof(conn->host) - 1); | ||
strncpy(url, i + 1, sizeof(url) - 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto.
// Look for IPv6 literal hostname | ||
if (*url == '[') { | ||
strncpy(conn->host, url + 1, sizeof(conn->host) - 1); | ||
if ((i = strrchr(conn->host, ']')) != NULL) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
strrchr
+ strlcpy
instead of fixing up the result.
|
||
if (inet_pton(AF_INET6, hostname, buf)) | ||
return 1; | ||
return 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be
return hostname && 1 == inet_pton(AF_INET6, hostname, buf);
strcpy(string, scheme_from_proto(conn->proto)); | ||
|
||
if (*conn->user != 0 && strcmp(conn->user, "anonymous") != 0) | ||
sprintf(string + strlen(string), "%s:%s@", | ||
conn->user, conn->pass); | ||
|
||
sprintf(string + strlen(string), "%s:%i%s%s", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The URL formatting should be split to somewhere else so it can be shared between conn.c
and http.c
@shankar ping. |
Merged with minor edits. |
Commit bfd6e88:
Axel was previously unable to parse ipv6 address as hostname of url.
This has been fixed, conforming to RFC 2732
Closes #169
Commit 8de7c1a:
Axel did not add port number to the absolute url in the GET request to the proxy if it is not the default port. This has been fixed in this commit.
@ismaell please review my pull requests.