]> git.ipfire.org Git - people/ms/strongswan.git/commit
utils: Add malloc/free wrappers returning aligned data
authorMartin Willi <martin@revosec.ch>
Tue, 31 Mar 2015 15:25:05 +0000 (17:25 +0200)
committerMartin Willi <martin@revosec.ch>
Wed, 15 Apr 2015 11:44:40 +0000 (13:44 +0200)
commitf206bb74449f46c0558993f2b779ffa096fb32f2
tree9b7a2e4058621aea4dd3184d78c47a39f6520bf1
parentedab6c658c7d0c2d21877bf7aaad218c4b1c8167
utils: Add malloc/free wrappers returning aligned data

While we could use posix_memalign(3), that is not fully portable. Further, it
might be difficult on some platforms to properly catch it in leak-detective,
which results in invalid free()s when releasing such memory.

We instead use a simple wrapper, which allocates larger data, and saves the
padding size in the allocated header. This requires that memory is released
using a dedicated function.

To reduce the risk of invalid free() when working on corrupted data, we fill up
all the padding with the padding length, and verify it during free_align().
src/libstrongswan/tests/suites/test_utils.c
src/libstrongswan/utils/utils.c
src/libstrongswan/utils/utils.h