]> 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:14:20 +0000 (10:14 +0200)
commit893605280e5794320d3c8205cd807e9704468145
treed0a982b61cd8278b9e3c29ea84eb171f97b09642
parent8448fd29ee6b78f8c3dc9a8e891c59ba0843e3c7
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)

(cherry picked from commit 50e9d2b188b8dce070f388640c06a7dc04417390)
crypto/mem.c