diff options
author | Darren Tucker <dtucker@cvs.openbsd.org> | 2007-06-12 13:54:29 +0000 |
---|---|---|
committer | Darren Tucker <dtucker@cvs.openbsd.org> | 2007-06-12 13:54:29 +0000 |
commit | 2d9ab07ad3aa6f25f68d89c4c70890c3b37fc57e (patch) | |
tree | b3f22944948b894b03c444f71db40e910f535a23 /usr.bin | |
parent | d5d9022725bc506c5d3dcb1c442beaa3d7e4e9e8 (diff) |
Encode filename with strnvis if the name contains a newline (which can't
be represented in the scp protocol), from bz #891. ok markus@
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/ssh/scp.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/usr.bin/ssh/scp.c b/usr.bin/ssh/scp.c index d8238af2d88..619c43fe7de 100644 --- a/usr.bin/ssh/scp.c +++ b/usr.bin/ssh/scp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: scp.c,v 1.157 2007/06/12 08:24:20 djm Exp $ */ +/* $OpenBSD: scp.c,v 1.158 2007/06/12 13:54:28 dtucker Exp $ */ /* * scp - secure remote copy. This is basically patched BSD rcp which * uses ssh to do the data transfer (instead of using rcmd). @@ -90,6 +90,7 @@ #include <string.h> #include <time.h> #include <unistd.h> +#include <vis.h> #include "xmalloc.h" #include "atomicio.h" @@ -569,7 +570,7 @@ source(int argc, char **argv) off_t i, amt, statbytes; size_t result; int fd = -1, haderr, indx; - char *last, *name, buf[2048]; + char *last, *name, buf[2048], encname[MAXPATHLEN]; int len; for (indx = 0; indx < argc; ++indx) { @@ -578,13 +579,12 @@ source(int argc, char **argv) len = strlen(name); while (len > 1 && name[len-1] == '/') name[--len] = '\0'; - if (strchr(name, '\n') != NULL) { - run_err("%s: skipping, filename contains a newline", - name); - goto next; - } if ((fd = open(name, O_RDONLY|O_NONBLOCK, 0)) < 0) goto syserr; + if (strchr(name, '\n') != NULL) { + strnvis(encname, name, sizeof(encname), VIS_NL); + name = encname; + } if (fstat(fd, &stb) < 0) { syserr: run_err("%s: %s", name, strerror(errno)); goto next; |