From cccb91291f77ce0c6be0ed4659b43c848938e022 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Thu, 1 Jul 2004 09:00:40 +0000 Subject: [PATCH] dns-fix-20040630 Fix the dns portion of cm_GetCell() to prevent against a NULL pointer dereference when the ttl expired. --- src/WINNT/afsd/cm_cell.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/WINNT/afsd/cm_cell.c b/src/WINNT/afsd/cm_cell.c index 8107329da..682be66d9 100644 --- a/src/WINNT/afsd/cm_cell.c +++ b/src/WINNT/afsd/cm_cell.c @@ -85,8 +85,8 @@ cm_cell_t *cm_GetCell_Gen(char *namep, char *newnamep, long flags) ) { int dns_expired = 0; if (!cp) { - cp = malloc(sizeof(*cp)); - memset(cp, 0, sizeof(*cp)); + cp = malloc(sizeof(cm_cell_t)); + memset(cp, 0, sizeof(cm_cell_t)); } else { dns_expired = 1; @@ -109,6 +109,7 @@ cm_cell_t *cm_GetCell_Gen(char *namep, char *newnamep, long flags) if (dns_expired) { cp->flags |= CM_CELLFLAG_VLSERVER_INVALID; cp = NULL; /* set cp to NULL to indicate error */ + goto done; } } else { /* got cell from DNS */ @@ -126,7 +127,7 @@ cm_cell_t *cm_GetCell_Gen(char *namep, char *newnamep, long flags) } /* randomise among those vlservers having the same rank*/ - cm_RandomizeServer(&cp->vlServersp); + cm_RandomizeServer(&cp->vlServersp); #ifdef AFS_AFSDB_ENV if (dns_expired) { -- 2.39.5