mirror of
https://github.com/GrapheneOS/hardened_malloc.git
synced 2025-05-02 14:26:32 -04: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
2 changed files with 4 additions and 2 deletions
|
@ -7,7 +7,8 @@ OPTNONE int main(void) {
|
|||
if (!p) {
|
||||
return 1;
|
||||
}
|
||||
*(p + 256 * 1024 + 7) = 0;
|
||||
size_t size = malloc_usable_size(p);
|
||||
*(p + size + 7) = 0;
|
||||
free(p);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -7,7 +7,8 @@ OPTNONE int main(void) {
|
|||
if (!p) {
|
||||
return 1;
|
||||
}
|
||||
*(p + 8 + 7) ^= 1;
|
||||
size_t size = malloc_usable_size(p);
|
||||
*(p + size + 7) ^= 1;
|
||||
free(p);
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue