]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
STABLE14-fs-lsm-parse-bug-20090226
authorPeter Tripician <tripicia@cmf.nrl.navy.mil>
Tue, 17 Feb 2009 03:59:53 +0000 (03:59 +0000)
committerDerrick Brashear <shadow@dementia.org>
Tue, 17 Feb 2009 03:59:53 +0000 (03:59 +0000)
LICENSE IPL10
FIXES 124319

print correct error on root directory

(cherry picked from commit 52f3295d32e3a72916ea1f99119967b7279f642a)

src/venus/fs.c

index a333ba20d488e00bd5235ef0a3521ba82b757d3b..60066076696ca97d09e64e0ee8239b2aa13bee97 100644 (file)
@@ -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.