]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
DEVEL15-windows-cell-name-trailing-dot-removal-20081008
authorJeffrey Altman <jaltman@secure-endpoints.com>
Wed, 8 Oct 2008 18:43:17 +0000 (18:43 +0000)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Wed, 8 Oct 2008 18:43:17 +0000 (18:43 +0000)
LICENSE MIT
FIXES 120318

Lookups of cell names that have a trailing dot should have the dot removed
otherwise there is a risk of duplicate cell entries since "foo" and "foo."
will not match but both will resolve to the same AFSDB record in DNS.

(cherry picked from commit e7b06ab695b83114954b58bd8cd25e5c0ad3f395)

src/WINNT/afsd/cm_cell.c

index 8d8264330ae8d2f487ce2cd5a441684fc1db9b17..7047606a24ae9c8635bb176610eb197dddabbe1e 100644 (file)
@@ -158,14 +158,30 @@ cm_cell_t *cm_GetCell_Gen(char *namep, char *newnamep, afs_uint32 flags)
     cm_cell_t *cp, *cp2;
     long code;
     char fullname[CELL_MAXNAMELEN]="";
+    char name[CELL_MAXNAMELEN]="";
     int  hasWriteLock = 0;
     int  hasMutex = 0;
     afs_uint32 hash;
     cm_cell_rock_t rock;
+    size_t len;
 
-    if (!strcmp(namep,SMB_IOCTL_FILENAME_NOSLASH))
+    if (namep == NULL || !namep[0] || !strcmp(namep,SMB_IOCTL_FILENAME_NOSLASH))
         return NULL;
 
+    /* 
+     * Strip off any trailing dots at the end of the cell name.
+     * Failure to do so results in an undesireable alias as the
+     * result of DNS AFSDB record lookups where a trailing dot
+     * has special meaning.
+     */
+    strncpy(name, namep, CELL_MAXNAMELEN);
+    for (len = strlen(namep); len > 0 && namep[len-1] == '.'; len--) {
+        name[len-1] = '\0';
+    }
+    if (len == 0)
+        return NULL;
+    namep = name;
+
     hash = CM_CELL_NAME_HASH(namep);
 
     lock_ObtainRead(&cm_cellLock);