aboutsummaryrefslogtreecommitdiffstats
path: root/csource
diff options
context:
space:
mode:
authorAndrey Konovalov <andreyknvl@google.com>2017-05-18 20:24:41 +0200
committerAndrey Konovalov <andreyknvl@google.com>2017-06-12 19:48:23 +0200
commited6891f2edb833a3ba06dc656bb8cfe371d0bc6a (patch)
tree1c03b260340fb340fcca8c3628915734dcdaf90e /csource
parent19015af81522aa5d8aaa16d07306c48c3a61571e (diff)
csource: use tmp dir in repeat loop when tmpdir flag is on
Diffstat (limited to 'csource')
-rw-r--r--csource/common.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/csource/common.go b/csource/common.go
index 466e6de43..0d78bca5f 100644
--- a/csource/common.go
+++ b/csource/common.go
@@ -1760,7 +1760,7 @@ static int do_sandbox_namespace(int executor_pid, bool enable_tun)
}
#endif
-#if defined(SYZ_EXECUTOR) || (defined(SYZ_REPEAT) && defined(SYZ_WAIT_REPEAT))
+#if defined(SYZ_EXECUTOR) || (defined(SYZ_REPEAT) && defined(SYZ_WAIT_REPEAT) && defined(SYZ_USE_TMP_DIR))
static void remove_dir(const char* dir)
{
DIR* dp;
@@ -1841,7 +1841,9 @@ retry:
exitf("rmdir(%s) failed", dir);
}
}
+#endif
+#if defined(SYZ_EXECUTOR) || (defined(SYZ_REPEAT) && defined(SYZ_WAIT_REPEAT))
static uint64_t current_time_ms()
{
struct timespec ts;
@@ -1877,18 +1879,22 @@ void loop()
{
int iter;
for (iter = 0;; iter++) {
+#ifdef SYZ_USE_TMP_DIR
char cwdbuf[256];
sprintf(cwdbuf, "./%d", iter);
if (mkdir(cwdbuf, 0777))
fail("failed to mkdir");
+#endif
int pid = fork();
if (pid < 0)
fail("clone failed");
if (pid == 0) {
prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0);
setpgrp();
+#ifdef SYZ_USE_TMP_DIR
if (chdir(cwdbuf))
fail("failed to chdir");
+#endif
#ifdef SYZ_TUN_ENABLE
flush_tun();
#endif
@@ -1910,7 +1916,9 @@ void loop()
break;
}
}
+#ifdef SYZ_USE_TMP_DIR
remove_dir(cwdbuf);
+#endif
}
}
#else