[delphij at FreeBSD.org: cvs commit: src/bin/rcp rcp.c]

Xin LI delphij at frontfree.net
Thu Sep 16 05:30:09 PDT 2004


FYI, a patch suitable for DragonFly is included in attachment.

----- Forwarded message from Xin LI <delphij at xxxxxxxxxxx> -----

Date: Thu, 16 Sep 2004 12:16:10 +0000 (UTC)
From: Xin LI <delphij at xxxxxxxxxxx>
	cvs-all at xxxxxxxxxxx
Subject: cvs commit: src/bin/rcp rcp.c
X-Sieve: CMU Sieve 2.2
Delivered-To: delphij at xxxxxxxxxxx
Delivered-To: src-committers at xxxxxxxxxxx
X-FreeBSD-CVS-Branch: RELENG_4
Precedence: bulk
X-Loop: FreeBSD.ORG
X-Virus-Scanned: by amavisd-new at frontfree.net

delphij     2004-09-16 12:16:10 UTC

  FreeBSD src repository

  Modified files:        (Branch: RELENG_4)
    bin/rcp              rcp.c 
  Log:
  MFC revision 1.37
  date: 2002/10/06 09:09:27;  author: charnier;  state: Exp;  lines: +11 -16
  While removing a memory leak, rev 1.32 introduced a
  free-memory-and-reuse-it-after. Correct both problems and
  make rcp -r work again under /etc/malloc.conf -> AJ.
  
  PR:             bin/54969
  Approved by:    murray (mentor)
  
  Revision  Changes    Path
  1.26.2.6  +11 -16    src/bin/rcp/rcp.c

----- End forwarded message -----

-- 
Xin LI <delphij frontfree net>	http://www.delphij.net/
See complete headers for GPG key and other information.

Index: rcp.c
===================================================================
RCS file: /home/dcvs/src/bin/rcp/rcp.c,v
retrieving revision 1.3
diff -u -r1.3 rcp.c
--- rcp.c	19 Mar 2004 17:17:46 -0000	1.3
+++ rcp.c	16 Sep 2004 12:25:21 -0000
@@ -39,7 +39,7 @@
  *
  * @(#) Copyright (c) 1983, 1990, 1992, 1993 The Regents of the University of California.  All rights reserved.
  * @(#)rcp.c	8.2 (Berkeley) 4/2/94
- * $FreeBSD: src/bin/rcp/rcp.c,v 1.26.2.5 2002/08/16 20:06:34 ume Exp $
+ * $FreeBSD: src/bin/rcp/rcp.c,v 1.26.2.6 2004/09/16 12:16:10 delphij Exp $
  * $DragonFly: src/bin/rcp/rcp.c,v 1.3 2004/03/19 17:17:46 cpressey Exp $
  */
 
@@ -581,7 +581,7 @@
 	size_t amt, count;
 	int 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]
@@ -678,21 +678,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;
Attachment:
pgp00012.pgp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pgp00012.pgp
Type: application/octet-stream
Size: 187 bytes
Desc: "Description: PGP signature"
URL: <http://lists.dragonflybsd.org/pipermail/bugs/attachments/20040916/3b46dc3f/attachment-0016.obj>


More information about the Bugs mailing list