From ff8b8f3b72a7f8c5d1df3b22aced886b672c1a74 Mon Sep 17 00:00:00 2001 From: Peter Tripician Date: Tue, 17 Feb 2009 03:59:41 +0000 Subject: [PATCH] DEVEL15-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 0e04d457f..e2387fd95 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. @@ -4035,7 +4042,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