X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=pscp.c;h=d0e045f9072edd31274c03a3b33a704577f252c8;hb=4e550f96b2edcf33f2480d2374815ec3df6a60f5;hp=0fa1839af5db8da5d35771278a10e847b79c82e9;hpb=6c81ee6706f75ccab7bc285d00139126524cce36;p=PuTTY.git diff --git a/pscp.c b/pscp.c index 0fa1839a..d0e045f9 100644 --- a/pscp.c +++ b/pscp.c @@ -321,6 +321,17 @@ static void do_cmd(char *host, char *user, char *cmd) if (host == NULL || host[0] == '\0') bump("Empty host name"); + /* + * Remove fiddly bits of address: remove a colon suffix, and + * the square brackets around an IPv6 literal address. + */ + if (host[0] == '[') { + host++; + host[strcspn(host, "]")] = '\0'; + } else { + host[strcspn(host, ":")] = '\0'; + } + /* * If we haven't loaded session details already (e.g., from -load), * try looking for a session called "host". @@ -381,11 +392,6 @@ static void do_cmd(char *host, char *user, char *cmd) } } - /* - * Trim a colon suffix off the hostname if it's there. - */ - cfg.host[strcspn(cfg.host, ":")] = '\0'; - /* * Remove any remaining whitespace from the hostname. */ @@ -533,6 +539,19 @@ static void print_stats(char *name, unsigned long size, unsigned long done, */ static char *colon(char *str) { + /* Check and process IPv6 literal addresses + * (eg: 'jeroen@[2001:db8::1]:myfile.txt') */ + char *ipv6 = strchr(str, '['); + if (ipv6) { + str = strchr(str, ']'); + if (str) { + /* Terminate on the closing bracket */ + *str++ = '\0'; + return (str); + } + return (NULL); + } + /* We ignore a leading colon, since the hostname cannot be empty. We also ignore a colon as second character because of filenames like f:myfile.txt. */ @@ -1928,7 +1947,7 @@ static void toremote(int argc, char *argv[]) *targ++ = '\0'; if (*targ == '\0') targ = "."; - /* Substitute "." for emtpy target */ + /* Substitute "." for empty target */ /* Separate host and username */ user = host; @@ -2129,6 +2148,7 @@ static void usage(void) printf(" -l user connect with specified username\n"); printf(" -pw passw login with specified password\n"); printf(" -1 -2 force use of particular SSH protocol version\n"); + printf(" -4 -6 force use of IPv4 or IPv6\n"); printf(" -C enable compression\n"); printf(" -i key private key file for authentication\n"); printf(" -batch disable all interactive prompts\n");