Some portability fixes that address possible alignment issues. Read R. Chen's blog 10/06/06 for more information.

svn path=/trunk/; revision=24472
This commit is contained in:
Thomas Bluemel 2006-10-09 15:09:50 +00:00
parent 182fc37942
commit 8a80403d2a
5 changed files with 10 additions and 10 deletions

View file

@ -1047,7 +1047,8 @@ BuildDefaultPrincipalAce(IN PSECURITY_PAGE sp,
WORD AceSize;
SidLen = GetLengthSid(pSid);
AceSize = sizeof(ACCESS_ALLOWED_ACE) + (WORD)SidLen - sizeof(DWORD);
AceSize = FIELD_OFFSET(ACCESS_ALLOWED_ACE,
SidStart) + (WORD)SidLen;
Ace = HeapAlloc(GetProcessHeap(),
0,
AceSize);

View file

@ -184,7 +184,7 @@ static __inline BOOL set_ntstatus( NTSTATUS status )
return !status;
}
#define WINE_SIZE_OF_WORLD_ACCESS_ACL (sizeof(ACL) + sizeof(ACCESS_ALLOWED_ACE) + sizeof(sidWorld) - sizeof(DWORD))
#define WINE_SIZE_OF_WORLD_ACCESS_ACL (sizeof(ACL) + FIELD_OFFSET(ACCESS_ALLOWED_ACE, SidStart) + sizeof(sidWorld))
/* some helper functions - taken from winehq cvs 20050916 */
@ -428,7 +428,7 @@ static BOOL ParseStringAclToAcl(LPCWSTR StringAcl, LPDWORD lpdwFlags,
goto lerr;
StringAcl++;
length += sizeof(ACCESS_ALLOWED_ACE) - sizeof(DWORD) + sidlen;
length += FIELD_OFFSET(ACCESS_ALLOWED_ACE, SidStart) + sidlen;
}
*cBytes = length;

View file

@ -812,8 +812,6 @@ RtlSelfRelativeToAbsoluteSD2(IN OUT PSECURITY_DESCRIPTOR SelfRelativeSD,
&pSacl,
&SaclLength);
ASSERT(sizeof(SECURITY_DESCRIPTOR) > sizeof(SECURITY_DESCRIPTOR_RELATIVE));
/* calculate the start and end of the data area, we simply just move the
data by the difference between the size of the relative and absolute
security descriptor structure */

View file

@ -42,8 +42,8 @@ RtlLengthRequiredSid(IN ULONG SubAuthorityCount)
{
PAGED_CODE_RTL();
return (sizeof(SID) - (ANYSIZE_ARRAY * sizeof(ULONG)) +
(SubAuthorityCount * sizeof(ULONG)));
return (ULONG)FIELD_OFFSET(SID,
SubAuthority[SubAuthorityCount]);
}
@ -132,8 +132,8 @@ RtlLengthSid(IN PSID Sid_)
PAGED_CODE_RTL();
return (sizeof(SID) - sizeof(Sid->SubAuthority) +
(Sid->SubAuthorityCount * sizeof(ULONG)));
return (ULONG)FIELD_OFFSET(SID,
SubAuthority[Sid->SubAuthorityCount]);
}

View file

@ -246,7 +246,8 @@ SepCaptureSid(IN PSID InputSid,
_SEH_TRY
{
ProbeForRead(Sid,
sizeof(*Sid) - sizeof(Sid->SubAuthority),
FIELD_OFFSET(SID,
SubAuthority),
sizeof(UCHAR));
SidSize = RtlLengthRequiredSid(Sid->SubAuthorityCount);
ProbeForRead(Sid,