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)
{
return(FALSE);
}
if (Sid->SubAuthorityCount > 15)
{
return(FALSE);
}
return(TRUE);
if (((Sid->Revision & 0xf) != 1) ||
(Sid->SubAuthorityCount > 15))
{
return FALSE;
}
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));
}
@ -54,12 +52,13 @@ RtlInitializeSid(IN PSID Sid,
IN PSID_IDENTIFIER_AUTHORITY IdentifierAuthority,
IN UCHAR SubAuthorityCount)
{
Sid->Revision = 1;
Sid->SubAuthorityCount = SubAuthorityCount;
memcpy(&Sid->IdentifierAuthority,
IdentifierAuthority,
sizeof(SID_IDENTIFIER_AUTHORITY));
return(STATUS_SUCCESS);
Sid->Revision = 1;
Sid->SubAuthorityCount = SubAuthorityCount;
memcpy(&Sid->IdentifierAuthority,
IdentifierAuthority,
sizeof(SID_IDENTIFIER_AUTHORITY));
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;
}
@ -91,7 +90,7 @@ BOOLEAN STDCALL
RtlEqualSid(IN PSID Sid1,
IN PSID Sid2)
{
if (Sid1->Revision != Sid2->Revision)
if (Sid1->Revision != Sid2->Revision)
{
return(FALSE);
}
@ -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));
}
@ -125,14 +124,16 @@ RtlCopySid(ULONG BufferLength,
PSID Dest,
PSID Src)
{
if (BufferLength < RtlLengthSid(Src))
{
return(STATUS_UNSUCCESSFUL);
}
memmove(Dest,
Src,
RtlLengthSid(Src));
return(STATUS_SUCCESS);
if (BufferLength < RtlLengthSid(Src))
{
return STATUS_UNSUCCESSFUL;
}
memmove(Dest,
Src,
RtlLengthSid(Src));
return STATUS_SUCCESS;
}
@ -181,49 +182,47 @@ 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,
UCHAR SubAuthorityCount,
ULONG SubAuthority0,
ULONG SubAuthority1,
ULONG SubAuthority2,
ULONG SubAuthority3,
ULONG SubAuthority4,
ULONG SubAuthority5,
ULONG SubAuthority6,
ULONG SubAuthority7,
PSID *Sid
)
NTSTATUS STDCALL
RtlAllocateAndInitializeSid(PSID_IDENTIFIER_AUTHORITY IdentifierAuthority,
UCHAR SubAuthorityCount,
ULONG SubAuthority0,
ULONG SubAuthority1,
ULONG SubAuthority2,
ULONG SubAuthority3,
ULONG SubAuthority4,
ULONG SubAuthority5,
ULONG SubAuthority6,
ULONG SubAuthority7,
PSID *Sid)
{
PSID pSid;
PSID pSid;
if (SubAuthorityCount > 8)
return STATUS_INVALID_SID;
if (SubAuthorityCount > 8)
return STATUS_INVALID_SID;
if (Sid == NULL)
return STATUS_INVALID_PARAMETER;
if (Sid == NULL)
return STATUS_INVALID_PARAMETER;
pSid = (PSID)ExAllocatePool(PagedPool, SubAuthorityCount * sizeof(DWORD) + 8);
if (pSid == NULL)
return STATUS_NO_MEMORY;
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,
IdentifierAuthority,
sizeof(SID_IDENTIFIER_AUTHORITY));
pSid->Revision = 1;
pSid->SubAuthorityCount = SubAuthorityCount;
memcpy(&pSid->IdentifierAuthority,
IdentifierAuthority,
sizeof(SID_IDENTIFIER_AUTHORITY));
switch (SubAuthorityCount)
{
switch (SubAuthorityCount)
{
case 8:
pSid->SubAuthority[7] = SubAuthority7;
case 7:
@ -241,11 +240,11 @@ RtlAllocateAndInitializeSid (
case 1:
pSid->SubAuthority[0] = SubAuthority0;
break;
}
}
*Sid = pSid;
*Sid = pSid;
return STATUS_SUCCESS;
return STATUS_SUCCESS;
}