This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug malloc/20137] aligned_alloc should fail for bad size / alignment [DR#460]


https://sourceware.org/bugzilla/show_bug.cgi?id=20137

Florian Weimer <fweimer at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |fweimer at redhat dot com
              Flags|                            |security-

--- Comment #1 from Florian Weimer <fweimer at redhat dot com> ---
(In reply to Joseph Myers from comment #0)
> The resolution to C11 DR#460 requires aligned_alloc to return NULL if the
> alignment is not valid (not a power of 2, in our case) or the size is not a
> multiple of the alignment.  This needs to be implemented.

Do you have link to the rationale for the second requirement?  It does not make
sense to me.

For example, when allocating space for a struct dirent object, you can end up
with an allocation size which is not a multiple of the required alignment. 
glibc itself uses a similar allocations in many other places.


I understand this bug is just about aligned_alloc (and not about lowering the
alignment of pointers returned by malloc if the size happens to be odd, for
example).  But this additional requirement for aligned_alloc seems to be rather
strange.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]