diff options
Diffstat (limited to 'scp.c')
-rw-r--r-- | scp.c | 16 |
1 files changed, 9 insertions, 7 deletions
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: scp.c,v 1.157 2007/06/12 08:24:20 djm Exp $ */ | 1 | /* $OpenBSD: scp.c,v 1.158 2007/06/12 13:54:28 dtucker Exp $ */ |
2 | /* | 2 | /* |
3 | * scp - secure remote copy. This is basically patched BSD rcp which | 3 | * scp - secure remote copy. This is basically patched BSD rcp which |
4 | * uses ssh to do the data transfer (instead of using rcmd). | 4 | * uses ssh to do the data transfer (instead of using rcmd). |
@@ -96,6 +96,9 @@ | |||
96 | #include <string.h> | 96 | #include <string.h> |
97 | #include <time.h> | 97 | #include <time.h> |
98 | #include <unistd.h> | 98 | #include <unistd.h> |
99 | #if defined(HAVE_STRNVIS) && defined(HAVE_VIS_H) | ||
100 | #include <vis.h> | ||
101 | #endif | ||
99 | 102 | ||
100 | #include "xmalloc.h" | 103 | #include "xmalloc.h" |
101 | #include "atomicio.h" | 104 | #include "atomicio.h" |
@@ -582,7 +585,7 @@ source(int argc, char **argv) | |||
582 | off_t i, amt, statbytes; | 585 | off_t i, amt, statbytes; |
583 | size_t result; | 586 | size_t result; |
584 | int fd = -1, haderr, indx; | 587 | int fd = -1, haderr, indx; |
585 | char *last, *name, buf[2048]; | 588 | char *last, *name, buf[2048], encname[MAXPATHLEN]; |
586 | int len; | 589 | int len; |
587 | 590 | ||
588 | for (indx = 0; indx < argc; ++indx) { | 591 | for (indx = 0; indx < argc; ++indx) { |
@@ -591,13 +594,12 @@ source(int argc, char **argv) | |||
591 | len = strlen(name); | 594 | len = strlen(name); |
592 | while (len > 1 && name[len-1] == '/') | 595 | while (len > 1 && name[len-1] == '/') |
593 | name[--len] = '\0'; | 596 | name[--len] = '\0'; |
594 | if (strchr(name, '\n') != NULL) { | ||
595 | run_err("%s: skipping, filename contains a newline", | ||
596 | name); | ||
597 | goto next; | ||
598 | } | ||
599 | if ((fd = open(name, O_RDONLY|O_NONBLOCK, 0)) < 0) | 597 | if ((fd = open(name, O_RDONLY|O_NONBLOCK, 0)) < 0) |
600 | goto syserr; | 598 | goto syserr; |
599 | if (strchr(name, '\n') != NULL) { | ||
600 | strnvis(encname, name, sizeof(encname), VIS_NL); | ||
601 | name = encname; | ||
602 | } | ||
601 | if (fstat(fd, &stb) < 0) { | 603 | if (fstat(fd, &stb) < 0) { |
602 | syserr: run_err("%s: %s", name, strerror(errno)); | 604 | syserr: run_err("%s: %s", name, strerror(errno)); |
603 | goto next; | 605 | goto next; |