add simple overflow tests

This commit is contained in:
Daniel Micay committed 2018-09-04 09:15:23 -04:00
1 parent 1a7b8079d0
commit 5017500a47
3 files changed
+26

No files matched your search

+2
View File
@@ -18,6 +18,8 @@ EXECUTABLES := \
uninitialized_free \
uninitialized_realloc \
uninitialized_malloc_usable_size \
eight_byte_overflow_small \
eight_byte_overflow_large \
all: $(EXECUTABLES)
@@ -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;
}
@@ -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;
}