[PATCH] scp fixes

Matthew Vernon matthew at debian.org
Fri Sep 28 06:46:06 EST 2001


Hi,

The following patch does two things (which you may choose to take
separatly if you don't like one or t'other). Firstly, I add a -1 and
-2 option, since a) it's convenient b) people keep asking for it c)
it's hardly a big fix, nor does it break backwards compatibility and
d) I don't accept any slippery slope arguments.

Secondly, I check for and ignore filenames with \n in the filename,
since these break the rcp/scp protocol.

Cheers,

Matthew
--- scp.c.orig	Thu Sep 27 21:32:32 2001
+++ scp.c	Thu Sep 27 21:41:06 2001
@@ -242,9 +242,11 @@
	addargs(&args, "-oClearAllForwardings yes");
 
	fflag = tflag = 0;
-	while ((ch = getopt(argc, argv, "dfprtvBCc:i:P:q46S:o:F:")) !=
-1)
+	while ((ch = getopt(argc, argv, "dfprtvBCc:i:P:q1246S:o:F:"))
!= -1)
		switch (ch) {
		/* User-visible flags. */
+                case '1':
+                case '2':
		case '4':
		case '6':
		case 'C':
@@ -505,6 +507,12 @@
			name[--len] = '\0';
		if ((fd = open(name, O_RDONLY, 0)) < 0)
			goto syserr;
+               /*Check for filename containing a newline*/
+               if ((last = strchr(name, '\n')) != NULL) {
+                       run_err("%s: filename contains a newline,
ignoring it",
+                               name);
+                       goto next; 
+               }
		if (fstat(fd, &stb) < 0) {
 syserr:			run_err("%s: %s", name,
strerror(errno));
			goto next;


-- 
"At least you know where you are with Microsoft."
"True. I just wish I'd brought a paddle."
http://www.debian.org



More information about the openssh-unix-dev mailing list