about summary refs log tree commit diff
diff options
context:
space:
mode:
authorvan Hauser <vh@thc.org>2020-04-09 13:17:56 +0200
committervan Hauser <vh@thc.org>2020-04-09 13:17:56 +0200
commit1fab45024ba2c9f39f63d0078ca35c4ffd52b035 (patch)
treee784c4b6f336a098052182bdee7b0f57573e4610
parente354235ebb46ab8451b96a1fd21003a37f59f86f (diff)
downloadafl++-1fab45024ba2c9f39f63d0078ca35c4ffd52b035.tar.gz
check for empty AFL env vars
-rw-r--r--src/afl-common.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/afl-common.c b/src/afl-common.c
index 73b3fa8a..7eee5265 100644
--- a/src/afl-common.c
+++ b/src/afl-common.c
@@ -353,7 +353,7 @@ void check_environment_vars(char **envp) {
   if (be_quiet) return;
 
   int   index = 0, found = 0;
-  char *env;
+  char *env, *val;
   while ((env = envp[index++]) != NULL) {
 
     if (strncmp(env, "ALF_", 4) == 0) {
@@ -367,10 +367,21 @@ void check_environment_vars(char **envp) {
       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])] == '=')
+            env[strlen(afl_environment_variables[i])] == '=') {
+
           match = 1;
-        else
+          if ((val = getenv(afl_environment_variables[i])) && !*val)
+            WARNF(
+                "AFL environment variable %s defined but is empty, this can "
+                "lead to unexpected consequences",
+                afl_environment_variables[i]);
+
+        } else {
+
           i++;
+
+        }
+
       if (match == 0) {
 
         WARNF("Mistyped AFL environment variable: %s", env);