mirror of
https://github.com/GrapheneOS/hardened_malloc.git
synced 2024-12-25 07:29:33 -05:00
improve write-after-free tests
This commit is contained in:
parent
3751b85e47
commit
918f0d3302
@ -1,4 +1,3 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
@ -9,6 +8,6 @@ int main(void) {
|
||||
return 1;
|
||||
}
|
||||
free(p);
|
||||
memset(p, 'a', 128 * 1024);
|
||||
p[64 * 1024 + 1] = 'a';
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,14 +1,19 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
__attribute__((optimize(0)))
|
||||
int main(void) {
|
||||
char *p = malloc(16);
|
||||
char *p = malloc(128);
|
||||
if (!p) {
|
||||
return 1;
|
||||
}
|
||||
free(p);
|
||||
memset(p, 'a', 16);
|
||||
|
||||
p[65] = 'a';
|
||||
|
||||
// trigger reuse of the allocation
|
||||
for (size_t i = 0; i < 100000; i++) {
|
||||
free(malloc(128));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user