[NETAPI32]
authorEric Kohl <eric.kohl@reactos.org>
Sat, 14 Sep 2013 21:35:01 +0000 (21:35 +0000)
committerEric Kohl <eric.kohl@reactos.org>
Sat, 14 Sep 2013 21:35:01 +0000 (21:35 +0000)
NetLocalGroupGetMembers: Fix heap corruption by calculationg the proper buffer size.

svn path=/trunk/; revision=60119

reactos/dll/win32/netapi32/local_group.c

index 9f49f50..0f301af 100644 (file)
@@ -1515,27 +1515,27 @@ NetLocalGroupGetMembers(
         switch (level)
         {
             case 0:
-                Size = sizeof(LOCALGROUP_MEMBERS_INFO_0) +
-                       RtlLengthSid(EnumContext->Sids[i]);
+                Size += sizeof(LOCALGROUP_MEMBERS_INFO_0) +
+                        RtlLengthSid(EnumContext->Sids[i]);
                 break;
 
             case 1:
-                Size = sizeof(LOCALGROUP_MEMBERS_INFO_1) +
-                       RtlLengthSid(EnumContext->Sids[i]) +
-                       EnumContext->Names[i].Name.Length + sizeof(WCHAR);
+                Size += sizeof(LOCALGROUP_MEMBERS_INFO_1) +
+                        RtlLengthSid(EnumContext->Sids[i]) +
+                        EnumContext->Names[i].Name.Length + sizeof(WCHAR);
                 break;
 
             case 2:
-                Size = sizeof(LOCALGROUP_MEMBERS_INFO_2) +
-                       RtlLengthSid(EnumContext->Sids[i]) +
-                       EnumContext->Names[i].Name.Length + sizeof(WCHAR) +
-                       EnumContext->Domains->Domains[EnumContext->Names[i].DomainIndex].Name.Length + sizeof(WCHAR);
+                Size += sizeof(LOCALGROUP_MEMBERS_INFO_2) +
+                        RtlLengthSid(EnumContext->Sids[i]) +
+                        EnumContext->Names[i].Name.Length + sizeof(WCHAR) +
+                        EnumContext->Domains->Domains[EnumContext->Names[i].DomainIndex].Name.Length + sizeof(WCHAR);
                 break;
 
             case 3:
-                Size = sizeof(LOCALGROUP_MEMBERS_INFO_3) +
-                       EnumContext->Names[i].Name.Length + sizeof(WCHAR) +
-                       EnumContext->Domains->Domains[EnumContext->Names[i].DomainIndex].Name.Length + sizeof(WCHAR);
+                Size += sizeof(LOCALGROUP_MEMBERS_INFO_3) +
+                        EnumContext->Names[i].Name.Length + sizeof(WCHAR) +
+                        EnumContext->Domains->Domains[EnumContext->Names[i].DomainIndex].Name.Length + sizeof(WCHAR);
                 break;
 
             default: