Skip to content

Commit aaaa96a

Browse files
Merge pull request AFLplusplus#2280 from GAP-dev/dev
Fix macOS env optimization
2 parents eee4be9 + 2e2a3a2 commit aaaa96a

File tree

5 files changed

+26
-3
lines changed

5 files changed

+26
-3
lines changed

src/afl-analyze.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -695,22 +695,27 @@ static void set_up_environment(char **argv) {
695695
ck_free(frida_binary);
696696

697697
setenv("LD_PRELOAD", frida_afl_preload, 1);
698+
#ifdef __APPLE__
698699
setenv("DYLD_INSERT_LIBRARIES", frida_afl_preload, 1);
699-
700+
#endif
700701
} else {
701702

702703
/* CoreSight mode uses the default behavior. */
703704

704705
setenv("LD_PRELOAD", getenv("AFL_PRELOAD"), 1);
706+
#ifdef __APPLE__
705707
setenv("DYLD_INSERT_LIBRARIES", getenv("AFL_PRELOAD"), 1);
708+
#endif
706709

707710
}
708711

709712
} else if (frida_mode) {
710713

711714
u8 *frida_binary = find_afl_binary(argv[0], "afl-frida-trace.so");
712715
setenv("LD_PRELOAD", frida_binary, 1);
716+
#ifdef __APPLE__
713717
setenv("DYLD_INSERT_LIBRARIES", frida_binary, 1);
718+
#endif
714719
ck_free(frida_binary);
715720

716721
}

src/afl-fuzz.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1965,16 +1965,19 @@ int main(int argc, char **argv_orig, char **envp) {
19651965
ck_free(frida_binary);
19661966

19671967
setenv("LD_PRELOAD", frida_afl_preload, 1);
1968+
#ifdef __APPLE__
19681969
setenv("DYLD_INSERT_LIBRARIES", frida_afl_preload, 1);
1969-
1970+
#endif
19701971
}
19711972

19721973
} else {
19731974

19741975
/* CoreSight mode uses the default behavior. */
19751976

19761977
setenv("LD_PRELOAD", getenv("AFL_PRELOAD"), 1);
1978+
#ifdef __APPLE__
19771979
setenv("DYLD_INSERT_LIBRARIES", getenv("AFL_PRELOAD"), 1);
1980+
#endif
19781981

19791982
}
19801983

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

19982003
}

src/afl-showmap.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -740,22 +740,28 @@ static void set_up_environment(afl_forkserver_t *fsrv, char **argv) {
740740
ck_free(frida_binary);
741741

742742
setenv("LD_PRELOAD", frida_afl_preload, 1);
743+
#ifdef __APPLE__
743744
setenv("DYLD_INSERT_LIBRARIES", frida_afl_preload, 1);
745+
#endif
744746

745747
} else {
746748

747749
/* CoreSight mode uses the default behavior. */
748750

749751
setenv("LD_PRELOAD", getenv("AFL_PRELOAD"), 1);
752+
#ifdef __APPLE__
750753
setenv("DYLD_INSERT_LIBRARIES", getenv("AFL_PRELOAD"), 1);
754+
#endif
751755

752756
}
753757

754758
} else if (fsrv->frida_mode) {
755759

756760
u8 *frida_binary = find_afl_binary(argv[0], "afl-frida-trace.so");
757761
setenv("LD_PRELOAD", frida_binary, 1);
762+
#ifdef __APPLE__
758763
setenv("DYLD_INSERT_LIBRARIES", frida_binary, 1);
764+
#endif
759765
ck_free(frida_binary);
760766

761767
}

src/afl-tmin.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -714,22 +714,28 @@ static void set_up_environment(afl_forkserver_t *fsrv, char **argv) {
714714
ck_free(frida_binary);
715715

716716
setenv("LD_PRELOAD", frida_afl_preload, 1);
717+
#ifdef __APPLE__
717718
setenv("DYLD_INSERT_LIBRARIES", frida_afl_preload, 1);
719+
#endif
718720

719721
} else {
720722

721723
/* CoreSight mode uses the default behavior. */
722724

723725
setenv("LD_PRELOAD", getenv("AFL_PRELOAD"), 1);
726+
#ifdef __APPLE__
724727
setenv("DYLD_INSERT_LIBRARIES", getenv("AFL_PRELOAD"), 1);
728+
#endif
725729

726730
}
727731

728732
} else if (fsrv->frida_mode) {
729733

730734
u8 *frida_binary = find_afl_binary(argv[0], "afl-frida-trace.so");
731735
setenv("LD_PRELOAD", frida_binary, 1);
736+
#ifdef __APPLE__
732737
setenv("DYLD_INSERT_LIBRARIES", frida_binary, 1);
738+
#endif
733739
ck_free(frida_binary);
734740

735741
}

utils/afl_network_proxy/afl-network-server.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,9 @@ static void set_up_environment(afl_forkserver_t *fsrv) {
233233
} else {
234234

235235
setenv("LD_PRELOAD", getenv("AFL_PRELOAD"), 1);
236+
#ifdef __APPLE__
236237
setenv("DYLD_INSERT_LIBRARIES", getenv("AFL_PRELOAD"), 1);
237-
238+
#endif
238239
}
239240

240241
}

0 commit comments

Comments
 (0)