From: Jeffrey Altman Date: Wed, 8 Oct 2008 18:43:03 +0000 (+0000) Subject: windows-cell-name-trailing-dot-removal-20081008 X-Git-Tag: openafs-devel-1_5_61~771 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=e7b06ab695b83114954b58bd8cd25e5c0ad3f395;p=packages%2Fo%2Fopenafs.git windows-cell-name-trailing-dot-removal-20081008 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. --- diff --git a/src/WINNT/afsd/cm_cell.c b/src/WINNT/afsd/cm_cell.c index 8d8264330..7047606a2 100644 --- a/src/WINNT/afsd/cm_cell.c +++ b/src/WINNT/afsd/cm_cell.c @@ -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);