Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 21 Apr 2003 20:09:19 -0400
From:      "Robert Ames" <robertames@hotmail.com>
To:        freebsd-stable@freebsd.org
Subject:   Fix for rcp -r
Message-ID:  <BAY7-F483WfkxERL3kx0000ba75@hotmail.com>

next in thread | raw e-mail | index | archive | help

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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?BAY7-F483WfkxERL3kx0000ba75>