diff --git a/src/backend.c b/src/backend.c index d6b15d891..b0469e8d7 100644 --- a/src/backend.c +++ b/src/backend.c @@ -371,8 +371,8 @@ static bool opencl_test_instruction (hashcat_ctx_t *hashcat_ctx, cl_context cont #ifndef DEBUG #ifndef _WIN fflush (stderr); - int bak = dup (2); - int tmp = open ("/dev/null", O_WRONLY); + int bak = fcntl(2, F_DUPFD_CLOEXEC); + int tmp = open ("/dev/null", O_WRONLY | O_CLOEXEC); dup2 (tmp, 2); close (tmp); #endif @@ -383,7 +383,11 @@ static bool opencl_test_instruction (hashcat_ctx_t *hashcat_ctx, cl_context cont #ifndef DEBUG #ifndef _WIN fflush (stderr); + #ifndef __APPLE__ + dup3 (bak, 2, O_CLOEXEC); + #else dup2 (bak, 2); + #endif close (bak); #endif #endif diff --git a/src/shared.c b/src/shared.c index b27dbdba1..f9d3a01ab 100644 --- a/src/shared.c +++ b/src/shared.c @@ -336,7 +336,11 @@ bool hc_path_create (const char *path) { if (hc_path_exist (path) == true) return false; - const int fd = creat (path, S_IRUSR | S_IWUSR); +#ifdef O_CLOEXEC + const int fd = open (path, O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, S_IRUSR | S_IWUSR); +#else + const int fd = open (path, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR); +#endif if (fd == -1) return false;