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 <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>
This commit is contained in:
Jeffrey Altman 2012-11-06 06:39:39 -05:00
parent 40964dd39d
commit 8c7846f4e1
3 changed files with 14 additions and 14 deletions

View File

@ -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)

View File

@ -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;
}

View File

@ -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;
}