mirror of
https://github.com/AFLplusplus/AFLplusplus.git
synced 2025-06-13 02:28:09 +00:00
Move comment about adding 8 bytes to buffer length to the line where we
actually add 8 bytes Remove defunct TODO for posix_memalign as the function now exists Add wrapper for malloc_usable_size
This commit is contained in:
committed by
Dominik Maier
parent
45ccc7d475
commit
ee238eb00d
@ -183,6 +183,9 @@ static void *__dislocator_alloc(size_t len) {
|
|||||||
else
|
else
|
||||||
rlen = len;
|
rlen = len;
|
||||||
|
|
||||||
|
/* We will also store buffer length and a canary below the actual buffer, so
|
||||||
|
let's add 8 bytes for that. */
|
||||||
|
|
||||||
tlen = (1 + PG_COUNT(rlen + 8)) * PAGE_SIZE;
|
tlen = (1 + PG_COUNT(rlen + 8)) * PAGE_SIZE;
|
||||||
flags = MAP_PRIVATE | MAP_ANONYMOUS;
|
flags = MAP_PRIVATE | MAP_ANONYMOUS;
|
||||||
fd = -1;
|
fd = -1;
|
||||||
@ -200,9 +203,6 @@ static void *__dislocator_alloc(size_t len) {
|
|||||||
(void)sp;
|
(void)sp;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* We will also store buffer length and a canary below the actual buffer, so
|
|
||||||
let's add 8 bytes for that. */
|
|
||||||
|
|
||||||
ret = (u8 *)mmap(NULL, tlen, PROT_READ | PROT_WRITE, flags, fd, 0);
|
ret = (u8 *)mmap(NULL, tlen, PROT_READ | PROT_WRITE, flags, fd, 0);
|
||||||
#if defined(USEHUGEPAGE)
|
#if defined(USEHUGEPAGE)
|
||||||
/* We try one more time with regular call */
|
/* We try one more time with regular call */
|
||||||
@ -296,10 +296,6 @@ void *calloc(size_t elem_len, size_t elem_cnt) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO: add a wrapper for posix_memalign, otherwise apps who use it,
|
|
||||||
will fail when freeing the memory.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* The wrapper for malloc(). Roughly the same, also clobbers the returned
|
/* The wrapper for malloc(). Roughly the same, also clobbers the returned
|
||||||
memory (unlike calloc(), malloc() is not guaranteed to return zeroed
|
memory (unlike calloc(), malloc() is not guaranteed to return zeroed
|
||||||
memory). */
|
memory). */
|
||||||
@ -468,6 +464,12 @@ void *reallocarray(void *ptr, size_t elem_len, size_t elem_cnt) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t malloc_usable_size(void *ptr) {
|
||||||
|
|
||||||
|
return PTR_L(ptr);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
__attribute__((constructor)) void __dislocator_init(void) {
|
__attribute__((constructor)) void __dislocator_init(void) {
|
||||||
|
|
||||||
u8 *tmp = (u8 *)getenv("AFL_LD_LIMIT_MB");
|
u8 *tmp = (u8 *)getenv("AFL_LD_LIMIT_MB");
|
||||||
@ -492,4 +494,3 @@ __attribute__((constructor)) void __dislocator_init(void) {
|
|||||||
align_allocations = !!getenv("AFL_ALIGNED_ALLOC");
|
align_allocations = !!getenv("AFL_ALIGNED_ALLOC");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user