aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorvan Hauser <vh@thc.org>2023-08-04 21:13:07 +0000
committerGitHub <noreply@github.com>2023-08-04 21:13:07 +0000
commit2ce511353036efe7bd0c068c90fe7cf0ae20f670 (patch)
treebffd39d824f9197b34d739a63033a6b919faefce /src
parent738a6c07311a41515146c3adab04bce9336a160c (diff)
parent247d8539feb0dee3eab80586ee4e32292dc7ca78 (diff)
downloadafl++-2ce511353036efe7bd0c068c90fe7cf0ae20f670.tar.gz
Merge pull request #1822 from jschwartzentruber/nyx-log
Add AFL_NYX_LOG to redirect NYX hprintf messages to a file.
Diffstat (limited to 'src')
-rw-r--r--src/afl-forkserver.c19
-rw-r--r--src/afl-fuzz.c1
2 files changed, 20 insertions, 0 deletions
diff --git a/src/afl-forkserver.c b/src/afl-forkserver.c
index 717898d1..9da096f7 100644
--- a/src/afl-forkserver.c
+++ b/src/afl-forkserver.c
@@ -164,6 +164,8 @@ void afl_nyx_runner_kill(afl_forkserver_t *fsrv) {
}
+ if (fsrv->nyx_log_fd >= 0) { close(fsrv->nyx_log_fd); }
+
}
}
@@ -218,6 +220,7 @@ void afl_fsrv_init(afl_forkserver_t *fsrv) {
fsrv->nyx_bind_cpu_id = 0xFFFFFFFF;
fsrv->nyx_use_tmp_workdir = false;
fsrv->nyx_tmp_workdir_path = NULL;
+ fsrv->nyx_log_fd = -1;
#endif
// this structure needs default so we initialize it if this was not done
@@ -575,6 +578,22 @@ void afl_fsrv_start(afl_forkserver_t *fsrv, char **argv,
fsrv->nyx_handlers->nyx_config_set_input_buffer_write_protection(nyx_config,
true);
+ char *nyx_log_path = getenv("AFL_NYX_LOG");
+ if (nyx_log_path) {
+
+ fsrv->nyx_log_fd =
+ open(nyx_log_path, O_CREAT | O_TRUNC | O_WRONLY, DEFAULT_PERMISSION);
+ if (fsrv->nyx_log_fd < 0) {
+
+ NYX_PRE_FATAL(fsrv, "AFL_NYX_LOG path could not be written");
+
+ }
+
+ fsrv->nyx_handlers->nyx_config_set_hprintf_fd(nyx_config,
+ fsrv->nyx_log_fd);
+
+ }
+
if (fsrv->nyx_standalone) {
fsrv->nyx_handlers->nyx_config_set_process_role(nyx_config, StandAlone);
diff --git a/src/afl-fuzz.c b/src/afl-fuzz.c
index 3d7adf41..e1f93f0d 100644
--- a/src/afl-fuzz.c
+++ b/src/afl-fuzz.c
@@ -303,6 +303,7 @@ static void usage(u8 *argv0, int more_help) {
" Increase this value in case the crash reports are truncated.\n"
" Default value is 4096.\n"
"AFL_NYX_DISABLE_SNAPSHOT_MODE: disable snapshot mode (must be supported by the agent)\n"
+ "AFL_NYX_LOG: output NYX hprintf messages to another file\n"
"AFL_NYX_REUSE_SNAPSHOT: reuse an existing Nyx root snapshot\n"
DYN_COLOR