From 8c7846f4e1dd89db4ff3b03c558d97cd13cbb205 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Tue, 6 Nov 2012 06:39:39 -0500 Subject: [PATCH] Windows: call MIDL_user_allocate instead of calloc In the RPC service routines do not call calloc() directly. All memory will be deallocated by a call to MIDL_user_free() so use MIDL_user_allocate() to perform the allocation. Modify MIDL_user_allocate() to call calloc() instead of malloc() to ensure that the memory is initialized to NUL bytes. Change-Id: I4d458bb5d8888c63040f213550d04f481e98175b Reviewed-on: http://gerrit.openafs.org/8365 Tested-by: BuildBot Reviewed-by: Jeffrey Altman Tested-by: Jeffrey Altman --- src/WINNT/afsd/cm_rpc.c | 2 +- src/WINNT/afsd/rpc_srvsvc.c | 20 ++++++++++---------- src/WINNT/afsd/rpc_wkssvc.c | 6 +++--- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/WINNT/afsd/cm_rpc.c b/src/WINNT/afsd/cm_rpc.c index 683aa93eb0..76d857b3f6 100644 --- a/src/WINNT/afsd/cm_rpc.c +++ b/src/WINNT/afsd/cm_rpc.c @@ -165,7 +165,7 @@ long AFSRPC_GetToken( void __RPC_FAR * __RPC_USER midl_user_allocate (size_t cBytes) { - return ((void __RPC_FAR *) malloc(cBytes)); + return ((void __RPC_FAR *) calloc(cBytes, 1)); } void __RPC_USER midl_user_free(void __RPC_FAR * p) diff --git a/src/WINNT/afsd/rpc_srvsvc.c b/src/WINNT/afsd/rpc_srvsvc.c index 33f8210c71..6ad1646cdd 100644 --- a/src/WINNT/afsd/rpc_srvsvc.c +++ b/src/WINNT/afsd/rpc_srvsvc.c @@ -588,17 +588,17 @@ NET_API_STATUS NetrShareEnum( case 2: if (space_limited) space_available -= sizeof(InfoStruct->ShareInfo.Level2); - InfoStruct->ShareInfo.Level2->Buffer = calloc((enump->count - enump->next), sizeof(SHARE_INFO_2)); + InfoStruct->ShareInfo.Level2->Buffer = MIDL_user_allocate((enump->count - enump->next) * sizeof(SHARE_INFO_2)); break; case 1: if (space_limited) space_available -= sizeof(InfoStruct->ShareInfo.Level1); - InfoStruct->ShareInfo.Level1->Buffer = calloc((enump->count - enump->next), sizeof(SHARE_INFO_1)); + InfoStruct->ShareInfo.Level1->Buffer = MIDL_user_allocate((enump->count - enump->next) * sizeof(SHARE_INFO_1)); break; case 0: if (space_limited) space_available -= sizeof(InfoStruct->ShareInfo.Level0); - InfoStruct->ShareInfo.Level0->Buffer = calloc((enump->count - enump->next), sizeof(SHARE_INFO_0)); + InfoStruct->ShareInfo.Level0->Buffer = MIDL_user_allocate((enump->count - enump->next) * sizeof(SHARE_INFO_0)); break; } @@ -738,13 +738,13 @@ NET_API_STATUS NetrShareGetInfo( /* Allocate the memory for the response */ switch (Level) { case 2: - InfoStruct->ShareInfo2 = calloc(1, sizeof(SHARE_INFO_2)); + InfoStruct->ShareInfo2 = MIDL_user_allocate(sizeof(SHARE_INFO_2)); break; case 1: - InfoStruct->ShareInfo1 = calloc(1, sizeof(SHARE_INFO_1)); + InfoStruct->ShareInfo1 = MIDL_user_allocate(sizeof(SHARE_INFO_1)); break; case 0: - InfoStruct->ShareInfo0 = calloc(1, sizeof(SHARE_INFO_0)); + InfoStruct->ShareInfo0 = MIDL_user_allocate(sizeof(SHARE_INFO_0)); break; } @@ -952,16 +952,16 @@ NET_API_STATUS NetrServerGetInfo( */ switch (Level) { case 103: - InfoStruct->ServerInfo103 = calloc(1, sizeof(SERVER_INFO_103)); + InfoStruct->ServerInfo103 = MIDL_user_allocate(sizeof(SERVER_INFO_103)); break; case 102: - InfoStruct->ServerInfo102 = calloc(1, sizeof(SERVER_INFO_102)); + InfoStruct->ServerInfo102 = MIDL_user_allocate(sizeof(SERVER_INFO_102)); break; case 101: - InfoStruct->ServerInfo101 = calloc(1, sizeof(SERVER_INFO_101)); + InfoStruct->ServerInfo101 = MIDL_user_allocate(sizeof(SERVER_INFO_101)); break; case 100: - InfoStruct->ServerInfo100 = calloc(1, sizeof(SERVER_INFO_100)); + InfoStruct->ServerInfo100 = MIDL_user_allocate(sizeof(SERVER_INFO_100)); break; } diff --git a/src/WINNT/afsd/rpc_wkssvc.c b/src/WINNT/afsd/rpc_wkssvc.c index 805853e534..b97af5bf68 100644 --- a/src/WINNT/afsd/rpc_wkssvc.c +++ b/src/WINNT/afsd/rpc_wkssvc.c @@ -55,13 +55,13 @@ unsigned long NetrWkstaGetInfo( */ switch (Level) { case 102: - WkstaInfo->WkstaInfo102 = calloc(1, sizeof(WKSTA_INFO_102)); + WkstaInfo->WkstaInfo102 = MIDL_user_allocate(sizeof(WKSTA_INFO_102)); break; case 101: - WkstaInfo->WkstaInfo101 = calloc(1, sizeof(WKSTA_INFO_101)); + WkstaInfo->WkstaInfo101 = MIDL_user_allocate(sizeof(WKSTA_INFO_101)); break; case 100: - WkstaInfo->WkstaInfo100 = calloc(1, sizeof(WKSTA_INFO_100)); + WkstaInfo->WkstaInfo100 = MIDL_user_allocate(sizeof(WKSTA_INFO_100)); break; }