[PATCH]: Broken scp -p option

Corinna Vinschen vinschen at redhat.com
Mon Feb 19 20:36:41 EST 2001


Hi,

I have found an serious problem when using 'scp -rp'. The usage of
the static buffer "namebuf" together with calling `sink()' recursively
results in overwriting the buffer np points to. This in turn results
in a broken call to `ulimits()' and `chmod'.

This patch solves the problem:

Index: scp.c
===================================================================
RCS file: /cvs/openssh_cvs/scp.c,v
retrieving revision 1.56
diff -u -p -r1.56 scp.c
--- scp.c	2001/02/18 03:55:16	1.56
+++ scp.c	2001/02/19 09:31:27
@@ -802,16 +802,16 @@ sink(argc, argv)
 			}
 			vect[0] = xstrdup(np);
 			sink(1, vect);
-			if (vect[0])
-				xfree(vect[0]);
 			if (setimes) {
 				setimes = 0;
-				if (utimes(np, tv) < 0)
+				if (utimes(vect[0], tv) < 0)
 					run_err("%s: set times: %s",
-						np, strerror(errno));
+						vect[0], strerror(errno));
 			}
 			if (mod_flag)
-				(void) chmod(np, mode);
+				(void) chmod(vect[0], mode);
+			if (vect[0])
+				xfree(vect[0]);
 			continue;
 		}
 		omode = mode;

Corinna

-- 
Corinna Vinschen
Cygwin Developer
Red Hat, Inc.
mailto:vinschen at redhat.com





More information about the openssh-unix-dev mailing list