fixed tiny nitpicks
MODIFY
docs/env_variables.md
docs/env_variables.md
@@ -426,7 +426,7 @@ checks or alter some of the more exotic semantics of the tool:
- If you are Jakub, you may need `AFL_I_DONT_CARE_ABOUT_MISSING_CRASHES`.
Others need not apply, unless they also want to disable the
- /proc/sys/kernel/core_pattern check.
+ `/proc/sys/kernel/core_pattern` check.
- Benchmarking only: `AFL_BENCH_JUST_ONE` causes the fuzzer to exit after
processing the first queue entry; and `AFL_BENCH_UNTIL_CRASH` causes it to

MODIFY
include/afl-fuzz.h
include/afl-fuzz.h
@@ -390,7 +390,7 @@ typedef struct afl_env_vars {
*afl_hang_tmout, *afl_forksrv_init_tmout, *afl_skip_crashes, *afl_preload,
*afl_max_det_extras, *afl_statsd_host, *afl_statsd_port,
*afl_crash_exitcode, *afl_statsd_tags_flavor, *afl_testcache_size,
- *afl_testcache_entries, *afl_kill_signal;
+ *afl_testcache_entries, *afl_kill_signal, *afl_target_env;
} afl_env_vars_t;

MODIFY
include/common.h
include/common.h
@@ -51,7 +51,7 @@ char * get_afl_env(char *env);
/* Extract env vars from input string and set them using setenv()
For use with AFL_TARGET_ENV, ... */
-u8 extract_and_set_env(u8 *env_str);
+bool extract_and_set_env(u8 *env_str);
extern u8 be_quiet;
extern u8 *doc_path; /* path to documentation dir */

MODIFY
src/afl-common.c
src/afl-common.c
@@ -618,19 +618,15 @@ char *get_afl_env(char *env) {
}
-u8 extract_and_set_env(u8 *env_str) {
+bool extract_and_set_env(u8 *env_str) {
- if (!env_str) { return 0; }
+ if (!env_str) { return false; }
- u8 *p = ck_strdup(env_str);
+ bool ret = false; // return false by default
+ u8 *p = ck_strdup(env_str);
u8 *end = p + strlen((char *)p);
-
- u8 ret_val = 0; // return false by default
-
u8 *rest = p;
- u8 *key = p;
- u8 *val = p;
u8 closing_sym = ' ';
u8 c;
@@ -647,7 +643,7 @@ u8 extract_and_set_env(u8 *env_str) {
if (rest + 1 >= end) break;
- key = rest;
+ u8 *key = rest;
// env variable names may not start with numbers or '='
if (*key == '=' || (*key >= '0' && *key <= '9')) { goto free_and_return; }
@@ -673,7 +669,7 @@ u8 extract_and_set_env(u8 *env_str) {
rest += 1;
if (rest >= end || *rest == ' ') { goto free_and_return; }
- val = rest;
+ u8 *val = rest;
if (*val == '\'' || *val == '"') {
closing_sym = *val;
@@ -700,17 +696,17 @@ u8 extract_and_set_env(u8 *env_str) {
rest += 1;
if (rest < end && *rest != ' ') { goto free_and_return; }
- num_pairs += 1;
+ num_pairs++;
setenv(key, val, 1);
}
- if (num_pairs > 0) { ret_val = 1; }
+ if (num_pairs) { ret = true; }
free_and_return:
ck_free(p);
- return ret_val;
+ return ret;
}

MODIFY
src/afl-fuzz-state.c
src/afl-fuzz-state.c
@@ -433,6 +433,13 @@ void read_afl_environment(afl_state_t *afl, char **envp) {
afl->afl_env.afl_kill_signal =
(u8 *)get_afl_env(afl_environment_variables[i]);
+ } else if (!strncmp(env, "AFL_TARGET_ENV",
+
+ afl_environment_variable_len)) {
+
+ afl->afl_env.afl_target_env =
+ (u8 *)get_afl_env(afl_environment_variables[i]);
+
}
} else {

MODIFY
src/afl-fuzz.c
src/afl-fuzz.c
@@ -1304,8 +1304,8 @@ int main(int argc, char **argv_orig, char **envp) {
}
- u8 *extra_env = (u8 *)getenv("AFL_TARGET_ENV");
- if (extra_env && !extract_and_set_env(extra_env)) {
+ if (afl->afl_env.afl_target_env &&
+ !extract_and_set_env(afl->afl_env.afl_target_env)) {
FATAL("Bad value of AFL_TARGET_ENV");

fixed tiny nitpicks