diff --git a/reactos/dll/win32/aclui/aclui.c b/reactos/dll/win32/aclui/aclui.c index 729ac7ca539..4613a9dd76c 100644 --- a/reactos/dll/win32/aclui/aclui.c +++ b/reactos/dll/win32/aclui/aclui.c @@ -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); diff --git a/reactos/dll/win32/advapi32/sec/sid.c b/reactos/dll/win32/advapi32/sec/sid.c index f53e8cbabe1..c4658957642 100644 --- a/reactos/dll/win32/advapi32/sec/sid.c +++ b/reactos/dll/win32/advapi32/sec/sid.c @@ -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; diff --git a/reactos/lib/rtl/sd.c b/reactos/lib/rtl/sd.c index e5a382ecc31..efad4afd134 100644 --- a/reactos/lib/rtl/sd.c +++ b/reactos/lib/rtl/sd.c @@ -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 */ diff --git a/reactos/lib/rtl/sid.c b/reactos/lib/rtl/sid.c index d461c45ab1a..28fce407d64 100644 --- a/reactos/lib/rtl/sid.c +++ b/reactos/lib/rtl/sid.c @@ -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]); } diff --git a/reactos/ntoskrnl/se/sid.c b/reactos/ntoskrnl/se/sid.c index ec506a75443..cae927f6dd3 100644 --- a/reactos/ntoskrnl/se/sid.c +++ b/reactos/ntoskrnl/se/sid.c @@ -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,