mirror of
https://github.com/GrapheneOS/hardened_malloc.git
synced 2024-12-18 12:24:27 -05:00
use calculated size for overflow tests
This greatly reduces how much these tests depend on hard-wired knowledge about the size classes.
This commit is contained in:
parent
acda766e2c
commit
13a1f578cb
@ -7,7 +7,8 @@ OPTNONE int main(void) {
|
|||||||
if (!p) {
|
if (!p) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
*(p + 256 * 1024 + 7) = 0;
|
size_t size = malloc_usable_size(p);
|
||||||
|
*(p + size + 7) = 0;
|
||||||
free(p);
|
free(p);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,8 @@ OPTNONE int main(void) {
|
|||||||
if (!p) {
|
if (!p) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
*(p + 8 + 7) ^= 1;
|
size_t size = malloc_usable_size(p);
|
||||||
|
*(p + size + 7) ^= 1;
|
||||||
free(p);
|
free(p);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user