From: Jeffrey Altman Date: Wed, 28 Dec 2011 22:07:01 +0000 (-0500) Subject: Windows: replace strdup with xdr_alloc in callback processing X-Git-Tag: upstream/1.8.0_pre1^2~2888 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=19f1e0f7cf40c3da1d49c789358bd814f7e3b3eb;p=packages%2Fo%2Fopenafs.git Windows: replace strdup with xdr_alloc in callback processing The CRT allocator cannot be used for memory that will be freed by afsrpc.dll. Use xdr_alloc() instead. Change-Id: Idd33710c225d58b4e6eba0bfdb2f8b3282996258 Reviewed-on: http://gerrit.openafs.org/6439 Tested-by: BuildBot Tested-by: Jeffrey Altman Reviewed-by: Jeffrey Altman --- diff --git a/src/WINNT/afsd/cm_callback.c b/src/WINNT/afsd/cm_callback.c index c2408e436..d1aa1e06c 100644 --- a/src/WINNT/afsd/cm_callback.c +++ b/src/WINNT/afsd/cm_callback.c @@ -1157,15 +1157,21 @@ GetCellCommon(afs_int32 a_cellnum, char **a_name, serverList *a_hosts) afs_int32 sn; cm_cell_t * cellp; cm_serverRef_t * serverRefp; + size_t len; cellp = cm_FindCellByID(a_cellnum, CM_FLAG_NOPROBE); if (!cellp) { - *a_name = strdup(""); + *a_name = (char *)xdr_alloc(sizeof(char)); + if (*a_name) + *a_name = '\0'; return 0; } lock_ObtainRead(&cm_serverLock); - *a_name = strdup(cellp->name); + len = strlen(cellp->name)+1; + *a_name = (char *)xdr_alloc(len); + if (*a_name) + memcpy(*a_name, cellp->name, len); for ( sn = 0, serverRefp = cellp->vlServersp; sn < AFSMAXCELLHOSTS && serverRefp; @@ -1408,6 +1414,7 @@ int SRXAFSCB_GetLocalCell(struct rx_call *callp, char **a_name) struct rx_peer *peerp; unsigned long host = 0; unsigned short port = 0; + size_t len; if (cm_shutdown) return 1; @@ -1421,7 +1428,10 @@ int SRXAFSCB_GetLocalCell(struct rx_call *callp, char **a_name) ntohl(host), ntohs(port)); if (cm_data.rootCellp) { - t_name = strdup(cm_data.rootCellp->name); + len = strlen(cm_data.rootCellp->name) + 1; + t_name = (char *)xdr_alloc(len); + if (t_name) + memcpy(t_name, cm_data.rootCellp->name, len); } else { t_name = (char *)xdr_alloc(1); t_name[0] = '\0';