[NTOSKRNL]

Small optimization of SepPrivilegeCheck

svn path=/trunk/; revision=61582
This commit is contained in:
Timo Kreuzer 2014-01-11 15:23:53 +00:00
parent 95c15b34d7
commit a269ff2f2b

View file

@ -90,7 +90,7 @@ SepPrivilegeCheck(PTOKEN Token,
Required = (PrivilegeControl & PRIVILEGE_SET_ALL_NECESSARY) ? PrivilegeCount : 1; Required = (PrivilegeControl & PRIVILEGE_SET_ALL_NECESSARY) ? PrivilegeCount : 1;
/* Loop all requested privileges until we found the required ones */ /* Loop all requested privileges until we found the required ones */
for (i = 0; i < PrivilegeCount && Required > 0; i++) for (i = 0; i < PrivilegeCount; i++)
{ {
/* Loop the privileges of the token */ /* Loop the privileges of the token */
for (j = 0; j < Token->PrivilegeCount; j++) for (j = 0; j < Token->PrivilegeCount; j++)
@ -107,6 +107,13 @@ SepPrivilegeCheck(PTOKEN Token,
{ {
Privileges[i].Attributes |= SE_PRIVILEGE_USED_FOR_ACCESS; Privileges[i].Attributes |= SE_PRIVILEGE_USED_FOR_ACCESS;
Required--; Required--;
/* Check if we have found all privileges */
if (Required == 0)
{
/* We're done! */
return TRUE;
}
} }
/* Leave the inner loop */ /* Leave the inner loop */
@ -115,8 +122,9 @@ SepPrivilegeCheck(PTOKEN Token,
} }
} }
/* Return whether we found all required privileges */ /* When we reached this point, we did not find all privileges */
return (Required == 0); NT_ASSERT(Required > 0);
return FALSE;
} }
NTSTATUS NTSTATUS