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; WORD AceSize;
SidLen = GetLengthSid(pSid); SidLen = GetLengthSid(pSid);
AceSize = sizeof(ACCESS_ALLOWED_ACE) + (WORD)SidLen - sizeof(DWORD); AceSize = FIELD_OFFSET(ACCESS_ALLOWED_ACE,
SidStart) + (WORD)SidLen;
Ace = HeapAlloc(GetProcessHeap(), Ace = HeapAlloc(GetProcessHeap(),
0, 0,
AceSize); AceSize);

View file

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

View file

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

View file

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

View file

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