hardened_malloc/test/simple-memory-corruption/invalid_free_unprotected.c

15 lines
296 B
C
Raw Normal View History

2018-08-24 08:45:48 +00:00
#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;
}