diff options
author | vanhauser-thc <vh@thc.org> | 2021-03-24 20:02:58 +0100 |
---|---|---|
committer | vanhauser-thc <vh@thc.org> | 2021-03-24 20:02:58 +0100 |
commit | d319b4a3819052de5bf576c560da6e4687c31de9 (patch) | |
tree | a4c7f4af226ac4eeddabf0eddb5f3ef1782578ee | |
parent | 7dc48478698ba73eeb045af3ca25e4a62e68b359 (diff) | |
download | afl++-d319b4a3819052de5bf576c560da6e4687c31de9.tar.gz |
support libraries for find_afl_binary
-rw-r--r-- | src/afl-common.c | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/src/afl-common.c b/src/afl-common.c index 1f9839a2..087aa113 100644 --- a/src/afl-common.c +++ b/src/afl-common.c @@ -282,12 +282,19 @@ u8 *find_binary(u8 *fname) { u8 *find_afl_binary(u8 *own_loc, u8 *fname) { - u8 *afl_path = NULL, *target_path, *own_copy; + u8 *afl_path = NULL, *target_path, *own_copy, *tmp; + int perm = X_OK; + + if ((tmp = strrchr(fname, '.'))) { + + if (!strcasecmp(tmp, ".so") || !strcasecmp(tmp, ".dylib")) { perm = R_OK; } + + } if ((afl_path = getenv("AFL_PATH"))) { target_path = alloc_printf("%s/%s", afl_path, fname); - if (!access(target_path, X_OK)) { + if (!access(target_path, perm)) { return target_path; @@ -311,7 +318,7 @@ u8 *find_afl_binary(u8 *own_loc, u8 *fname) { target_path = alloc_printf("%s/%s", own_copy, fname); ck_free(own_copy); - if (!access(target_path, X_OK)) { + if (!access(target_path, perm)) { return target_path; @@ -330,7 +337,7 @@ u8 *find_afl_binary(u8 *own_loc, u8 *fname) { } target_path = alloc_printf("%s/%s", BIN_PATH, fname); - if (!access(target_path, X_OK)) { + if (!access(target_path, perm)) { return target_path; @@ -340,7 +347,15 @@ u8 *find_afl_binary(u8 *own_loc, u8 *fname) { } - return find_binary(fname); + if (perm == X_OK) { + + return find_binary(fname); + + } else { + + FATAL("Library '%s' not found", fname); + + } } |