From: Peter Tripician Date: Tue, 17 Feb 2009 03:59:28 +0000 (+0000) Subject: fs-lsm-parse-bug-20090226 X-Git-Tag: openafs-devel-1_5_61~526 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=52f3295d32e3a72916ea1f99119967b7279f642a;p=packages%2Fo%2Fopenafs.git fs-lsm-parse-bug-20090226 LICENSE IPL10 FIXES 124319 print correct error on root directory --- diff --git a/src/venus/fs.c b/src/venus/fs.c index 3590530ba..f59cc5748 100644 --- a/src/venus/fs.c +++ b/src/venus/fs.c @@ -307,12 +307,15 @@ static char * Parent(char *apath) { char *tp; - strcpy(tspace, apath); + strlcpy(tspace, apath, sizeof(tspace)); tp = strrchr(tspace, '/'); - if (tp) { - *tp = 0; - } else - strcpy(tspace, "."); + if (tp == (char *)tspace) + tp++; + else if (tp == (char *)NULL) { + tp = (char *)tspace; + *(tp++) = '.'; + } + *tp = '\0'; return tspace; } @@ -1685,7 +1688,11 @@ ListMountCmd(struct cmd_syndesc *as, void *arock) * Find rightmost slash, if any. */ last_component = (char *)strrchr(true_name, '/'); - if (last_component) { + if (last_component == (char *)true_name) { + strcpy(parent_dir, "/"); + last_component++; + } + else if (last_component != (char *)NULL) { /* * Found it. Designate everything before it as the parent directory, * everything after it as the final component. @@ -4038,7 +4045,11 @@ FlushMountCmd(struct cmd_syndesc *as, void *arock) * Find rightmost slash, if any. */ last_component = (char *)strrchr(true_name, '/'); - if (last_component) { + if (last_component == (char *)true_name) { + strcpy(parent_dir, "/"); + last_component++; + } + else if (last_component != (char *)NULL) { /* * Found it. Designate everything before it as the parent directory, * everything after it as the final component.