From a184d3fcdecfaaf694029fb375d023882aea444e Mon Sep 17 00:00:00 2001 From: Jason Evans Date: Tue, 28 Jan 2014 18:02:07 -0800 Subject: [PATCH] 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. --- test/integration/aligned_alloc.c | 4 ++-- test/integration/mallocx.c | 21 --------------------- test/integration/posix_memalign.c | 4 ++-- 3 files changed, 4 insertions(+), 25 deletions(-) diff --git a/test/integration/aligned_alloc.c b/test/integration/aligned_alloc.c index 17c2151c..60900148 100644 --- a/test/integration/aligned_alloc.c +++ b/test/integration/aligned_alloc.c @@ -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); diff --git a/test/integration/mallocx.c b/test/integration/mallocx.c index c26f6c56..f37a74bc 100644 --- a/test/integration/mallocx.c +++ b/test/integration/mallocx.c @@ -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)); } diff --git a/test/integration/posix_memalign.c b/test/integration/posix_memalign.c index c88a4dcb..19741c6c 100644 --- a/test/integration/posix_memalign.c +++ b/test/integration/posix_memalign.c @@ -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)",