X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/2e85c969d67eb14a07314802d4ac5dd63eef660b..bead8fe5a91e28295a93126d1ea9483c28c27e88:/pscp.c diff --git a/pscp.c b/pscp.c index ebe1f4fa..9df19637 100644 --- a/pscp.c +++ b/pscp.c @@ -213,8 +213,6 @@ int from_backend(void *frontend, int is_stderr, const char *data, int datalen) if (pendsize < pendlen + len) { pendsize = pendlen + len + 4096; pending = sresize(pending, pendsize, unsigned char); - if (!pending) - fatalbox("Out of memory"); } memcpy(pending + pendlen, p, len); pendlen += len; @@ -222,6 +220,15 @@ int from_backend(void *frontend, int is_stderr, const char *data, int datalen) return 0; } +int from_backend_untrusted(void *frontend_handle, const char *data, int len) +{ + /* + * No "untrusted" output should get here (the way the code is + * currently, it's all diverted by FLAG_STDERR). + */ + assert(!"Unexpected call to from_backend_untrusted()"); + return 0; /* not reached */ +} static int ssh_scp_recv(unsigned char *buf, int len) { outptr = buf; @@ -539,26 +546,23 @@ 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. */ - if (str[0] == '\0' || str[0] == ':' || str[1] == ':') + if (str[0] == '\0' || str[0] == ':' || + (str[0] != '[' && str[1] == ':')) return (NULL); - while (*str != '\0' && *str != ':' && *str != '/' && *str != '\\') + 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++; + } if (*str == ':') return (str); else @@ -751,7 +755,7 @@ static struct fxp_handle *scp_sftp_filehandle; static struct fxp_xfer *scp_sftp_xfer; static uint64 scp_sftp_fileoffset; -void scp_source_setup(char *target, int shouldbedir) +int scp_source_setup(char *target, int shouldbedir) { if (using_sftp) { /* @@ -766,7 +770,7 @@ void scp_source_setup(char *target, int shouldbedir) if (!fxp_init()) { tell_user(stderr, "unable to initialise SFTP: %s", fxp_error()); errs++; - return; + return 1; } sftp_register(req = fxp_stat_send(target)); @@ -789,6 +793,7 @@ void scp_source_setup(char *target, int shouldbedir) } else { (void) response(); } + return 0; } int scp_send_errmsg(char *str) @@ -1980,7 +1985,8 @@ static void toremote(int argc, char *argv[]) do_cmd(host, user, cmd); sfree(cmd); - scp_source_setup(targ, targetshouldbedirectory); + if (scp_source_setup(targ, targetshouldbedirectory)) + return; for (i = 0; i < argc - 1; i++) { src = argv[i]; @@ -2139,6 +2145,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"); @@ -2151,9 +2159,10 @@ static void usage(void) 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(" -noagent disable use of Pageant\n"); + printf(" -agent enable use of Pageant\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 @@ -2203,7 +2212,6 @@ int psftp_main(int argc, char *argv[]) #endif ; cmdline_tooltype = TOOLTYPE_FILETRANSFER; - ssh_get_line = &console_get_line; sk_init(); /* Load Default Settings before doing anything else. */ @@ -2223,6 +2231,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) {