fixed returning the reference to the token in SeCopyClientToken() and probe pointer when neccessary

svn path=/trunk/; revision=13524
This commit is contained in:
Thomas Bluemel 2005-02-13 13:03:44 +00:00
parent 9e0d358564
commit ecc1462959

View file

@ -131,13 +131,32 @@ SepDuplicateToken(PTOKEN Token,
KPROCESSOR_MODE PreviousMode, KPROCESSOR_MODE PreviousMode,
PTOKEN* NewAccessToken) PTOKEN* NewAccessToken)
{ {
NTSTATUS Status;
ULONG uLength; ULONG uLength;
ULONG i; ULONG i;
PVOID EndMem; PVOID EndMem;
PTOKEN AccessToken; PTOKEN AccessToken;
NTSTATUS Status;
if(PreviousMode != KernelMode)
{
Status = STATUS_SUCCESS;
_SEH_TRY
{
ProbeForWrite(NewAccessToken,
sizeof(TOKEN),
sizeof(ULONG));
}
_SEH_HANDLE
{
Status = _SEH_GetExceptionCode();
}
_SEH_END;
if(!NT_SUCCESS(Status))
{
return Status;
}
}
Status = ObCreateObject(PreviousMode, Status = ObCreateObject(PreviousMode,
SepTokenObjectType, SepTokenObjectType,
@ -243,9 +262,18 @@ SepDuplicateToken(PTOKEN Token,
} }
if ( NT_SUCCESS(Status) ) if ( NT_SUCCESS(Status) )
{
_SEH_TRY
{ {
*NewAccessToken = AccessToken; *NewAccessToken = AccessToken;
return(STATUS_SUCCESS); Status = STATUS_SUCCESS;
}
_SEH_HANDLE
{
Status = _SEH_GetExceptionCode();
}
_SEH_END;
return Status;
} }
ObDereferenceObject(AccessToken); ObDereferenceObject(AccessToken);
@ -320,7 +348,7 @@ SeCopyClientToken(PACCESS_TOKEN Token,
TokenImpersonation, TokenImpersonation,
Level, Level,
PreviousMode, PreviousMode,
(PTOKEN*)&NewToken); (PTOKEN*)NewToken);
return(Status); return(Status);
} }