From 96591f3118e46fe449201a3125b4c2c777aed4cf Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Fri, 2 Dec 2016 21:32:18 -0800 Subject: [PATCH] Replace ctime with _r variant --- include/common.h | 1 + src/status.c | 8 ++++++-- src/terminal.c | 6 ++++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/include/common.h b/include/common.h index 58312f2cb..fe50ef80a 100644 --- a/include/common.h +++ b/include/common.h @@ -17,6 +17,7 @@ #elif defined (_WIN32) || defined (_WIN64) #define _WIN 1 #define WIN 1 +#define _POSIX_THREAD_SAFE_FUNCTIONS 200112L //for *time_r functions #else #error Your Operating System is not supported or detected #endif diff --git a/src/status.c b/src/status.c index 486f6743b..aebbbc9e8 100644 --- a/src/status.c +++ b/src/status.c @@ -844,7 +844,9 @@ char *status_get_time_started_absolute (const hashcat_ctx_t *hashcat_ctx) const time_t time_start = status_ctx->runtime_start; - char *start = ctime (&time_start); + char buf; + + char *start = ctime_r (&time_start, &buf); const size_t start_len = strlen (start); @@ -934,7 +936,9 @@ char *status_get_time_estimated_absolute (const hashcat_ctx_t *hashcat_ctx) now += sec_etc; - char *etc = ctime (&now); + char buf; + + char *etc = ctime_r (&now, &buf); const size_t etc_len = strlen (etc); diff --git a/src/terminal.c b/src/terminal.c index 2b161482e..b09fc35c9 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -70,8 +70,10 @@ void goodbye_screen (hashcat_ctx_t *hashcat_ctx, const time_t proc_start, const if (user_options->show == true) return; if (user_options->left == true) return; - event_log_info_nn (hashcat_ctx, "Started: %s", ctime (&proc_start)); - event_log_info_nn (hashcat_ctx, "Stopped: %s", ctime (&proc_stop)); + char start_buf, stop_buf; + + event_log_info_nn (hashcat_ctx, "Started: %s", ctime_r (&proc_start, &start_buf)); + event_log_info_nn (hashcat_ctx, "Stopped: %s", ctime_r (&proc_stop, &stop_buf)); } int setup_console ()