summaryrefslogtreecommitdiff
path: root/scp.c
diff options
context:
space:
mode:
authordtucker <dtucker>2007-06-12 14:02:07 +0000
committerdtucker <dtucker>2007-06-12 14:02:07 +0000
commitc03ff01610d787a7f9590095d6553309869bf6bb (patch)
tree8ad0f7f552959588a0575a59e34618860d09bbd9 /scp.c
parent44cfa6390f764e38b1c0eba2c273693b42a1492d (diff)
downloadopenssh-c03ff01610d787a7f9590095d6553309869bf6bb.tar.gz
- dtucker@cvs.openbsd.org 2007/06/12 13:54:28
[scp.c] 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 'scp.c')
-rw-r--r--scp.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/scp.c b/scp.c
index 087e64a4..92a67b73 100644
--- a/scp.c
+++ b/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).
@@ -96,6 +96,9 @@
#include <string.h>
#include <time.h>
#include <unistd.h>
+#if defined(HAVE_STRNVIS) && defined(HAVE_VIS_H)
+#include <vis.h>
+#endif
#include "xmalloc.h"
#include "atomicio.h"
@@ -582,7 +585,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) {
@@ -591,13 +594,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;