Add env variable SHM_FUZZ_MAP_SIZE (#2430)

* Add env variable SHM_FUZZ_PAGE_SIZE to tell the forkserver about the max shm input size

* fix

* PAGE_SIZE->MAP_SIZE

* fix more nits

* More cleanup
This commit is contained in:
Dominik Maier
2025-05-16 12:14:58 +02:00
committed by GitHub
parent d6bb210410
commit 6dcd0aa089
6 changed files with 45 additions and 5 deletions

View File

@ -2917,11 +2917,16 @@ void setup_testcase_shmem(afl_state_t *afl) {
afl->shm_fuzz = ck_alloc(sizeof(sharedmem_t));
// we need to set the non-instrumented mode to not overwrite the SHM_ENV_VAR
u8 *map = afl_shm_init(afl->shm_fuzz, MAX_FILE + sizeof(u32), 1);
size_t shm_fuzz_map_size = SHM_FUZZ_MAP_SIZE_DEFAULT;
u8 *map = afl_shm_init(afl->shm_fuzz, shm_fuzz_map_size, 1);
afl->shm_fuzz->shmemfuzz_mode = 1;
if (!map) { FATAL("BUG: Zero return from afl_shm_init."); }
u8 *shm_fuzz_map_size_str = alloc_printf("%zu", shm_fuzz_map_size);
setenv(SHM_FUZZ_MAP_SIZE_ENV_VAR, shm_fuzz_map_size_str, 1);
ck_free(shm_fuzz_map_size_str);
#ifdef USEMMAP
setenv(SHM_FUZZ_ENV_VAR, afl->shm_fuzz->g_shm_file_path, 1);
#else