add simple overflow tests

pull/50/head
Daniel Micay 2018-09-04 09:06:23 -04:00
parent 1a7b8079d0
commit 5017500a47
3 changed files with 26 additions and 0 deletions

View File

@ -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)

View 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;
}

View 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;
}