windows-cell-name-length-consistency-two-20080806
authorJeffrey Altman <jaltman@secure-endpoints.com>
Wed, 6 Aug 2008 21:25:43 +0000 (21:25 +0000)
committerJeffrey Altman <jaltman@secure-endpoints.com>
Wed, 6 Aug 2008 21:25:43 +0000 (21:25 +0000)
LICENSE MIT

fix what I broke

src/WINNT/afsd/cm_cell.c
src/WINNT/afsd/cm_config.c

index c2c3b13..128e53a 100644 (file)
@@ -150,7 +150,8 @@ cm_cell_t *cm_GetCell_Gen(char *namep, char *newnamep, afs_uint32 flags)
     lock_ObtainRead(&cm_cellLock);
     for (cp = cm_data.cellNameHashTablep[hash]; cp; cp=cp->nameNextp) {
         if (cm_stricmp_utf8(namep, cp->name) == 0) {
-            strcpy(fullname, cp->name);
+            strncpy(fullname, cp->name, CELL_MAXNAMELEN);
+            fullname[CELL_MAXNAMELEN-1] = '\0';
             break;
         }
     }
index 6e357e5..55bdffd 100644 (file)
@@ -196,8 +196,8 @@ long cm_SearchCellFile(char *cellNamep, char *newCellNamep,
             if (stricmp(lineBuffer+1, cellNamep) == 0) {
                /* found the cell we're looking for */
                if (newCellNamep) {
-                   strncpy(newCellNamep, lineBuffer+1,CELL_MAXNAMELEN+1);
-                    newCellNamep[CELL_MAXNAMELEN] = '\0';
+                   strncpy(newCellNamep, lineBuffer+1,CELL_MAXNAMELEN);
+                    newCellNamep[CELL_MAXNAMELEN-1] = '\0';
                     strlwr(newCellNamep);
                 }
                 inRightCell = 1;
@@ -215,8 +215,8 @@ long cm_SearchCellFile(char *cellNamep, char *newCellNamep,
                    return -5;
                }
                if (newCellNamep) {
-                   strncpy(newCellNamep, lineBuffer+1,CELL_MAXNAMELEN+1);
-                    newCellNamep[CELL_MAXNAMELEN] = '\0';
+                   strncpy(newCellNamep, lineBuffer+1,CELL_MAXNAMELEN);
+                    newCellNamep[CELL_MAXNAMELEN-1] = '\0';
                     strlwr(newCellNamep);
                 }
                inRightCell = 0;
@@ -316,8 +316,8 @@ long cm_SearchCellByDNS(char *cellNamep, char *newCellNamep, int *ttl,
             if (procp)
                 (*procp)(rockp, &vlSockAddr, cellHostNames[i]);
             if (newCellNamep) {
-                strncpy(newCellNamep,cellNamep,CELL_MAXNAMELEN+1);
-                newCellNamep[CELL_MAXNAMELEN] = '\0';
+                strncpy(newCellNamep,cellNamep,CELL_MAXNAMELEN);
+                newCellNamep[CELL_MAXNAMELEN-1] = '\0';
                 strlwr(newCellNamep);
             }
         }