about summary refs log tree commit diff
path: root/src/afl-fuzz-init.c
diff options
context:
space:
mode:
authorhexcoder- <heiko@hexco.de>2020-12-29 10:25:48 +0100
committerhexcoder- <heiko@hexco.de>2020-12-29 10:25:48 +0100
commite9a306a50eee1444ae40b961fbc8d942541348ca (patch)
tree0717234c9c9e51681973ff1ffba387c84ead3d60 /src/afl-fuzz-init.c
parent107c79b84b7cd7d90e8f9e10b3a46fbafcae39eb (diff)
downloadafl++-e9a306a50eee1444ae40b961fbc8d942541348ca.tar.gz
fix localtime warnings from CodeQL
Diffstat (limited to 'src/afl-fuzz-init.c')
-rw-r--r--src/afl-fuzz-init.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/src/afl-fuzz-init.c b/src/afl-fuzz-init.c
index ec937f29..75c0384f 100644
--- a/src/afl-fuzz-init.c
+++ b/src/afl-fuzz-init.c
@@ -1668,19 +1668,20 @@ static void handle_existing_out_dir(afl_state_t *afl) {
   if (afl->in_place_resume && rmdir(fn)) {
 
     time_t     cur_t = time(0);
-    struct tm *t = localtime(&cur_t);
+    struct tm  t;
+    localtime_r(&cur_t, &t);
 
 #ifndef SIMPLE_FILES
 
     u8 *nfn = alloc_printf("%s.%04d-%02d-%02d-%02d:%02d:%02d", fn,
-                           t->tm_year + 1900, t->tm_mon + 1, t->tm_mday,
-                           t->tm_hour, t->tm_min, t->tm_sec);
+                           t.tm_year + 1900, t.tm_mon + 1, t.tm_mday,
+                           t.tm_hour, t.tm_min, t.tm_sec);
 
 #else
 
-    u8 *nfn = alloc_printf("%s_%04d%02d%02d%02d%02d%02d", fn, t->tm_year + 1900,
-                           t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min,
-                           t->tm_sec);
+    u8 *nfn = alloc_printf("%s_%04d%02d%02d%02d%02d%02d", fn, t.tm_year + 1900,
+                           t.tm_mon + 1, t.tm_mday, t.tm_hour, t.tm_min,
+                           t.tm_sec);
 
 #endif                                                    /* ^!SIMPLE_FILES */
 
@@ -1699,19 +1700,20 @@ static void handle_existing_out_dir(afl_state_t *afl) {
   if (afl->in_place_resume && rmdir(fn)) {
 
     time_t     cur_t = time(0);
-    struct tm *t = localtime(&cur_t);
+    struct tm  t;
+    localtime_r(&cur_t, &t);
 
 #ifndef SIMPLE_FILES
 
     u8 *nfn = alloc_printf("%s.%04d-%02d-%02d-%02d:%02d:%02d", fn,
-                           t->tm_year + 1900, t->tm_mon + 1, t->tm_mday,
-                           t->tm_hour, t->tm_min, t->tm_sec);
+                           t.tm_year + 1900, t.tm_mon + 1, t.tm_mday,
+                           t.tm_hour, t.tm_min, t.tm_sec);
 
 #else
 
-    u8 *nfn = alloc_printf("%s_%04d%02d%02d%02d%02d%02d", fn, t->tm_year + 1900,
-                           t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min,
-                           t->tm_sec);
+    u8 *nfn = alloc_printf("%s_%04d%02d%02d%02d%02d%02d", fn, t.tm_year + 1900,
+                           t.tm_mon + 1, t.tm_mday, t.tm_hour, t.tm_min,
+                           t.tm_sec);
 
 #endif                                                    /* ^!SIMPLE_FILES */