mirror of
https://github.com/GrapheneOS/hardened_malloc.git
synced 2025-05-24 08:51:14 -04:00
add wrapper for mremap with sanity check
This commit is contained in:
parent
5bc6820c24
commit
1cb28531a8
3 changed files with 14 additions and 2 deletions
11
memory.c
11
memory.c
|
@ -31,3 +31,14 @@ int memory_protect(void *ptr, size_t size, int prot) {
|
|||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int memory_remap_fixed(void *old, size_t old_size, void *new, size_t new_size) {
|
||||
void *ptr = mremap(old, old_size, new_size, MREMAP_MAYMOVE|MREMAP_FIXED, new);
|
||||
if (unlikely(ptr == MAP_FAILED)) {
|
||||
if (errno != ENOMEM) {
|
||||
fatal_error("non-ENOMEM mremap failure");
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue