看板 DFBSD_bugs 關於我們 聯絡資訊
--IrhDeMKUP4DT/M7F Content-Type: multipart/mixed; boundary="SLDf9lqlvOQaIe6s" Content-Disposition: inline --SLDf9lqlvOQaIe6s Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable FYI, a patch suitable for DragonFly is included in attachment. ----- Forwarded message from Xin LI <delphij@FreeBSD.org> ----- Date: Thu, 16 Sep 2004 12:16:10 +0000 (UTC) From: Xin LI <delphij@FreeBSD.org> cvs-all@FreeBSD.org Subject: cvs commit: src/bin/rcp rcp.c X-Sieve: CMU Sieve 2.2 Delivered-To: delphij@freebsd.org Delivered-To: src-committers@freebsd.org 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=20 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. =20 PR: bin/54969 Approved by: murray (mentor) =20 Revision Changes Path 1.26.2.6 +11 -16 src/bin/rcp/rcp.c ----- End forwarded message ----- --=20 Xin LI <delphij frontfree net> http://www.delphij.net/ See complete headers for GPG key and other information. --SLDf9lqlvOQaIe6s Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="patch-rcp.c" Content-Transfer-Encoding: quoted-printable Index: rcp.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D 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 $ */ =20 @@ -581,7 +581,7 @@ size_t amt, count; int exists, first, mask, mode, ofd, omode; int setimes, targisdir, wrerrno =3D 0; - char ch, *cp, *np, *targ, *why, *vect[1], buf[BUFSIZ]; + char ch, *cp, *np, *targ, *why, *vect[1], buf[BUFSIZ], path[PATH_MAX]; =20 #define atime tv[0] #define mtime tv[1] @@ -678,21 +678,15 @@ if (*cp++ !=3D ' ') SCREWUP("size not delimited"); if (targisdir) { - static char *namebuf =3D NULL; - static size_t cursize; - size_t need; - - need =3D strlen(targ) + strlen(cp) + 250; - if (need > cursize) { - if (namebuf !=3D NULL) - free(namebuf); - if (!(namebuf =3D malloc(need))) - run_err("%s", strerror(errno)); - cursize =3D need; + if (strlen(targ) + (*targ ? 1 : 0) + strlen(cp) + >=3D 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 =3D namebuf; + np =3D path; } else np =3D targ; exists =3D stat(np, &stb) =3D=3D 0; --SLDf9lqlvOQaIe6s-- --IrhDeMKUP4DT/M7F Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.6 (FreeBSD) iD8DBQFBSYaZOfuToMruuMARAjxoAJ9W05kgkqNhEkZvq7/aA1v+aY7etwCeL8p4 G2TIO0rvPkSCyZJ499ZEie8= =p5V+ -----END PGP SIGNATURE----- --IrhDeMKUP4DT/M7F--