add MI_PADDING build option to add padding to each block to detect heap block overflows

This commit is contained in:
daan 2020-01-29 17:10:57 -08:00
parent 9a532037df
commit 5d212d688f
3 changed files with 57 additions and 8 deletions

View file

@ -10,6 +10,7 @@
static void double_free1();
static void double_free2();
static void corrupt_free();
static void block_overflow1();
int main() {
mi_version();
@ -18,6 +19,7 @@ int main() {
// double_free1();
// double_free2();
// corrupt_free();
// block_overflow1();
void* p1 = malloc(78);
void* p2 = malloc(24);
@ -41,6 +43,11 @@ int main() {
return 0;
}
static void block_overflow1() {
void* p = mi_malloc(16);
memset(p, 0, 17);
free(p);
}
// The double free samples come ArcHeap [1] by Insu Yun (issue #161)
// [1]: https://arxiv.org/pdf/1903.00503.pdf