Fix RtlEqualSid().

svn path=/trunk/; revision=10062
This commit is contained in:
Eric Kohl 2004-07-10 13:11:18 +00:00
parent 7f900f8f7e
commit 39da3d41f9

View file

@ -1,4 +1,4 @@
/* $Id: sid.c,v 1.2 2004/06/20 23:30:47 gdalsnes Exp $
/* $Id: sid.c,v 1.3 2004/07/10 13:11:18 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -24,15 +24,13 @@
BOOLEAN STDCALL
RtlValidSid(IN PSID Sid)
{
if ((Sid->Revision & 0xf) != 1)
if (((Sid->Revision & 0xf) != 1) ||
(Sid->SubAuthorityCount > 15))
{
return(FALSE);
return FALSE;
}
if (Sid->SubAuthorityCount > 15)
{
return(FALSE);
}
return(TRUE);
return TRUE;
}
@ -42,7 +40,7 @@ RtlValidSid(IN PSID Sid)
ULONG STDCALL
RtlLengthRequiredSid(IN UCHAR SubAuthorityCount)
{
return(sizeof(SID) + (SubAuthorityCount - 1) * sizeof(ULONG));
return (sizeof(SID) + (SubAuthorityCount - 1) * sizeof(ULONG));
}
@ -59,7 +57,8 @@ RtlInitializeSid(IN PSID Sid,
memcpy(&Sid->IdentifierAuthority,
IdentifierAuthority,
sizeof(SID_IDENTIFIER_AUTHORITY));
return(STATUS_SUCCESS);
return STATUS_SUCCESS;
}
@ -70,7 +69,7 @@ PULONG STDCALL
RtlSubAuthoritySid(IN PSID Sid,
IN ULONG SubAuthority)
{
return(&Sid->SubAuthority[SubAuthority]);
return &Sid->SubAuthority[SubAuthority];
}
@ -80,7 +79,7 @@ RtlSubAuthoritySid(IN PSID Sid,
PUCHAR STDCALL
RtlSubAuthorityCountSid(IN PSID Sid)
{
return(&Sid->SubAuthorityCount);
return &Sid->SubAuthorityCount;
}
@ -99,7 +98,7 @@ RtlEqualSid(IN PSID Sid1,
{
return(FALSE);
}
if (RtlCompareMemory(Sid1, Sid2, RtlLengthSid(Sid1)) != 0)
if (RtlCompareMemory(Sid1, Sid2, RtlLengthSid(Sid1)) != RtlLengthSid(Sid1))
{
return(FALSE);
}
@ -113,7 +112,7 @@ RtlEqualSid(IN PSID Sid1,
ULONG STDCALL
RtlLengthSid(IN PSID Sid)
{
return(sizeof(SID) + (Sid->SubAuthorityCount-1)*4);
return (sizeof(SID) + (Sid->SubAuthorityCount-1) * sizeof(ULONG));
}
@ -127,12 +126,14 @@ RtlCopySid(ULONG BufferLength,
{
if (BufferLength < RtlLengthSid(Src))
{
return(STATUS_UNSUCCESSFUL);
return STATUS_UNSUCCESSFUL;
}
memmove(Dest,
Src,
RtlLengthSid(Src));
return(STATUS_SUCCESS);
return STATUS_SUCCESS;
}
@ -181,17 +182,15 @@ RtlCopySidAndAttributesArray(ULONG Count,
PSID_IDENTIFIER_AUTHORITY STDCALL
RtlIdentifierAuthoritySid(IN PSID Sid)
{
return(&Sid->IdentifierAuthority);
return &Sid->IdentifierAuthority;
}
/*
* @implemented
*/
NTSTATUS
STDCALL
RtlAllocateAndInitializeSid (
PSID_IDENTIFIER_AUTHORITY IdentifierAuthority,
NTSTATUS STDCALL
RtlAllocateAndInitializeSid(PSID_IDENTIFIER_AUTHORITY IdentifierAuthority,
UCHAR SubAuthorityCount,
ULONG SubAuthority0,
ULONG SubAuthority1,
@ -201,8 +200,7 @@ RtlAllocateAndInitializeSid (
ULONG SubAuthority5,
ULONG SubAuthority6,
ULONG SubAuthority7,
PSID *Sid
)
PSID *Sid)
{
PSID pSid;
@ -212,13 +210,14 @@ RtlAllocateAndInitializeSid (
if (Sid == NULL)
return STATUS_INVALID_PARAMETER;
pSid = (PSID)ExAllocatePool(PagedPool, SubAuthorityCount * sizeof(DWORD) + 8);
pSid = (PSID)ExAllocatePool(PagedPool,
sizeof(SID) + (SubAuthorityCount - 1) * sizeof(ULONG));
if (pSid == NULL)
return STATUS_NO_MEMORY;
pSid->Revision = 1;
pSid->SubAuthorityCount = SubAuthorityCount;
memcpy (&pSid->IdentifierAuthority,
memcpy(&pSid->IdentifierAuthority,
IdentifierAuthority,
sizeof(SID_IDENTIFIER_AUTHORITY));