mirror of
https://github.com/openssl/openssl.git
synced 2025-12-20 01:22:19 +08:00
crypto/mem.c: use open-coded aligned alloc when posix_memalign fails
While posix_memalign() is generally not expected to fail, we can always use the internal aligned alloc implementation to ensure that any OPENSSL_aligned_malloc failure is indeed fatal and does not require a fallback. Signed-off-by: Eugene Syromiatnikov <esyr@openssl.org> Reviewed-by: Neil Horman <nhorman@openssl.org> Reviewed-by: Saša Nedvědický <sashan@openssl.org> (Merged from https://github.com/openssl/openssl/pull/28295)
This commit is contained in:
committed by
Neil Horman
parent
8e28f5c0b9
commit
f75a6d951a
@@ -176,19 +176,10 @@ static const struct array_aligned_alloc_vector {
|
||||
{ SIZE_MAX / 8 + 9, 8, 64, EXP_NONNULL, EXP_INT_OF },
|
||||
|
||||
/*
|
||||
* posix_memalign expected to fail with ENOMEM, while the open-coded
|
||||
* implementation tries to alloc size + alignment, which should fail
|
||||
* on integer overflow.
|
||||
* the open-coded implementation tries to alloc size + alignment,
|
||||
* which should fail on integer overflow.
|
||||
*/
|
||||
{ 1, SIZE_MAX / 2 + 2, SIZE_MAX / 2 + 1,
|
||||
#if (defined(_BSD_SOURCE) \
|
||||
|| (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112L)) \
|
||||
&& !USE_CUSTOM_ALLOC_FNS
|
||||
EXP_OOM, EXP_OOM
|
||||
#else
|
||||
EXP_INT_OF, EXP_INT_OF
|
||||
#endif
|
||||
},
|
||||
{ 1, SIZE_MAX - 32767, 65536, EXP_INT_OF, EXP_INT_OF },
|
||||
};
|
||||
|
||||
static int secure_memory_is_secure;
|
||||
|
||||
Reference in New Issue
Block a user