Uploaded image for project: 'Core ReactOS'
  1. Core ReactOS
  2. CORE-16094

Review sizeof(ACCESS_ALLOWED_ACE) allocations

    XMLWordPrintable

Details

    • Task
    • Resolution: Unresolved
    • Minor
    • None
    • None

    Description

      (Expanded from PR1607, thanks to Michael Maltsev.)

      We want to use (more)
      FIELD_OFFSET(ACCESS_ALLOWED_ACE, SidStart)
      instead.

      grep pattern:
      https://git.reactos.org/?p=reactos.git&a=search&h=HEAD&st=grep&s=sizeof.%2BACCESS_ALLOWED_ACE&sr=1

      https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/content/ntifs/nf-ntifs-rtlcreateacl

      To calculate the size of an ACL, add sizeof(ACL) to the size of all the ACEs to be stored in the ACL. To calculate the size of an ACE, add the size of the ACE structure, such as sizeof(ACCESS_ALLOWED_ACE), to the length of the SID associated with the ACE, and then subtract the size of the SidStart member (which is part of both the ACE structure and the SID). Use the RtlLengthSid function to get the length of a specified SID.

      The following example shows how to calculate the size of an access-allowed ACE:

      sizeof (ACCESS_ALLOWED_ACE) - sizeof (ACCESS_ALLOWED_ACE.SidStart)
      + GetLengthSid (pAceSid);

      To calculate the size of an ACL, use the following algorithm, substituting the appropriate ACE structure in the sizeof(ACE) expression:

      cbAcl = sizeof (ACL);
      for (i = 0 ; i < nAceCount ; i++) {
      // subtract ACE.SidStart from the size
      cbAce = sizeof (ACE) - sizeof (DWORD);
      // add this ACE's SID length
      cbAce += GetLengthSid (pAceSid[i]);
      // add the length of each ACE to the total ACL length
      cbAcl += cbAce;
      }

      Attachments

        Activity

          People

            bug zilla Bug Zilla
            Serge Gautherie Serge Gautherie
            Votes:
            1 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated: