[RTL] When taking system volume ownership, assert that we succeeded to restore privileges

CORE-17637
This commit is contained in:
Jérôme Gardou 2021-06-17 15:39:40 +02:00 committed by Jérôme Gardou
parent 9c5b39e25a
commit fb9ebe17bf

View file

@ -412,7 +412,9 @@ Cleanup:
return Status; return Status;
} }
static NTSTATUS _Must_inspect_result_
static
NTSTATUS
RtlpSysVolTakeOwnership(IN PUNICODE_STRING DirectoryPath, RtlpSysVolTakeOwnership(IN PUNICODE_STRING DirectoryPath,
IN PSECURITY_DESCRIPTOR SecurityDescriptor) IN PSECURITY_DESCRIPTOR SecurityDescriptor)
{ {
@ -511,12 +513,16 @@ RtlpSysVolTakeOwnership(IN PUNICODE_STRING DirectoryPath,
Cleanup: Cleanup:
if (TokenEnabled) if (TokenEnabled)
{ {
ZwAdjustPrivilegesToken(hToken, /* Disable privileges that we had to enable, whetever the result was. */
FALSE, NTSTATUS Status2 = ZwAdjustPrivilegesToken(hToken,
&TokenPrivileges, FALSE,
0, &TokenPrivileges,
NULL, 0,
NULL); NULL,
NULL);
/* This must succeed */
ASSERT(NT_SUCCESS(Status2));
(void)Status2;
} }
if (AdminSid != NULL) if (AdminSid != NULL)