From 56d5c768750a90dd09a70efb48e8f9a44564b83c Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Wed, 8 Oct 2008 18:43:17 +0000 Subject: [PATCH] DEVEL15-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. (cherry picked from commit e7b06ab695b83114954b58bd8cd25e5c0ad3f395) --- src/WINNT/afsd/cm_cell.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) 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); -- 2.39.5