[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [torsocks/master] Use seconds since epoch, not local time, for log timestamps.
commit 35187508cfaf3fd21ed68159f4635ee2d376aea4
Author: Taylor R Campbell <campbell+torsocks@xxxxxxxxxx>
Date: Fri Jun 19 04:23:36 2015 +0000
Use seconds since epoch, not local time, for log timestamps.
Local time may require opening files to load the time zone database, which
leads to a potential deadlock-against-self when intercepting a close() in the
middle of tsocks_once initialization for close().
The same issue applies even if we use UTC, via gmtime.
Signed-off-by: David Goulet <dgoulet@xxxxxxxxx>
---
src/common/log.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/src/common/log.c b/src/common/log.c
index b68d66b..8bf8836 100644
--- a/src/common/log.c
+++ b/src/common/log.c
@@ -47,14 +47,12 @@ int tsocks_loglevel = DEFAULT_LOG_LEVEL;
static size_t add_time_to_log(char *buf, size_t len)
{
time_t now;
- const struct tm *tm;
assert(buf);
/* Get time stamp. */
time(&now);
- tm = localtime(&now);
- return strftime(buf, len, "[%b %d %H:%M:%S] ", tm);
+ return snprintf(buf, len, "%llu ", (unsigned long long)now);
}
/*
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits