mirror of
https://github.com/GrapheneOS/hardened_malloc.git
synced 2024-12-21 05:44:29 -05:00
add simple overflow tests
This commit is contained in:
parent
1a7b8079d0
commit
5017500a47
@ -18,6 +18,8 @@ EXECUTABLES := \
|
||||
uninitialized_free \
|
||||
uninitialized_realloc \
|
||||
uninitialized_malloc_usable_size \
|
||||
eight_byte_overflow_small \
|
||||
eight_byte_overflow_large \
|
||||
|
||||
all: $(EXECUTABLES)
|
||||
|
||||
|
12
test/simple-memory-corruption/eight_byte_overflow_large.c
Normal file
12
test/simple-memory-corruption/eight_byte_overflow_large.c
Normal file
@ -0,0 +1,12 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
__attribute__((optimize(0)))
|
||||
int main(void) {
|
||||
char *p = malloc(128 * 1024);
|
||||
if (!p) {
|
||||
return 1;
|
||||
}
|
||||
*(p + 128 * 1024 + 7) = 0;
|
||||
free(p);
|
||||
return 0;
|
||||
}
|
12
test/simple-memory-corruption/eight_byte_overflow_small.c
Normal file
12
test/simple-memory-corruption/eight_byte_overflow_small.c
Normal file
@ -0,0 +1,12 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
__attribute__((optimize(0)))
|
||||
int main(void) {
|
||||
char *p = malloc(8);
|
||||
if (!p) {
|
||||
return 1;
|
||||
}
|
||||
*(p + 8 + 7) = 0;
|
||||
free(p);
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user