bin/54969: rcp '-r' option patch or MFC request
Kyunghwan Kim
redjade at atropos.snu.ac.kr
Mon Jul 28 02:00:23 PDT 2003
>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 <redjade at 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:
>Unformatted:
More information about the freebsd-bugs
mailing list