Fix for rcp -r

Robert Ames robertames at hotmail.com
Mon Apr 21 17:09:36 PDT 2003


rcp -r is broken in 4.7 and 4.8.  A fix is included below.  The
web-based bug interface is currently disabled so I can't open a bug
report.  I believe the person that provided the patch to me also
indicated the problem exists in 5.0, but I'm unable to verify that
since I'm only running 4.x.  I think they monitor this list so I'll
let them speak up if they choose to.

>--- rcp.c~	Sun Feb 16 05:11:07 2003
>+++ rcp.c	Sun Feb 16 05:13:52 2003
>@@ -589,7 +591,7 @@
>  	off_t i, j, size;
>  	int amt, count, exists, first, mask, mode, ofd, omode;
>  	int setimes, targisdir, wrerrno = 0;
>-	char ch, *cp, *np, *targ, *why, *vect[1], buf[BUFSIZ];
>+	char ch, *cp, *np, *targ, *why, *vect[1], buf[BUFSIZ], path[PATH_MAX];
>
>  #define	atime	tv[0]
>  #define	mtime	tv[1]
>@@ -686,21 +688,15 @@
>  		if (*cp++ != ' ')
>  			SCREWUP("size not delimited");
>  		if (targisdir) {
>-			static char *namebuf = NULL;
>-			static size_t cursize;
>-			size_t need;
>-
>-			need = strlen(targ) + strlen(cp) + 250;
>-			if (need > cursize) {
>-				if (namebuf != NULL)
>-					free(namebuf);
>-				if (!(namebuf = malloc(need)))
>-					run_err("%s", strerror(errno));
>-				cursize = need;
>+			if (strlen(targ) + (*targ ? 1 : 0) + strlen(cp)
>+					>= sizeof(path)) {
>+				run_err("%s%s%s: name too long", targ,
>+					*targ ? "/" : "", cp);
>+				exit(1);
>  			}
>-			(void)snprintf(namebuf, need, "%s%s%s", targ,
>+			(void)snprintf(path, sizeof(path), "%s%s%s", targ,
>  			    *targ ? "/" : "", cp);
>-			np = namebuf;
>+			np = path;
>  		} else
>  			np = targ;
>  		exists = stat(np, &stb) == 0;
>


_________________________________________________________________
Add photos to your e-mail with MSN 8. Get 2 months FREE*.  
http://join.msn.com/?page=features/featuredemail



More information about the freebsd-stable mailing list