From 4007abe99cc86c56c0866dae646d3ff0691acc83 Mon Sep 17 00:00:00 2001 From: Peter Tripician Date: Tue, 17 Feb 2009 03:59:53 +0000 Subject: [PATCH] STABLE14-fs-lsm-parse-bug-20090226 LICENSE IPL10 FIXES 124319 print correct error on root directory (cherry picked from commit 52f3295d32e3a72916ea1f99119967b7279f642a) --- 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 a333ba20d..600660766 100644 --- a/src/venus/fs.c +++ b/src/venus/fs.c @@ -308,12 +308,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; } @@ -1622,7 +1625,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. @@ -3718,7 +3725,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