]> git.ipfire.org Git - thirdparty/openssl.git/commit
mem: Don't use posix_memalign() and friends with custom wrapper
authorSebastian Andrzej Siewior <sebastian@breakpoint.cc>
Sun, 13 Oct 2024 16:05:55 +0000 (18:05 +0200)
committerTomas Mraz <tomas@openssl.org>
Wed, 16 Oct 2024 08:13:49 +0000 (10:13 +0200)
commit50e9d2b188b8dce070f388640c06a7dc04417390
treebbbce282dd3a884a077fdc41f8f69918b1bc1671
parente524ac548a628e4cef9fd5e722720c0fd48f41a8
mem: Don't use posix_memalign() and friends with custom wrapper

If the application provides custom memory allocations functions via
CRYPTO_set_mem_functions() then those should be used instead something
else like posix_memalign(). The applications might verify alloc and free
calls and pointers from posix_memalign() were never returned by the
implementations.

At least stunnel4 complains here.

Use posix_memalign() or if aligned_alloc() only if the application did
not provide a custom malloc() implementation. In case of a custom
implementation use CRYPTO_malloc() and align the memory accordingly.

Fixes #25678

Signed-off-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/25682)
crypto/mem.c