Skip to content

Commit

Permalink
Merge pull request AFLplusplus#2280 from GAP-dev/dev
Browse files Browse the repository at this point in the history
Fix macOS env optimization
  • Loading branch information
vanhauser-thc authored Dec 28, 2024
2 parents eee4be9 + 2e2a3a2 commit aaaa96a
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/afl-analyze.c
Original file line number Diff line number Diff line change
Expand Up @@ -695,22 +695,27 @@ static void set_up_environment(char **argv) {
ck_free(frida_binary);

setenv("LD_PRELOAD", frida_afl_preload, 1);
#ifdef __APPLE__
setenv("DYLD_INSERT_LIBRARIES", frida_afl_preload, 1);

#endif
} else {

/* CoreSight mode uses the default behavior. */

setenv("LD_PRELOAD", getenv("AFL_PRELOAD"), 1);
#ifdef __APPLE__
setenv("DYLD_INSERT_LIBRARIES", getenv("AFL_PRELOAD"), 1);
#endif

}

} else if (frida_mode) {

u8 *frida_binary = find_afl_binary(argv[0], "afl-frida-trace.so");
setenv("LD_PRELOAD", frida_binary, 1);
#ifdef __APPLE__
setenv("DYLD_INSERT_LIBRARIES", frida_binary, 1);
#endif
ck_free(frida_binary);

}
Expand Down
7 changes: 6 additions & 1 deletion src/afl-fuzz.c
Original file line number Diff line number Diff line change
Expand Up @@ -1965,16 +1965,19 @@ int main(int argc, char **argv_orig, char **envp) {
ck_free(frida_binary);

setenv("LD_PRELOAD", frida_afl_preload, 1);
#ifdef __APPLE__
setenv("DYLD_INSERT_LIBRARIES", frida_afl_preload, 1);

#endif
}

} else {

/* CoreSight mode uses the default behavior. */

setenv("LD_PRELOAD", getenv("AFL_PRELOAD"), 1);
#ifdef __APPLE__
setenv("DYLD_INSERT_LIBRARIES", getenv("AFL_PRELOAD"), 1);
#endif

}

Expand All @@ -1992,7 +1995,9 @@ int main(int argc, char **argv_orig, char **envp) {
u8 *frida_binary = find_afl_binary(argv[0], "afl-frida-trace.so");
OKF("Injecting %s ...", frida_binary);
setenv("LD_PRELOAD", frida_binary, 1);
#ifdef __APPLE__
setenv("DYLD_INSERT_LIBRARIES", frida_binary, 1);
#endif
ck_free(frida_binary);

}
Expand Down
6 changes: 6 additions & 0 deletions src/afl-showmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -740,22 +740,28 @@ static void set_up_environment(afl_forkserver_t *fsrv, char **argv) {
ck_free(frida_binary);

setenv("LD_PRELOAD", frida_afl_preload, 1);
#ifdef __APPLE__
setenv("DYLD_INSERT_LIBRARIES", frida_afl_preload, 1);
#endif

} else {

/* CoreSight mode uses the default behavior. */

setenv("LD_PRELOAD", getenv("AFL_PRELOAD"), 1);
#ifdef __APPLE__
setenv("DYLD_INSERT_LIBRARIES", getenv("AFL_PRELOAD"), 1);
#endif

}

} else if (fsrv->frida_mode) {

u8 *frida_binary = find_afl_binary(argv[0], "afl-frida-trace.so");
setenv("LD_PRELOAD", frida_binary, 1);
#ifdef __APPLE__
setenv("DYLD_INSERT_LIBRARIES", frida_binary, 1);
#endif
ck_free(frida_binary);

}
Expand Down
6 changes: 6 additions & 0 deletions src/afl-tmin.c
Original file line number Diff line number Diff line change
Expand Up @@ -714,22 +714,28 @@ static void set_up_environment(afl_forkserver_t *fsrv, char **argv) {
ck_free(frida_binary);

setenv("LD_PRELOAD", frida_afl_preload, 1);
#ifdef __APPLE__
setenv("DYLD_INSERT_LIBRARIES", frida_afl_preload, 1);
#endif

} else {

/* CoreSight mode uses the default behavior. */

setenv("LD_PRELOAD", getenv("AFL_PRELOAD"), 1);
#ifdef __APPLE__
setenv("DYLD_INSERT_LIBRARIES", getenv("AFL_PRELOAD"), 1);
#endif

}

} else if (fsrv->frida_mode) {

u8 *frida_binary = find_afl_binary(argv[0], "afl-frida-trace.so");
setenv("LD_PRELOAD", frida_binary, 1);
#ifdef __APPLE__
setenv("DYLD_INSERT_LIBRARIES", frida_binary, 1);
#endif
ck_free(frida_binary);

}
Expand Down
3 changes: 2 additions & 1 deletion utils/afl_network_proxy/afl-network-server.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,9 @@ static void set_up_environment(afl_forkserver_t *fsrv) {
} else {

setenv("LD_PRELOAD", getenv("AFL_PRELOAD"), 1);
#ifdef __APPLE__
setenv("DYLD_INSERT_LIBRARIES", getenv("AFL_PRELOAD"), 1);

#endif
}

}
Expand Down

0 comments on commit aaaa96a

Please sign in to comment.