Fix/remove flawed alignment-related overflow tests.
Fix/remove three related flawed tests that attempted to cause OOM due to large request size and alignment constraint. Although these tests "passed" on 64-bit systems due to the virtual memory hole, they could pass on some 32-bit systems.
This commit is contained in:
parent
2b51a3e9e9
commit
a184d3fcde
@ -47,10 +47,10 @@ TEST_BEGIN(test_oom_errors)
|
||||
|
||||
#if LG_SIZEOF_PTR == 3
|
||||
alignment = UINT64_C(0x4000000000000000);
|
||||
size = UINT64_C(0x8400000000000001);
|
||||
size = UINT64_C(0xc000000000000001);
|
||||
#else
|
||||
alignment = 0x40000000LU;
|
||||
size = 0x84000001LU;
|
||||
size = 0xc0000001LU;
|
||||
#endif
|
||||
set_errno(0);
|
||||
p = aligned_alloc(alignment, size);
|
||||
|
@ -34,26 +34,6 @@ TEST_BEGIN(test_basic)
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_alignment_errors)
|
||||
{
|
||||
void *p;
|
||||
size_t nsz, sz, alignment;
|
||||
|
||||
#if LG_SIZEOF_PTR == 3
|
||||
alignment = UINT64_C(0x4000000000000000);
|
||||
sz = UINT64_C(0x8400000000000001);
|
||||
#else
|
||||
alignment = 0x40000000LU;
|
||||
sz = 0x84000001LU;
|
||||
#endif
|
||||
nsz = nallocx(sz, MALLOCX_ALIGN(alignment));
|
||||
assert_zu_ne(nsz, 0, "Unexpected nallocx() error");
|
||||
p = mallocx(sz, MALLOCX_ALIGN(alignment));
|
||||
assert_ptr_null(p, "Expected error for mallocx(%zu, %#x)", sz,
|
||||
MALLOCX_ALIGN(alignment));
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_alignment_and_size)
|
||||
{
|
||||
size_t nsz, rsz, sz, alignment, total;
|
||||
@ -114,6 +94,5 @@ main(void)
|
||||
|
||||
return (test(
|
||||
test_basic,
|
||||
test_alignment_errors,
|
||||
test_alignment_and_size));
|
||||
}
|
||||
|
@ -43,10 +43,10 @@ TEST_BEGIN(test_oom_errors)
|
||||
|
||||
#if LG_SIZEOF_PTR == 3
|
||||
alignment = UINT64_C(0x4000000000000000);
|
||||
size = UINT64_C(0x8400000000000001);
|
||||
size = UINT64_C(0xc000000000000001);
|
||||
#else
|
||||
alignment = 0x40000000LU;
|
||||
size = 0x84000001LU;
|
||||
size = 0xc0000001LU;
|
||||
#endif
|
||||
assert_d_ne(posix_memalign(&p, alignment, size), 0,
|
||||
"Expected error for posix_memalign(&p, %zu, %zu)",
|
||||
|
Loading…
Reference in New Issue
Block a user