- Just run again the loop if LsarOpenAccount call failed (that also avoids a call to LsarClose on a NULL handle, that is trapped by the kdbg if one enabled "set condition * first always").
- Free the memory and the opened handles before returning in case of failure of LsapAddPrivilegeToTokenPrivileges. Maybe this cleaning step can be done more elegantly.
Eric, can you please review that? It should be good I think.

svn path=/trunk/; revision=63496
This commit is contained in:
Hermès Bélusca-Maïto 2014-05-29 21:34:35 +00:00
parent 0d6c552a9d
commit cb2c49a1ea

View file

@ -1308,23 +1308,30 @@ LsapSetPrivileges(
TokenInfo1->Groups->Groups[i].Sid,
ACCOUNT_VIEW,
&AccountHandle);
if (!NT_SUCCESS(Status))
continue;
Status = LsarEnumeratePrivilegesAccount(AccountHandle,
&Privileges);
if (NT_SUCCESS(Status))
{
Status = LsarEnumeratePrivilegesAccount(AccountHandle,
&Privileges);
if (NT_SUCCESS(Status))
for (j = 0; j < Privileges->PrivilegeCount; j++)
{
for (j = 0; j < Privileges->PrivilegeCount; j++)
Status = LsapAddPrivilegeToTokenPrivileges(&TokenInfo1->Privileges,
&(Privileges->Privilege[j]));
if (!NT_SUCCESS(Status))
{
Status = LsapAddPrivilegeToTokenPrivileges(&TokenInfo1->Privileges,
&(Privileges->Privilege[j]));
if (!NT_SUCCESS(Status))
return Status;
}
/* We failed, clean everything and return */
LsaIFree_LSAPR_PRIVILEGE_SET(Privileges);
LsarClose(&AccountHandle);
LsarClose(&PolicyHandle);
LsaIFree_LSAPR_PRIVILEGE_SET(Privileges);
Privileges = NULL;
return Status;
}
}
LsaIFree_LSAPR_PRIVILEGE_SET(Privileges);
Privileges = NULL;
}
LsarClose(&AccountHandle);