summaryrefslogtreecommitdiff
path: root/scp.c
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 /scp.c
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@
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 087e64a42..92a67b733 100644
--- a/scp.c
+++ b/scp.c
@@ -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) {
602syserr: run_err("%s: %s", name, strerror(errno)); 604syserr: run_err("%s: %s", name, strerror(errno));
603 goto next; 605 goto next;