mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 18:15:11 +00:00
- fixed buffer size calculation in RtlLengthRequiredSid and RtlLengthSid
- use RtlCreateUnicodeString to allocate the string in RtlConvertSidToUnicodeString svn path=/trunk/; revision=18012
This commit is contained in:
parent
528323ece7
commit
7542d31c35
1 changed files with 26 additions and 27 deletions
|
@ -42,7 +42,8 @@ RtlLengthRequiredSid(IN ULONG SubAuthorityCount)
|
||||||
{
|
{
|
||||||
PAGED_CODE_RTL();
|
PAGED_CODE_RTL();
|
||||||
|
|
||||||
return (sizeof(SID) + (SubAuthorityCount - 1) * sizeof(ULONG));
|
return (sizeof(SID) - (ANYSIZE_ARRAY * sizeof(ULONG)) +
|
||||||
|
(SubAuthorityCount * sizeof(ULONG)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -106,22 +107,18 @@ RtlEqualSid(IN PSID Sid1_,
|
||||||
{
|
{
|
||||||
PISID Sid1 = Sid1_;
|
PISID Sid1 = Sid1_;
|
||||||
PISID Sid2 = Sid2_;
|
PISID Sid2 = Sid2_;
|
||||||
|
SIZE_T SidLen;
|
||||||
|
|
||||||
PAGED_CODE_RTL();
|
PAGED_CODE_RTL();
|
||||||
|
|
||||||
if (Sid1->Revision != Sid2->Revision)
|
if (Sid1->Revision != Sid2->Revision ||
|
||||||
|
(*RtlSubAuthorityCountSid(Sid1)) != (*RtlSubAuthorityCountSid(Sid2)))
|
||||||
{
|
{
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
if ((*RtlSubAuthorityCountSid(Sid1)) != (*RtlSubAuthorityCountSid(Sid2)))
|
|
||||||
{
|
SidLen = RtlLengthSid(Sid1);
|
||||||
return(FALSE);
|
return RtlCompareMemory(Sid1, Sid2, SidLen) == SidLen;
|
||||||
}
|
|
||||||
if (RtlCompareMemory(Sid1, Sid2, RtlLengthSid(Sid1)) != RtlLengthSid(Sid1))
|
|
||||||
{
|
|
||||||
return(FALSE);
|
|
||||||
}
|
|
||||||
return(TRUE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -135,7 +132,8 @@ RtlLengthSid(IN PSID Sid_)
|
||||||
|
|
||||||
PAGED_CODE_RTL();
|
PAGED_CODE_RTL();
|
||||||
|
|
||||||
return (sizeof(SID) + (Sid->SubAuthorityCount-1) * sizeof(ULONG));
|
return (sizeof(SID) - sizeof(Sid->SubAuthority) +
|
||||||
|
(Sid->SubAuthorityCount * sizeof(ULONG)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -243,7 +241,7 @@ RtlAllocateAndInitializeSid(PSID_IDENTIFIER_AUTHORITY IdentifierAuthority,
|
||||||
if (Sid == NULL)
|
if (Sid == NULL)
|
||||||
return STATUS_INVALID_PARAMETER;
|
return STATUS_INVALID_PARAMETER;
|
||||||
|
|
||||||
pSid = RtlpAllocateMemory(sizeof(SID) + (SubAuthorityCount - 1) * sizeof(ULONG),
|
pSid = RtlpAllocateMemory(RtlLengthRequiredSid(SubAuthorityCount),
|
||||||
TAG_SID);
|
TAG_SID);
|
||||||
if (pSid == NULL)
|
if (pSid == NULL)
|
||||||
return STATUS_NO_MEMORY;
|
return STATUS_NO_MEMORY;
|
||||||
|
@ -366,20 +364,20 @@ RtlConvertSidToUnicodeString(PUNICODE_STRING String,
|
||||||
Sid->SubAuthority[i]);
|
Sid->SubAuthority[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
Length = (wcs - Buffer) * sizeof(WCHAR);
|
|
||||||
if (AllocateBuffer)
|
if (AllocateBuffer)
|
||||||
{
|
{
|
||||||
String->Buffer = RtlpAllocateMemory(Length + sizeof(WCHAR),
|
if (!RtlCreateUnicodeString(String,
|
||||||
TAG_SID);
|
Buffer))
|
||||||
if (String->Buffer == NULL)
|
{
|
||||||
return STATUS_NO_MEMORY;
|
return STATUS_NO_MEMORY;
|
||||||
String->MaximumLength = Length + sizeof(WCHAR);
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Length = (wcs - Buffer) * sizeof(WCHAR);
|
||||||
|
|
||||||
if (Length > String->MaximumLength)
|
if (Length > String->MaximumLength)
|
||||||
return STATUS_BUFFER_TOO_SMALL;
|
return STATUS_BUFFER_TOO_SMALL;
|
||||||
}
|
|
||||||
|
|
||||||
String->Length = Length;
|
String->Length = Length;
|
||||||
RtlCopyMemory (String->Buffer,
|
RtlCopyMemory (String->Buffer,
|
||||||
|
@ -387,6 +385,7 @@ RtlConvertSidToUnicodeString(PUNICODE_STRING String,
|
||||||
Length);
|
Length);
|
||||||
if (Length < String->MaximumLength)
|
if (Length < String->MaximumLength)
|
||||||
String->Buffer[Length / sizeof(WCHAR)] = 0;
|
String->Buffer[Length / sizeof(WCHAR)] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue