From redjade@atropos.snu.ac.kr  Mon Jul 28 01:51:09 2003
Return-Path: <redjade@atropos.snu.ac.kr>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id F06E537B401
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 28 Jul 2003 01:51:09 -0700 (PDT)
Received: from atropos.snu.ac.kr (atropos.snu.ac.kr [147.46.106.37])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 1F07343F75
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 28 Jul 2003 01:51:09 -0700 (PDT)
	(envelope-from redjade@atropos.snu.ac.kr)
Received: from atropos.snu.ac.kr (localhost [127.0.0.1])
	by atropos.snu.ac.kr (8.12.9/8.12.9) with ESMTP id h6S8oY2q019527;
	Mon, 28 Jul 2003 17:50:35 +0900 (KST)
Received: (from redjade@localhost)
	by atropos.snu.ac.kr (8.12.9/8.12.9/Submit) id h6S8oY7A019526;
	Mon, 28 Jul 2003 17:50:34 +0900 (KST)
Message-Id: <20030728085033.GA19506@atropos.snu.ac.kr>
Date: Mon, 28 Jul 2003 17:50:34 +0900
From: Kyunghwan Kim <redjade@atropos.snu.ac.kr>
Reply-To: Kyunghwan Kim <redjade@atropos.snu.ac.kr>
To: FreeBSD-gnats-submit@freebsd.org
Subject: rcp '-r' option patch or MFC request

>Number:         54969
>Category:       bin
>Synopsis:       rcp '-r' option patch or MFC request
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    delphij
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Jul 28 02:00:20 PDT 2003
>Closed-Date:    Thu Sep 16 12:18:02 GMT 2004
>Last-Modified:  Thu Sep 16 12:18:02 GMT 2004
>Originator:     Kyunghwan Kim <redjade@atropos.snu.ac.kr>
>Release:        FreeBSD 4.8-STABLE i386
>Organization:
>Environment:
System: FreeBSD XXXX 4.8-STABLE FreeBSD 4.8-STABLE #0: Fri Jul 25 21:09:08 KST 2003

>Description:
	From revision 1.26.2.3, rcp don't work well with '-r' option.
	rcp.c revision 1.37 is not MFCed yet.
>How-To-Repeat:
	Use rcp with '-r' option post FreeBSD 4.7 release.
>Fix:
patch against rcp.c revision 1.26.2.5
--- rcp.c.orig	Sat Jul 26 01:53:33 2003
+++ rcp.c	Sat Jul 26 01:59:34 2003
@@ -589,7 +589,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 +686,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;
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->delphij 
Responsible-Changed-By: delphij 
Responsible-Changed-When: Thu Sep 16 12:12:11 GMT 2004 
Responsible-Changed-Why:  
Take this 

http://www.freebsd.org/cgi/query-pr.cgi?pr=54969 
State-Changed-From-To: open->closed 
State-Changed-By: delphij 
State-Changed-When: Thu Sep 16 12:16:51 GMT 2004 
State-Changed-Why:  
MFC committed with a slightly different version, thanks for your 
submission! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=54969 
>Unformatted:
