mirror of
https://github.com/reactos/reactos.git
synced 2025-06-28 06:59:42 +00:00
[NTOS:SE]
- Remove unnecessary null checks & fix up cleanup in SepCreateToken and SepDuplicateToken. Based on a patch by Víctor Martínez Calvo CORE-11768 #resolve svn path=/trunk/; revision=72101
This commit is contained in:
parent
ce6e5159ab
commit
ae5f46e58e
1 changed files with 14 additions and 28 deletions
|
@ -373,7 +373,7 @@ SepDuplicateToken(PTOKEN Token,
|
|||
ULONG uLength;
|
||||
ULONG i;
|
||||
PVOID EndMem;
|
||||
PTOKEN AccessToken = NULL;
|
||||
PTOKEN AccessToken;
|
||||
NTSTATUS Status;
|
||||
|
||||
PAGED_CODE();
|
||||
|
@ -400,9 +400,12 @@ SepDuplicateToken(PTOKEN Token,
|
|||
|
||||
AccessToken->TokenLock = &SepTokenLock;
|
||||
|
||||
/* Copy and reference the logon session */
|
||||
RtlCopyLuid(&AccessToken->AuthenticationId, &Token->AuthenticationId);
|
||||
SepRmReferenceLogonSession(&AccessToken->AuthenticationId);
|
||||
|
||||
AccessToken->TokenType = TokenType;
|
||||
AccessToken->ImpersonationLevel = Level;
|
||||
RtlCopyLuid(&AccessToken->AuthenticationId, &Token->AuthenticationId);
|
||||
RtlCopyLuid(&AccessToken->ModifiedId, &Token->ModifiedId);
|
||||
|
||||
AccessToken->TokenSource.SourceIdentifier.LowPart = Token->TokenSource.SourceIdentifier.LowPart;
|
||||
|
@ -483,26 +486,12 @@ SepDuplicateToken(PTOKEN Token,
|
|||
|
||||
*NewAccessToken = AccessToken;
|
||||
|
||||
/* Reference the logon session */
|
||||
SepRmReferenceLogonSession(&AccessToken->AuthenticationId);
|
||||
|
||||
done:
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
if (AccessToken)
|
||||
{
|
||||
if (AccessToken->UserAndGroups)
|
||||
ExFreePoolWithTag(AccessToken->UserAndGroups, TAG_TOKEN_USERS);
|
||||
|
||||
if (AccessToken->Privileges)
|
||||
ExFreePoolWithTag(AccessToken->Privileges, TAG_TOKEN_PRIVILAGES);
|
||||
|
||||
if (AccessToken->DefaultDacl)
|
||||
ExFreePoolWithTag(AccessToken->DefaultDacl, TAG_TOKEN_ACL);
|
||||
|
||||
/* Dereference the token, the delete procedure will clean up */
|
||||
ObDereferenceObject(AccessToken);
|
||||
}
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
@ -759,8 +748,11 @@ SepCreateToken(OUT PHANDLE TokenHandle,
|
|||
TokenSource->SourceName,
|
||||
sizeof(TokenSource->SourceName));
|
||||
|
||||
RtlCopyLuid(&AccessToken->TokenId, &TokenId);
|
||||
/* Copy and reference the logon session */
|
||||
RtlCopyLuid(&AccessToken->AuthenticationId, AuthenticationId);
|
||||
SepRmReferenceLogonSession(&AccessToken->AuthenticationId);
|
||||
|
||||
RtlCopyLuid(&AccessToken->TokenId, &TokenId);
|
||||
AccessToken->ExpirationTime = *ExpirationTime;
|
||||
RtlCopyLuid(&AccessToken->ModifiedId, &ModifiedId);
|
||||
|
||||
|
@ -899,18 +891,12 @@ SepCreateToken(OUT PHANDLE TokenHandle,
|
|||
*TokenHandle = (HANDLE)AccessToken;
|
||||
}
|
||||
|
||||
/* Reference the logon session */
|
||||
SepRmReferenceLogonSession(AuthenticationId);
|
||||
|
||||
done:
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
if (AccessToken)
|
||||
{
|
||||
/* Dereference the token, the delete procedure will clean up */
|
||||
ObDereferenceObject(AccessToken);
|
||||
}
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue