add basic invalid free tests
parent
97b693d862
commit
0a79e82474
|
@ -9,3 +9,6 @@ all: \
|
|||
write_after_free_small \
|
||||
read_zero_size \
|
||||
write_zero_size \
|
||||
invalid_free_protected \
|
||||
invalid_free_unprotected \
|
||||
invalid_free_small_region \
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
#include <sys/mman.h>
|
||||
|
||||
__attribute__((optimize(0)))
|
||||
int main(void) {
|
||||
free(malloc(16));
|
||||
char *p = mmap(NULL, 4096 * 16, PROT_NONE, MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
|
||||
if (p == MAP_FAILED) {
|
||||
return 1;
|
||||
}
|
||||
free(p + 4096 * 8);
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
__attribute__((optimize(0)))
|
||||
int main(void) {
|
||||
char *p = malloc(16);
|
||||
if (!p) {
|
||||
return 1;
|
||||
}
|
||||
char *q = p + 4096 * 4;
|
||||
free(q);
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
#include <sys/mman.h>
|
||||
|
||||
__attribute__((optimize(0)))
|
||||
int main(void) {
|
||||
free(malloc(16));
|
||||
char *p = mmap(NULL, 4096 * 16, PROT_READ|PROT_WRITE, MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
|
||||
if (p == MAP_FAILED) {
|
||||
return 1;
|
||||
}
|
||||
free(p + 4096 * 8);
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue