aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvan Hauser <vh@thc.org>2020-04-24 10:32:00 +0200
committerGitHub <noreply@github.com>2020-04-24 10:32:00 +0200
commit4a593d04056ce37743f6922f7d0f0002a6b4e0d5 (patch)
treee412a9c3aa0b952402d38d1487d22fdb3f1e69eb
parentb6f9f4c436bc8c63f9039847d2a7b6e13da3515e (diff)
parent82b6b8c87e1bc5394349fd2931b306f671c4da1a (diff)
downloadafl++-4a593d04056ce37743f6922f7d0f0002a6b4e0d5.tar.gz
Merge pull request #331 from Mindavi/feature/fail-on-invalid-binary-name
afl-gcc and afl-clang: fail when binary name can't be used to determine build mode
-rw-r--r--gcc_plugin/afl-gcc-fast.c8
-rw-r--r--src/afl-gcc.c27
2 files changed, 29 insertions, 6 deletions
diff --git a/gcc_plugin/afl-gcc-fast.c b/gcc_plugin/afl-gcc-fast.c
index 0e51ee62..164c72c2 100644
--- a/gcc_plugin/afl-gcc-fast.c
+++ b/gcc_plugin/afl-gcc-fast.c
@@ -123,11 +123,17 @@ static void edit_params(u32 argc, char **argv) {
u8 *alt_cxx = getenv("AFL_CXX");
cc_params[0] = alt_cxx && *alt_cxx ? alt_cxx : (u8 *)AFL_GCC_CXX;
- } else {
+ } else if (!strcmp(name, "afl-gcc-fast")) {
u8 *alt_cc = getenv("AFL_CC");
cc_params[0] = alt_cc && *alt_cc ? alt_cc : (u8 *)AFL_GCC_CC;
+ } else {
+
+ fprintf(stderr, "Name of the binary: %s\n", argv[0]);
+ FATAL(
+ "Name of the binary is not a known name, expected afl-(gcc|g++)-fast");
+
}
char *fplugin_arg = alloc_printf("-fplugin=%s/afl-gcc-pass.so", obj_path);
diff --git a/src/afl-gcc.c b/src/afl-gcc.c
index 6c6bd1f1..ac6fdd62 100644
--- a/src/afl-gcc.c
+++ b/src/afl-gcc.c
@@ -149,11 +149,17 @@ static void edit_params(u32 argc, char **argv) {
u8 *alt_cxx = getenv("AFL_CXX");
cc_params[0] = alt_cxx && *alt_cxx ? alt_cxx : (u8 *)"clang++";
- } else {
+ } else if (!strcmp(name, "afl-clang")) {
u8 *alt_cc = getenv("AFL_CC");
cc_params[0] = alt_cc && *alt_cc ? alt_cc : (u8 *)"clang";
+ } else {
+
+ fprintf(stderr, "Name of the binary: %s\n", argv[0]);
+ FATAL(
+ "Name of the binary is not a known name, expected afl-clang(++)");
+
}
} else {
@@ -166,12 +172,17 @@ static void edit_params(u32 argc, char **argv) {
#ifdef __APPLE__
- if (!strcmp(name, "afl-g++"))
+ if (!strcmp(name, "afl-g++")) {
cc_params[0] = getenv("AFL_CXX");
- else if (!strcmp(name, "afl-gcj"))
+ } else if (!strcmp(name, "afl-gcj")) {
cc_params[0] = getenv("AFL_GCJ");
- else
+ } else if (!strcmp(name, "afl-gcc")) {
cc_params[0] = getenv("AFL_CC");
+ } else {
+ fprintf(stderr, "Name of the binary: %s\n", argv[0]);
+ FATAL(
+ "Name of the binary is not a known name, expected afl-gcc/g++/gcj");
+ }
if (!cc_params[0]) {
@@ -199,11 +210,17 @@ static void edit_params(u32 argc, char **argv) {
u8 *alt_cc = getenv("AFL_GCJ");
cc_params[0] = alt_cc && *alt_cc ? alt_cc : (u8 *)"gcj";
- } else {
+ } else if (!strcmp(name, "afl-gcc")) {
u8 *alt_cc = getenv("AFL_CC");
cc_params[0] = alt_cc && *alt_cc ? alt_cc : (u8 *)"gcc";
+ } else {
+
+ fprintf(stderr, "Name of the binary: %s\n", argv[0]);
+ FATAL(
+ "Name of the binary is not a known name, expected afl-gcc/g++/gcj");
+
}
#endif /* __APPLE__ */