From 52f3295d32e3a72916ea1f99119967b7279f642a Mon Sep 17 00:00:00 2001 From: Peter Tripician Date: Tue, 17 Feb 2009 03:59:28 +0000 Subject: [PATCH] fs-lsm-parse-bug-20090226 LICENSE IPL10 FIXES 124319 print correct error on root directory --- src/venus/fs.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) 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. -- 2.39.5