add simple overflow tests
This commit is contained in:
parent
1a7b8079d0
commit
5017500a47
@ -18,6 +18,8 @@ EXECUTABLES := \
|
|||||||
uninitialized_free \
|
uninitialized_free \
|
||||||
uninitialized_realloc \
|
uninitialized_realloc \
|
||||||
uninitialized_malloc_usable_size \
|
uninitialized_malloc_usable_size \
|
||||||
|
eight_byte_overflow_small \
|
||||||
|
eight_byte_overflow_large \
|
||||||
|
|
||||||
all: $(EXECUTABLES)
|
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