Uploaded image for project: 'Traffic Server'
  1. Traffic Server
  2. TS-376

Fix memory alignmet inlies in ink_align.h

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 2.1.1
    • Core
    • None

    Description

      Alignment code defined in ink_align.h is:
      pointer = (char *)(((unsigned long) pointer + widthmask) & (~widthmask));

      It is assumed that widthmask parameter is power of two minus one.

      The upper math gives wrong results.
      Eg.
      Aligning memory with the base address of 0x1001 to 512 bytes is done as following in the code:
      aligned = align_pointer_forward(base, 511);
      This gives resulting address: 0x1200 which is fine
      However if the base address was 0x11F0 the resulting address would be 0x1F0 instead 0x1200

      Solution is to use the

      pointer = (char *)(((unsigned long) pointer + alignment) & ~(alignment - 1));
      and use the real alignment numbers in the api instead masked values

      Attachments

        Activity

          People

            mturk@apache.org Mladen Turk
            mturk@apache.org Mladen Turk
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: