]> git.ipfire.org Git - thirdparty/rsync.git/commitdiff
Using a correct time in log file
authorMichal Ruprich <mruprich@redhat.com>
Fri, 31 Jan 2025 13:35:18 +0000 (14:35 +0100)
committerAndrew Tridgell <andrew@tridgell.net>
Wed, 22 Apr 2026 03:02:10 +0000 (13:02 +1000)
options.c
tls.c
util1.c

index 74b39bf6a530ad3ff7bfd8f76cd028dda8e91d7f..58ed035fe8ff5fcb90f3b200983dc970a7de2cb3 100644 (file)
--- a/options.c
+++ b/options.c
@@ -1159,7 +1159,7 @@ static time_t parse_time(const char *arg)
 {
        const char *cp;
        time_t val, now = time(NULL);
-       struct tm t, *today = localtime(&now);
+       struct tm t, tmp, *today = localtime_r(&now, &tmp);
        int in_date, old_mday, n;
 
        memset(&t, 0, sizeof t);
diff --git a/tls.c b/tls.c
index e311240aff3850e4724608df09736079687a8c4a..e05f7ec23d87f0b8423788890e4bac1603d0b141 100644 (file)
--- a/tls.c
+++ b/tls.c
@@ -127,7 +127,7 @@ static void storetime(char *dest, size_t destsize, time_t t, int nsecs)
 {
        if (t) {
                int len;
-               struct tm *mt = gmtime(&t);
+               struct tm tmp, *mt = gmtime_r(&t, &tmp);
 
                len = snprintf(dest, destsize,
                        " %04d-%02d-%02d %02d:%02d:%02d",
diff --git a/util1.c b/util1.c
index e477759a407e586742e5af44c0000ed1ac619c5b..25ac7c9b08cbe5140a0df87da03ccd6d8697992b 100644 (file)
--- a/util1.c
+++ b/util1.c
@@ -1393,7 +1393,7 @@ char *timestring(time_t t)
        static int ndx = 0;
        static char buffers[4][20]; /* We support 4 simultaneous timestring results. */
        char *TimeBuf = buffers[ndx = (ndx + 1) % 4];
-       struct tm *tm = localtime(&t);
+       struct tm tmp, *tm = localtime_r(&t, &tmp);
        int len = snprintf(TimeBuf, sizeof buffers[0], "%4d/%02d/%02d %02d:%02d:%02d",
                 (int)tm->tm_year + 1900, (int)tm->tm_mon + 1, (int)tm->tm_mday,
                 (int)tm->tm_hour, (int)tm->tm_min, (int)tm->tm_sec);