summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarren Tucker <dtucker@zip.com.au>2007-06-13 00:02:07 +1000
committerDarren Tucker <dtucker@zip.com.au>2007-06-13 00:02:07 +1000
commitbed63112f5a1f52b255f03bc2f457eaab5001e0c (patch)
treebadf36a481bef543e524663201148549a7bfe108
parent0409e15078f70a64c6ec4b4519dbf82fd9c0650e (diff)
- 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@
-rw-r--r--ChangeLog6
-rw-r--r--scp.c16
2 files changed, 14 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index a962cfae..9cbab13e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -43,6 +43,10 @@
- jmc@cvs.openbsd.org 2007/06/12 13:43:55
[ssh.1]
add -K to SYNOPSIS;
+ - 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@
20070611
- (djm) Bugzilla #1306: silence spurious error messages from hang-on-exit
@@ -3057,4 +3061,4 @@
OpenServer 6 and add osr5bigcrypt support so when someone migrates
passwords between UnixWare and OpenServer they will still work. OK dtucker@
-$Id: ChangeLog,v 1.4698 2007/06/12 14:00:58 dtucker Exp $
+$Id: ChangeLog,v 1.4699 2007/06/12 14:02:07 dtucker Exp $
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;