From owner-freebsd-bugs@FreeBSD.ORG Mon Jul 28 02:00:22 2003 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A5F7337B401 for ; Mon, 28 Jul 2003 02:00:22 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9E08443FA3 for ; Mon, 28 Jul 2003 02:00:20 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.9/8.12.9) with ESMTP id h6S90KUp090633 for ; Mon, 28 Jul 2003 02:00:20 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.9/8.12.9/Submit) id h6S90KDZ090632; Mon, 28 Jul 2003 02:00:20 -0700 (PDT) Resent-Date: Mon, 28 Jul 2003 02:00:20 -0700 (PDT) Resent-Message-Id: <200307280900.h6S90KDZ090632@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Kyunghwan Kim Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id F06E537B401 for ; 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 ; 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 To: FreeBSD-gnats-submit@FreeBSD.org Subject: bin/54969: rcp '-r' option patch or MFC request X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Kyunghwan Kim List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Jul 2003 09:00:23 -0000 >Number: 54969 >Category: bin >Synopsis: rcp '-r' option patch or MFC request >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon Jul 28 02:00:20 PDT 2003 >Closed-Date: >Last-Modified: >Originator: Kyunghwan Kim >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: >Unformatted: