1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-12 00:33:53 -05:00

Use the new host_str* functions to improve IPv6 literal support.

I've gone through everywhere we handle host names / addresses (on
command lines, in PuTTY config, in port forwarding, in X display
names, in host key storage...) and tried to make them handle IPv6
literals sensibly, by using the host_str* functions I introduced in my
previous commit. Generally it's now OK to use a bracketed IPv6 literal
anywhere a hostname might have been valid; in a few cases where no
ambiguity exists (e.g. no :port suffix is permitted anyway)
unbracketed IPv6 literals are also acceptable.

[originally from svn r10120]
This commit is contained in:
Simon Tatham
2014-01-25 15:58:54 +00:00
parent 0348f57077
commit 8da4fa5063
14 changed files with 65 additions and 78 deletions

22
pscp.c
View File

@ -370,15 +370,9 @@ static void do_cmd(char *host, char *user, char *cmd)
bump("Empty host name");
/*
* Remove fiddly bits of address: remove a colon suffix, and
* the square brackets around an IPv6 literal address.
* Remove a colon suffix.
*/
if (host[0] == '[') {
host++;
host[strcspn(host, "]")] = '\0';
} else {
host[strcspn(host, ":")] = '\0';
}
host[host_strcspn(host, ":")] = '\0';
/*
* If we haven't loaded session details already (e.g., from -load),
@ -613,17 +607,7 @@ static char *colon(char *str)
if (str[0] == '\0' || str[0] == ':' ||
(str[0] != '[' && str[1] == ':'))
return (NULL);
while (*str != '\0' && *str != ':' && *str != '/' && *str != '\\') {
if (*str == '[') {
/* Skip over IPv6 literal addresses
* (eg: 'jeroen@[2001:db8::1]:myfile.txt') */
char *ipv6_end = strchr(str, ']');
if (ipv6_end) {
str = ipv6_end;
}
}
str++;
}
str += host_strcspn(str, ":/\\");
if (*str == ':')
return (str);
else