vol: avoid double dir separators from addtoname
authorJeffrey Altman <jaltman@your-file-system.com>
Thu, 20 Jan 2011 06:35:08 +0000 (01:35 -0500)
committerDerrick Brashear <shadow@dementia.org>
Sat, 22 Jan 2011 20:42:36 +0000 (12:42 -0800)
The manner in which addtoname() is used can often result
in double dir separators in path names.  Check for it and
avoid doubling the separator in addtoname()

Change-Id: Ie33459bec3bcc93f81f13020cd35ed8c473b6ca5
Reviewed-on: http://gerrit.openafs.org/3699
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Rod Widdowson <rdw@steadingsoftware.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

src/vol/namei_ops.c

index 9d56271..9175aa0 100644 (file)
@@ -248,17 +248,18 @@ namei_HandleToInodeDir(namei_t * name, IHandle_t * ih)
      */
     volutil_PartitionName_r(ih->ih_dev, name->n_base, sizeof(name->n_base));
     offset = VICE_PREFIX_SIZE + (ih->ih_dev > 25 ? 2 : 1);
-    name->n_base[offset] = '/';
+    name->n_base[offset] = OS_DIRSEPC;
     offset++;
     strlcpy(name->n_base + offset, INODEDIR, sizeof(name->n_base) - offset);
     strlcpy(name->n_path, name->n_base, sizeof(name->n_path));
 }
 #endif
 
-#define addtoname(N, C)                                 \
-do {                                                    \
-    strlcat((N)->n_path, OS_DIRSEP, sizeof((N)->n_path));     \
-    strlcat((N)->n_path, (C), sizeof((N)->n_path));     \
+#define addtoname(N, C)                                         \
+do {                                                            \
+    if ((N)->n_path[strlen((N)->n_path)-1] != OS_DIRSEPC)       \
+        strlcat((N)->n_path, OS_DIRSEP, sizeof((N)->n_path));   \
+    strlcat((N)->n_path, (C), sizeof((N)->n_path));             \
 } while(0)