]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
Windows: call MIDL_user_allocate instead of calloc
authorJeffrey Altman <jaltman@your-file-system.com>
Tue, 6 Nov 2012 11:39:39 +0000 (06:39 -0500)
committerJeffrey Altman <jaltman@your-file-system.com>
Sat, 8 Dec 2012 16:18:26 +0000 (08:18 -0800)
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.

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>
(cherry picked from commit 8c7846f4e1dd89db4ff3b03c558d97cd13cbb205)

Change-Id: I5562dbac4977a5d23407cd62c3deb743e629c48c
Reviewed-on: http://gerrit.openafs.org/8645
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
src/WINNT/afsd/cm_rpc.c
src/WINNT/afsd/rpc_srvsvc.c
src/WINNT/afsd/rpc_wkssvc.c

index 639cc109dc3f1d5a4dde7671c07e12cfa5888c7f..ff9d33481531036821fd13f775089a7a665262b4 100644 (file)
@@ -162,7 +162,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)
index 860ed30ff55936275afe1968cac135a4edd7861d..f35c47155794d9d62313d24e44540a51676a0578 100644 (file)
@@ -583,17 +583,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;
     }
 
@@ -733,13 +733,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;
     }
 
@@ -947,16 +947,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;
     }
 
index a8845b861ae5d2f584d49611e0af0c44355d6d1e..b577cbb76dc7a949637981237e08c03f35d4cba2 100644 (file)
@@ -50,13 +50,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;
     }