git: a38c2f99f81c - main - tzcode: Fix early tz change detection
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 02 Nov 2025 13:53:47 UTC
The branch main has been updated by des:
URL: https://cgit.FreeBSD.org/src/commit/?id=a38c2f99f81c2fc35c8ca209931c1c46e3e81023
commit a38c2f99f81c2fc35c8ca209931c1c46e3e81023
Author: Dag-Erling Smørgrav <des@FreeBSD.org>
AuthorDate: 2025-11-02 13:51:42 +0000
Commit: Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2025-11-02 13:51:42 +0000
tzcode: Fix early tz change detection
Assume tzdata is not fresh if last_checked is zero, as comparing the
current time to last_checked less than __tz_change_interval after boot
may produce a false negative.
While here, invert the return value from tzdata_is_fresh() to better
match its new name (it was previously called recheck_tzdata(), so zero
for fresh and non-zero for stale made sense, but it doesn't now).
PR: 269207
MFC after: 3 days
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D53502
---
contrib/tzcode/localtime.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/contrib/tzcode/localtime.c b/contrib/tzcode/localtime.c
index 1668475ea646..58099d234e2b 100644
--- a/contrib/tzcode/localtime.c
+++ b/contrib/tzcode/localtime.c
@@ -1583,15 +1583,15 @@ tzdata_is_fresh(void)
struct timespec now;
if (clock_gettime(CLOCK_MONOTONIC, &now) < 0)
- return 0;
+ return 1;
- if ((now.tv_sec - last_checked >= __tz_change_interval) ||
- (last_checked > now.tv_sec)) {
+ if (last_checked == 0 || last_checked > now.tv_sec ||
+ now.tv_sec - last_checked >= __tz_change_interval) {
last_checked = now.tv_sec;
- return 1;
+ return 0;
}
- return 0;
+ return 1;
}
#endif /* DETECT_TZ_CHANGES */
@@ -1642,7 +1642,7 @@ tzset_unlocked_name(char const *name)
? lcl_is_set < 0
: 0 < lcl_is_set && strcmp(lcl_TZname, name) == 0)
#ifdef DETECT_TZ_CHANGES
- if (tzdata_is_fresh() == 0)
+ if (tzdata_is_fresh())
#endif /* DETECT_TZ_CHANGES */
return;
# ifdef ALL_STATE