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;
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;
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".
*/
}
/*
- * Trim a colon suffix off the hostname if it's there.
- */
- cfg.host[strcspn(cfg.host, ":")] = '\0';
-
- /*
* Remove any remaining whitespace from the hostname.
*/
{
/* 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
for (i = 0; i < names->nnames; i++)
ournames[nnames++] = names->names[i];
-
names->nnames = 0; /* prevent free_names */
fxp_free_names(names);
}
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) {
/*
if (!fxp_init()) {
tell_user(stderr, "unable to initialise SFTP: %s", fxp_error());
errs++;
- return;
+ return 1;
}
sftp_register(req = fxp_stat_send(target));
} else {
(void) response();
}
+ return 0;
}
int scp_send_errmsg(char *str)
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);
}
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. */
*targ++ = '\0';
if (*targ == '\0')
targ = ".";
- /* Substitute "." for emtpy target */
+ /* Substitute "." for empty target */
/* Separate host and username */
user = host;
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];
(" 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");
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(" -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
#endif
;
cmdline_tooltype = TOOLTYPE_FILETRANSFER;
- ssh_get_line = &console_get_line;
sk_init();
/* Load Default Settings before doing anything else. */
/* 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) {