mirror of
https://github.com/reactos/reactos.git
synced 2025-06-28 14:29:43 +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 uLength;
|
||||||
ULONG i;
|
ULONG i;
|
||||||
PVOID EndMem;
|
PVOID EndMem;
|
||||||
PTOKEN AccessToken = NULL;
|
PTOKEN AccessToken;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
PAGED_CODE();
|
PAGED_CODE();
|
||||||
|
@ -400,9 +400,12 @@ SepDuplicateToken(PTOKEN Token,
|
||||||
|
|
||||||
AccessToken->TokenLock = &SepTokenLock;
|
AccessToken->TokenLock = &SepTokenLock;
|
||||||
|
|
||||||
|
/* Copy and reference the logon session */
|
||||||
|
RtlCopyLuid(&AccessToken->AuthenticationId, &Token->AuthenticationId);
|
||||||
|
SepRmReferenceLogonSession(&AccessToken->AuthenticationId);
|
||||||
|
|
||||||
AccessToken->TokenType = TokenType;
|
AccessToken->TokenType = TokenType;
|
||||||
AccessToken->ImpersonationLevel = Level;
|
AccessToken->ImpersonationLevel = Level;
|
||||||
RtlCopyLuid(&AccessToken->AuthenticationId, &Token->AuthenticationId);
|
|
||||||
RtlCopyLuid(&AccessToken->ModifiedId, &Token->ModifiedId);
|
RtlCopyLuid(&AccessToken->ModifiedId, &Token->ModifiedId);
|
||||||
|
|
||||||
AccessToken->TokenSource.SourceIdentifier.LowPart = Token->TokenSource.SourceIdentifier.LowPart;
|
AccessToken->TokenSource.SourceIdentifier.LowPart = Token->TokenSource.SourceIdentifier.LowPart;
|
||||||
|
@ -483,26 +486,12 @@ SepDuplicateToken(PTOKEN Token,
|
||||||
|
|
||||||
*NewAccessToken = AccessToken;
|
*NewAccessToken = AccessToken;
|
||||||
|
|
||||||
/* Reference the logon session */
|
|
||||||
SepRmReferenceLogonSession(&AccessToken->AuthenticationId);
|
|
||||||
|
|
||||||
done:
|
done:
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
if (AccessToken)
|
/* Dereference the token, the delete procedure will clean up */
|
||||||
{
|
|
||||||
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);
|
|
||||||
|
|
||||||
ObDereferenceObject(AccessToken);
|
ObDereferenceObject(AccessToken);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
@ -759,8 +748,11 @@ SepCreateToken(OUT PHANDLE TokenHandle,
|
||||||
TokenSource->SourceName,
|
TokenSource->SourceName,
|
||||||
sizeof(TokenSource->SourceName));
|
sizeof(TokenSource->SourceName));
|
||||||
|
|
||||||
RtlCopyLuid(&AccessToken->TokenId, &TokenId);
|
/* Copy and reference the logon session */
|
||||||
RtlCopyLuid(&AccessToken->AuthenticationId, AuthenticationId);
|
RtlCopyLuid(&AccessToken->AuthenticationId, AuthenticationId);
|
||||||
|
SepRmReferenceLogonSession(&AccessToken->AuthenticationId);
|
||||||
|
|
||||||
|
RtlCopyLuid(&AccessToken->TokenId, &TokenId);
|
||||||
AccessToken->ExpirationTime = *ExpirationTime;
|
AccessToken->ExpirationTime = *ExpirationTime;
|
||||||
RtlCopyLuid(&AccessToken->ModifiedId, &ModifiedId);
|
RtlCopyLuid(&AccessToken->ModifiedId, &ModifiedId);
|
||||||
|
|
||||||
|
@ -899,18 +891,12 @@ SepCreateToken(OUT PHANDLE TokenHandle,
|
||||||
*TokenHandle = (HANDLE)AccessToken;
|
*TokenHandle = (HANDLE)AccessToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Reference the logon session */
|
|
||||||
SepRmReferenceLogonSession(AuthenticationId);
|
|
||||||
|
|
||||||
done:
|
done:
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
|
||||||
if (AccessToken)
|
|
||||||
{
|
{
|
||||||
/* Dereference the token, the delete procedure will clean up */
|
/* Dereference the token, the delete procedure will clean up */
|
||||||
ObDereferenceObject(AccessToken);
|
ObDereferenceObject(AccessToken);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue