optimize a bit

This commit is contained in:
hexcoder-
2020-12-08 23:51:22 +01:00
parent 1dbb1c7193
commit a7125c68eb

View File

@ -248,6 +248,8 @@ u8 *afl_shm_init(sharedmem_t *shm, size_t map_size,
} }
if (!non_instrumented_mode) {
shm_str = alloc_printf("%d", shm->shm_id); shm_str = alloc_printf("%d", shm->shm_id);
/* If somebody is asking us to fuzz instrumented binaries in non-instrumented /* If somebody is asking us to fuzz instrumented binaries in non-instrumented
@ -255,15 +257,17 @@ u8 *afl_shm_init(sharedmem_t *shm, size_t map_size,
sending fork server commands. This should be replaced with better sending fork server commands. This should be replaced with better
auto-detection later on, perhaps? */ auto-detection later on, perhaps? */
if (!non_instrumented_mode) { setenv(SHM_ENV_VAR, shm_str, 1); } setenv(SHM_ENV_VAR, shm_str, 1);
ck_free(shm_str); ck_free(shm_str);
if (shm->cmplog_mode) { }
if (shm->cmplog_mode && !non_instrumented_mode) {
shm_str = alloc_printf("%d", shm->cmplog_shm_id); shm_str = alloc_printf("%d", shm->cmplog_shm_id);
if (!non_instrumented_mode) { setenv(CMPLOG_SHM_ENV_VAR, shm_str, 1); } setenv(CMPLOG_SHM_ENV_VAR, shm_str, 1);
ck_free(shm_str); ck_free(shm_str);
@ -274,6 +278,7 @@ u8 *afl_shm_init(sharedmem_t *shm, size_t map_size,
if (shm->map == (void *)-1 || !shm->map) { if (shm->map == (void *)-1 || !shm->map) {
shmctl(shm->shm_id, IPC_RMID, NULL); // do not leak shmem shmctl(shm->shm_id, IPC_RMID, NULL); // do not leak shmem
if (shm->cmplog_mode) { if (shm->cmplog_mode) {
shmctl(shm->cmplog_shm_id, IPC_RMID, NULL); // do not leak shmem shmctl(shm->cmplog_shm_id, IPC_RMID, NULL); // do not leak shmem
@ -291,12 +296,9 @@ u8 *afl_shm_init(sharedmem_t *shm, size_t map_size,
if (shm->cmp_map == (void *)-1 || !shm->cmp_map) { if (shm->cmp_map == (void *)-1 || !shm->cmp_map) {
shmctl(shm->shm_id, IPC_RMID, NULL); // do not leak shmem shmctl(shm->shm_id, IPC_RMID, NULL); // do not leak shmem
if (shm->cmplog_mode) {
shmctl(shm->cmplog_shm_id, IPC_RMID, NULL); // do not leak shmem shmctl(shm->cmplog_shm_id, IPC_RMID, NULL); // do not leak shmem
}
PFATAL("shmat() failed"); PFATAL("shmat() failed");
} }