X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=pscp.c;h=9259dd084d1ac0f4d6176f15957709a1ff4f1e5b;hb=df913d00360aea784521662ad42c11e3933bb6f8;hp=1c601e979363cc356abc75526c2c0585ba13d9e1;hpb=89f4cf6a0a6bde2885287cd9cc8f95d639fe99a0;p=PuTTY.git diff --git a/pscp.c b/pscp.c index 1c601e97..9259dd08 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. */ @@ -687,7 +706,6 @@ void scp_sftp_listdir(char *dirname) for (i = 0; i < names->nnames; i++) ournames[nnames++] = names->names[i]; - names->nnames = 0; /* prevent free_names */ fxp_free_names(names); } @@ -1289,8 +1307,21 @@ int scp_get_sink_action(struct scp_sink_action *act) namesize += names->nnames + 128; ournames = sresize(ournames, namesize, struct fxp_name); } - for (i = 0; i < names->nnames; i++) - ournames[nnames++] = names->names[i]; + for (i = 0; i < names->nnames; i++) { + if (!strcmp(names->names[i].filename, ".") || + !strcmp(names->names[i].filename, "..")) { + /* + * . and .. are normal consequences of + * reading a directory, and aren't worth + * complaining about. + */ + } else if (!vet_filename(names->names[i].filename)) { + tell_user(stderr, "ignoring potentially dangerous server-" + "supplied filename '%s'\n", + names->names[i].filename); + } else + ournames[nnames++] = names->names[i]; + } names->nnames = 0; /* prevent free_names */ fxp_free_names(names); } @@ -1796,7 +1827,7 @@ static void sink(char *targ, char *src) tell_user(stderr, " when we requested a file " "called '%s'.", stripsrc); tell_user(stderr, " If this is a wildcard, " - "consider upgrading to SSH 2 or using"); + "consider upgrading to SSH-2 or using"); tell_user(stderr, " the '-unsafe' option. Renaming" " of this file has been disallowed."); /* Override the name the server provided with our own. */ @@ -1916,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; @@ -2108,6 +2139,8 @@ static void usage(void) (" pscp [options] source [source...] [user@]host:target\n"); printf(" pscp [options] -ls [user@]host:filespec\n"); printf("Options:\n"); + printf(" -V print version information and exit\n"); + printf(" -pgpfp print PGP key fingerprints and exit\n"); printf(" -p preserve file attributes\n"); printf(" -q quiet, don't show statistics\n"); printf(" -r copy directories recursively\n"); @@ -2117,11 +2150,11 @@ 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"); printf(" -unsafe allow server-side wildcards (DANGEROUS)\n"); - printf(" -V print version information\n"); printf(" -sftp force use of SFTP protocol\n"); printf(" -scp force use of SCP protocol\n"); #if 0 @@ -2191,6 +2224,9 @@ int psftp_main(int argc, char *argv[]) /* We have our own verbosity in addition to `flags'. */ if (flags & FLAG_VERBOSE) verbose = 1; + } else if (strcmp(argv[i], "-pgpfp") == 0) { + pgp_fingerprints(); + return 1; } else if (strcmp(argv[i], "-r") == 0) { recursive = 1; } else if (strcmp(argv[i], "-p") == 0) {