summaryrefslogtreecommitdiff
path: root/imc/checker.c
diff options
context:
space:
mode:
authorMatthew Sotoudeh <matthew@masot.net>2024-05-16 19:31:52 -0700
committerMatthew Sotoudeh <matthew@masot.net>2024-05-16 19:31:52 -0700
commit2e7e1c12a74c64c1f908e7f071af8d2286537e95 (patch)
tree426efcb9ce75bd1e9e3b6ba46835a58e66e24537 /imc/checker.c
parent1239703a2ac39250800eb5ee5819efd98e9876c9 (diff)
check "reserve", fix bugs
Diffstat (limited to 'imc/checker.c')
-rw-r--r--imc/checker.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/imc/checker.c b/imc/checker.c
index 2bde59f..2ddf978 100644
--- a/imc/checker.c
+++ b/imc/checker.c
@@ -42,6 +42,17 @@ void check_main() {
get_random(magic, MAGIC_COOKIE_BYTES);
init_buddy(pool, pool_size, magic, curr_buddy);
+ void *redzone_start = 0;
+ void *redzone_end = 0;
+ if (choose(2, 0)) {
+ redzone_start = (uint8_t*)pool + 1365;
+ redzone_end = (uint8_t*)redzone_start + (1024 * 2);
+ verbose("Reserving %p -- %p\n", redzone_start, redzone_end);
+ assert(reserve(redzone_start,
+ (uint8_t*)redzone_end - (uint8_t*)redzone_start,
+ curr_buddy));
+ }
+
size_t size_options[] = {1, 128, 1024, 5, 167, 10500};
const size_t n_size_options = sizeof(size_options) / sizeof(size_options[0]);
@@ -82,6 +93,7 @@ void check_main() {
p->data_size = size_options[action];
size_t new_size = p->data_size + sizeof(struct ll);
p = reallocate(p, new_size, old_size, curr_buddy);
+ assert(!(redzone_start <= (void*)p && (void*)p < redzone_end));
for (size_t i = 0; i < p->data_size; i++)
p->data[i] = (uint8_t)p->data_size;
int lifetime = choose(n_timesteps - t, 0) + 1;
@@ -97,6 +109,9 @@ void check_main() {
size_t size = size_options[choose(n_size_options, 0)];
struct ll *ll = allocate(size + sizeof(struct ll), curr_buddy);
if (!ll) continue;
+ verbose("Got allocation: %p\n", ll);
+ assert(!(redzone_start <= (void*)ll && (void*)ll < redzone_end));
+
assert((void*)ll >= pool);
assert((uint8_t*)ll + size + sizeof(struct ll)
< (uint8_t*)pool + pool_size);
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback