From owner-freebsd-current Thu Jan 23 20:20:24 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.5/8.8.5) id UAA05981 for current-outgoing; Thu, 23 Jan 1997 20:20:24 -0800 (PST) Received: from rover.village.org (rover.village.org [204.144.255.49]) by freefall.freebsd.org (8.8.5/8.8.5) with SMTP id UAA05976 for ; Thu, 23 Jan 1997 20:20:20 -0800 (PST) Received: from rover.village.org [127.0.0.1] by rover.village.org with esmtp (Exim 0.56 #1) id E0vnd7Z-0000g7-00; Thu, 23 Jan 1997 21:20:09 -0700 Subject: Re: restore dies with: canonname: not enough bufferspace To: andreas@klemm.gtn.com (Andreas Klemm), current@freebsd.org In-reply-to: Your message of "Thu, 23 Jan 1997 23:36:27 +0100." <1899.854058987@critter.dk.tfs.com> References: <1899.854058987@critter.dk.tfs.com> Date: Thu, 23 Jan 1997 21:20:09 -0700 From: Warner Losh Message-Id: Sender: owner-current@freebsd.org X-Loop: FreeBSD.org Precedence: bulk In message <1899.854058987@critter.dk.tfs.com> Poul-Henning Kamp writes: : There is a patch in a PR for this one, please try it out. The PR number is 2536. The patch looks to be correct. I didn't catch the sizeof(char *) when I reviewed it. Pass the conical hat :-). A local copy here seems to have worked well for me. If no one objects, I'll commit this tomorrow afternoon. There is another, identical PR 2446, but that one lacks the patch :-). Warner P.S. Here's the patch, applied by hand here, that seems to have fixed it for me. This patch is from the above PR by Flemming Jacobsen with one minor stylistic nit corrected. Index: interactive.c =================================================================== RCS file: /home/imp/FreeBSD/CVS/src/sbin/restore/interactive.c,v retrieving revision 1.2 diff -u -r1.2 interactive.c --- interactive.c 1997/01/01 14:08:45 1.2 +++ interactive.c 1997/01/24 04:13:14 @@ -82,7 +82,7 @@ static char *copynext __P((char *, char *)); static int fcmp __P((const void *, const void *)); static void formatf __P((struct afile *, int)); -static void getcmd __P((char *, char *, char *, struct arglist *)); +static void getcmd __P((char *, char *, char *, int, struct arglist *)); struct dirent *glob_readdir __P((RST_DIR *dirp)); static int glob_stat __P((const char *, struct stat *)); static void mkentry __P((struct direct *, struct afile *)); @@ -121,7 +121,7 @@ volno = 0; } runshell = 1; - getcmd(curdir, cmd, name, &arglist); + getcmd(curdir, cmd, name, sizeof(name), &arglist); switch (cmd[0]) { /* * Add elements to the extraction list. @@ -300,9 +300,10 @@ * eliminate any embedded ".." components. */ static void -getcmd(curdir, cmd, name, ap) +getcmd(curdir, cmd, name, size, ap) char *curdir, *cmd, *name; struct arglist *ap; + int size; { register char *cp; static char input[BUFSIZ]; @@ -357,7 +358,7 @@ * If it is an absolute pathname, canonicalize it and return it. */ if (rawname[0] == '/') { - canon(rawname, name, sizeof(name)); + canon(rawname, name, size); } else { /* * For relative pathnames, prepend the current directory to @@ -366,7 +367,7 @@ (void) strcpy(output, curdir); (void) strcat(output, "/"); (void) strcat(output, rawname); - canon(output, name, sizeof(name)); + canon(output, name, size); } if (glob(name, GLOB_ALTDIRFUNC, NULL, &ap->glob) < 0) fprintf(stderr, "%s: out of memory\n", ap->cmd);