Use thread safe localtime_r() instead of localtime() 82/233882/2 submit/tizen/20200520.224506
authorNishant Chaprana <n.chaprana@samsung.com>
Wed, 20 May 2020 04:40:02 +0000 (10:10 +0530)
committerNishant Chaprana <n.chaprana@samsung.com>
Wed, 20 May 2020 04:53:55 +0000 (10:23 +0530)
Change-Id: I21375288846a67bdb6db1d128ca2373a89269615
Signed-off-by: Nishant Chaprana <n.chaprana@samsung.com>
packaging/stc-iptables.spec
src/helper/helper-log.c

index 031151a..75a1c4e 100644 (file)
@@ -1,6 +1,6 @@
 Name:       stc-iptables
 Summary:    STC(Smart Traffic Control) iptables
-Version:    0.0.25
+Version:    0.0.26
 Release:    0
 Group:      Network & Connectivity/Other
 License:    GPL-2.0 and Apache-2.0
index 6f629bf..2dbc87b 100755 (executable)
@@ -75,14 +75,14 @@ static void __stc_iptables_log_make_backup(void)
 
 static void __stc_iptables_log_get_local_time(char *strtime, const int size)
 {
-       struct timeval tv;
-       struct tm *local_ptm;
        char buf[32];
+       struct timeval tv;
+       struct tm result = {0, };
 
        gettimeofday(&tv, NULL);
-       local_ptm = localtime(&tv.tv_sec);
 
-       strftime(buf, sizeof(buf), "%m/%d %H:%M:%S", local_ptm);
+       strftime(buf, sizeof(buf), "%m/%d %H:%M:%S",
+                localtime_r(&tv.tv_sec, &result));
        snprintf(strtime, size, "%s.%03ld", buf, tv.tv_usec / 1000);
 }