]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
test/mem_alloc_test.c: increase alloc size for triggering OOM malloc failure
authorEugene Syromiatnikov <esyr@openssl.org>
Tue, 12 May 2026 12:41:16 +0000 (14:41 +0200)
committerNorbert Pocs <norbertp@openssl.org>
Mon, 18 May 2026 07:30:43 +0000 (09:30 +0200)
While half of the address space is enough to make malloc() fail on
kernels of the same bitness, 32-bit compat can have enough to accommodate
such a request, and even three fourth of the address space.  Bump
the requested size closer to the type's upper limit.

Fixes: d090695101a9 "test: add a sanity test for memory allocation functions"
Signed-off-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.foundation>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
MergeDate: Mon May 18 07:30:48 2026
(Merged from https://github.com/openssl/openssl/pull/31158)

test/mem_alloc_test.c

index cef1271f78889f6956b71a0541bb270fa2eee50b..600d4fc4d008cfeae545b68ec190123e0500bb43 100644 (file)
@@ -78,7 +78,7 @@ static const struct array_alloc_vector {
 
     { 1, 1, EXP_NONNULL, EXP_NONNULL },
 
-    { SQRT_SIZE_T / 2, SQRT_SIZE_T, EXP_OOM, EXP_OOM },
+    { SQRT_SIZE_T - 1, SQRT_SIZE_T - 1, EXP_OOM, EXP_OOM },
 
     { SQRT_SIZE_T, SQRT_SIZE_T, EXP_ZERO_SIZE, EXP_INT_OF },
 
@@ -88,8 +88,6 @@ static const struct array_alloc_vector {
 #else /* Of course there are no archutectures other than 32- and 64-bit ones */
     { 274177, 67280421310721LLU, EXP_NONNULL, EXP_INT_OF },
 #endif
-
-    { SIZE_MAX / 4 * 3, SIZE_MAX / 2, EXP_OOM, EXP_INT_OF },
 };
 
 static const struct array_realloc_vector {