aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/afl-analyze.c3
-rw-r--r--src/afl-common.c37
-rw-r--r--src/afl-fuzz.c4
-rw-r--r--src/afl-showmap.c4
-rw-r--r--src/afl-tmin.c3
5 files changed, 47 insertions, 4 deletions
diff --git a/src/afl-analyze.c b/src/afl-analyze.c
index 3de8c037..6816f6c8 100644
--- a/src/afl-analyze.c
+++ b/src/afl-analyze.c
@@ -863,7 +863,7 @@ static void find_binary(u8* fname) {
/* Main entry point */
-int main(int argc, char** argv) {
+int main(int argc, char** argv, char** envp) {
s32 opt;
u8 mem_limit_given = 0, timeout_given = 0, unicorn_mode = 0, use_wine = 0;
@@ -985,6 +985,7 @@ int main(int argc, char** argv) {
use_hex_offsets = !!getenv("AFL_ANALYZE_HEX");
+ check_environment_vars(envp);
setup_shm(0);
atexit(at_exit_handler);
setup_signal_handlers();
diff --git a/src/afl-common.c b/src/afl-common.c
index 958b9b7d..fee520c9 100644
--- a/src/afl-common.c
+++ b/src/afl-common.c
@@ -29,6 +29,7 @@
#include "debug.h"
#include "alloc-inl.h"
+#include "envs.h"
/* Detect @@ in args. */
#ifndef __glibc__
@@ -276,3 +277,39 @@ char** get_wine_argv(u8* own_loc, char** argv, int argc) {
}
+void check_environment_vars(char** envp) {
+
+ int index = 0, found = 0;
+ char* env;
+ while ((env = envp[index++]) != NULL) {
+
+ if (strncmp(env, "ALF_", 4) == 0) {
+
+ WARNF("Potentially mistyped AFL environment variable: %s", env);
+ found++;
+
+ } else if (strncmp(env, "AFL_", 4) == 0) {
+
+ int i = 0, match = 0;
+ while (match == 0 && afl_environment_variables[i] != NULL)
+ if (strncmp(env, afl_environment_variables[i],
+ strlen(afl_environment_variables[i])) == 0 &&
+ env[strlen(afl_environment_variables[i])] == '=')
+ match = 1;
+ else
+ i++;
+ if (match == 0) {
+
+ WARNF("Mistyped AFL environment variable: %s", env);
+ found++;
+
+ }
+
+ }
+
+ }
+
+ if (found) sleep(2);
+
+}
+
diff --git a/src/afl-fuzz.c b/src/afl-fuzz.c
index 8e4b22b1..e995a7a0 100644
--- a/src/afl-fuzz.c
+++ b/src/afl-fuzz.c
@@ -172,7 +172,7 @@ static int stricmp(char const* a, char const* b) {
/* Main entry point */
-int main(int argc, char** argv) {
+int main(int argc, char** argv, char** envp) {
s32 opt;
u64 prev_queued = 0;
@@ -609,6 +609,8 @@ int main(int argc, char** argv) {
OKF("afl-tmin fork server patch from github.com/nccgroup/TriforceAFL");
OKF("MOpt Mutator from github.com/puppet-meteor/MOpt-AFL");
+ check_environment_vars(envp);
+
if (fixed_seed) OKF("Running with fixed seed: %u", (u32)init_seed);
srandom((u32)init_seed);
diff --git a/src/afl-showmap.c b/src/afl-showmap.c
index 1fd425a2..99022983 100644
--- a/src/afl-showmap.c
+++ b/src/afl-showmap.c
@@ -712,7 +712,7 @@ static void find_binary(u8* fname) {
/* Main entry point */
-int main(int argc, char** argv) {
+int main(int argc, char** argv, char** envp) {
s32 opt, i;
u8 mem_limit_given = 0, timeout_given = 0, unicorn_mode = 0, use_wine = 0;
@@ -882,6 +882,8 @@ int main(int argc, char** argv) {
if (optind == argc || !out_file) usage(argv[0]);
+ check_environment_vars(envp);
+
setup_shm(0);
setup_signal_handlers();
diff --git a/src/afl-tmin.c b/src/afl-tmin.c
index e783b5f0..d1e87be1 100644
--- a/src/afl-tmin.c
+++ b/src/afl-tmin.c
@@ -1056,7 +1056,7 @@ static void read_bitmap(u8* fname) {
/* Main entry point */
-int main(int argc, char** argv) {
+int main(int argc, char** argv, char** envp) {
s32 opt;
u8 mem_limit_given = 0, timeout_given = 0, unicorn_mode = 0, use_wine = 0;
@@ -1208,6 +1208,7 @@ int main(int argc, char** argv) {
if (optind == argc || !in_file || !output_file) usage(argv[0]);
+ check_environment_vars(envp);
setup_shm(0);
atexit(at_exit_handler);
setup_signal_handlers();