mirror of
https://github.com/AFLplusplus/AFLplusplus.git
synced 2025-06-14 02:58:08 +00:00
Add AFL_FORK_SERVER_KILL_SIGNAL environment variable.
The AFL_FORK_SERVER_KILL_SIGNAL variable allows to configure the signal used to kill the fork server on termination.
This commit is contained in:
@ -456,38 +456,24 @@ u8 *find_afl_binary(u8 *own_loc, u8 *fname) {
|
||||
|
||||
}
|
||||
|
||||
/* Parses the kill signal environment variable, FATALs on error.
|
||||
If the env is not set, sets the env to default_signal for the signal handlers
|
||||
and returns the default_signal. */
|
||||
int parse_afl_kill_signal_env(u8 *afl_kill_signal_env, int default_signal) {
|
||||
|
||||
if (afl_kill_signal_env && afl_kill_signal_env[0]) {
|
||||
int parse_afl_kill_signal(u8 *numeric_signal_as_str, int default_signal) {
|
||||
|
||||
if (numeric_signal_as_str && numeric_signal_as_str[0]) {
|
||||
|
||||
char *endptr;
|
||||
u8 signal_code;
|
||||
signal_code = (u8)strtoul(afl_kill_signal_env, &endptr, 10);
|
||||
signal_code = (u8)strtoul(numeric_signal_as_str, &endptr, 10);
|
||||
/* Did we manage to parse the full string? */
|
||||
if (*endptr != '\0' || endptr == (char *)afl_kill_signal_env) {
|
||||
|
||||
FATAL("Invalid AFL_KILL_SIGNAL: %s (expected unsigned int)",
|
||||
afl_kill_signal_env);
|
||||
|
||||
if (*endptr != '\0' || endptr == (char *)numeric_signal_as_str) {
|
||||
FATAL("Invalid signal name: %s", numeric_signal_as_str);
|
||||
} else {
|
||||
return signal_code;
|
||||
}
|
||||
|
||||
return signal_code;
|
||||
|
||||
} else {
|
||||
|
||||
char *sigstr = alloc_printf("%d", default_signal);
|
||||
if (!sigstr) { FATAL("Failed to alloc mem for signal buf"); }
|
||||
|
||||
/* Set the env for signal handler */
|
||||
setenv("AFL_KILL_SIGNAL", sigstr, 1);
|
||||
free(sigstr);
|
||||
return default_signal;
|
||||
|
||||
}
|
||||
|
||||
return default_signal;
|
||||
}
|
||||
|
||||
static inline unsigned int helper_min3(unsigned int a, unsigned int b,
|
||||
@ -1253,4 +1239,3 @@ s32 create_file(u8 *fn) {
|
||||
return fd;
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user