Loading...
--- libmalloc/libmalloc-374.40.6/tests/pgm_integration.c
+++ libmalloc/libmalloc-409.81.2/tests/pgm_integration.c
@@ -13,6 +13,8 @@
#include <malloc/malloc.h>
#include <stdlib.h>
#include <unistd.h>
+
+#include "../src/platform.h" // CONFIG_PGM_WRAP_CUSTOM_ZONES
T_GLOBAL_META(
T_META_ENVVAR("MallocProbGuard=1"),
@@ -82,7 +84,7 @@
T_ASSERT_EQ(malloc_size(ptr), 5ul, "strict alignment");
touch_memory(ptr - 1); // left-alignment is always perfect
- touch_memory(ptr + 6);
+ touch_memory(ptr + 5);
}
T_DECL(uaf_detection, "Use-after-free detection",
@@ -104,7 +106,11 @@
T_META_ENVVAR("MallocProbGuardAllocations=300"),
T_META_ENVVAR("MallocProbGuardStrictAlignment=1"))
{
+#if __LP64__ // MALLOC_TARGET_64BIT
assert_crash(out_of_bounds_within_block);
+#else
+ T_SKIP("ARM (32 bit) crashes on misaligned memory accesses: EXC_ARM_DA_ALIGN");
+#endif
}
static boolean_t
@@ -309,9 +315,13 @@
uint32_t num_zones = malloc_num_zones;
malloc_zone_t *zone = malloc_create_zone(0, 0);
+#if CONFIG_PGM_WRAP_CUSTOM_ZONES
T_EXPECT_EQ_STR(malloc_get_zone_name(zone), "ProbGuardMallocZone", "PGM-wrapped zone");
T_EXPECT_EQ(malloc_num_zones, num_zones + 2, "registered both zones");
malloc_destroy_zone(zone);
T_EXPECT_EQ(malloc_num_zones, num_zones, "unregistered both zones");
-}
+#else
+ T_EXPECT_EQ(malloc_num_zones, num_zones + 1, "no PGM wrapper zone");
+#endif
+}