https://git.reactos.org/?p=reactos.git;a=commitdiff;h=206df96bc474cb154934b43453159079520e0512

commit 206df96bc474cb154934b43453159079520e0512
Author:     Thomas Faber <thomas.fa...@reactos.org>
AuthorDate: Sat May 27 14:01:44 2023 -0400
Commit:     Timo Kreuzer <timo.kreu...@reactos.org>
CommitDate: Thu Sep 12 17:44:13 2024 +0300

    [KMTESTS:SE] Correctly allocate PrivilegeSet buffers.
---
 modules/rostests/kmtests/ntos_se/SeQueryInfoToken.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/modules/rostests/kmtests/ntos_se/SeQueryInfoToken.c 
b/modules/rostests/kmtests/ntos_se/SeQueryInfoToken.c
index f5f2b0213aa..ae4c50f5561 100644
--- a/modules/rostests/kmtests/ntos_se/SeQueryInfoToken.c
+++ b/modules/rostests/kmtests/ntos_se/SeQueryInfoToken.c
@@ -282,25 +282,29 @@ START_TEST(SeQueryInfoToken)
 
     //  Testing SeAppendPrivileges. Must change PrivilegeCount to 2 (1 + 1)
 
-    NewPrivilegeSet = ExAllocatePool(PagedPool, sizeof(PRIVILEGE_SET));
+    NewPrivilegeSet = ExAllocatePoolZero(PagedPool,
+                                         FIELD_OFFSET(PRIVILEGE_SET, 
Privilege[1]),
+                                         'QSmK');
     NewPrivilegeSet->PrivilegeCount = 1;
 
     Status = SeAppendPrivileges(AccessState, NewPrivilegeSet);
     ok(Status == STATUS_SUCCESS, "SeAppendPrivileges failed\n");
     ok((AuxData->PrivilegeSet->PrivilegeCount == 2),"PrivelegeCount must be 2, 
but it is %d\n", AuxData->PrivilegeSet->PrivilegeCount);
-    ExFreePool(NewPrivilegeSet);
+    ExFreePoolWithTag(NewPrivilegeSet, 'QSmK');
 
     //----------------------------------------------------------------//
 
     // Testing SeAppendPrivileges. Must change PrivilegeCount to 6 (2 + 4)
 
-    NewPrivilegeSet = ExAllocatePool(PagedPool, 4*sizeof(PRIVILEGE_SET));
+    NewPrivilegeSet = ExAllocatePoolZero(PagedPool,
+                                         FIELD_OFFSET(PRIVILEGE_SET, 
Privilege[4]),
+                                         'QSmK');
     NewPrivilegeSet->PrivilegeCount = 4;
 
     Status = SeAppendPrivileges(AccessState, NewPrivilegeSet);
     ok(Status == STATUS_SUCCESS, "SeAppendPrivileges failed\n");
     ok((AuxData->PrivilegeSet->PrivilegeCount == 6),"PrivelegeCount must be 6, 
but it is %d\n", AuxData->PrivilegeSet->PrivilegeCount);
-    ExFreePool(NewPrivilegeSet);
+    ExFreePoolWithTag(NewPrivilegeSet, 'QSmK');
 
     //----------------------------------------------------------------//
     //      Testing SePrivilegeCheck                                  //
@@ -363,12 +367,14 @@ START_TEST(SeQueryInfoToken)
             TPrivileges = (PTOKEN_PRIVILEGES)(Buffer);
             //trace("TPCount = %u\n\n", TPrivileges->PrivilegeCount);
 
-            NewPrivilegeSet = ExAllocatePool(PagedPool, 
14*sizeof(PRIVILEGE_SET));
+            NewPrivilegeSet = ExAllocatePoolZero(PagedPool,
+                                                 FIELD_OFFSET(PRIVILEGE_SET, 
Privilege[14]),
+                                                 'QSmK');
             NewPrivilegeSet->PrivilegeCount = 14;
 
             ok((SeAppendPrivileges(AccessState, NewPrivilegeSet)) == 
STATUS_SUCCESS, "SeAppendPrivileges failed\n");
             ok((AuxData->PrivilegeSet->PrivilegeCount == 20),"PrivelegeCount 
must be 20, but it is %d\n", AuxData->PrivilegeSet->PrivilegeCount);
-            ExFreePool(NewPrivilegeSet);
+            ExFreePoolWithTag(NewPrivilegeSet, 'QSmK');
             for (i = 0; i < AuxData->PrivilegeSet->PrivilegeCount; i++)
             {
                 AuxData->PrivilegeSet->Privilege[i].Attributes = 
TPrivileges->Privileges[i].Attributes;

Reply via email to