krb5 commit [krb5-1.21]: Fix krb5_crypto_us_timeofday() microseconds check
[email protected] Mon, 4 Aug 2025 18:31:57 -0400 (EDT)
| Newsgroups | gmane.comp.encryption.kerberos.cvs |
|---|---|
| Message-ID | <[email protected]> |
https://github.com/krb5/krb5/commit/7910ea9a7e5a1c9ed4c973c862e2bd96fea0fd13 commit 7910ea9a7e5a1c9ed4c973c862e2bd96fea0fd13 Author: Alexey Tikhonov <[email protected]> Date: Thu Oct 3 18:40:04 2024 +0200 Fix krb5_crypto_us_timeofday() microseconds check Commit a60db180211a383bd382afe729e9309acb8dcf53 mistakenly reversed the sense of the krb5_crypto_us_timeofday() conditional that enforces fowards movement of the microseconds value within a second. Moreover, the macros ts_after() and ts_incr() should not have been applied to non-timestamp values. Revert the incorrect changes. [[email protected]: rewrote commit message] (cherry picked from commit 6f6d795be8d0dd0a46952cf8afa59b65d71df744) ticket: 9141 version_fixed: 1.21.4 src/lib/krb5/os/c_ustime.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/krb5/os/c_ustime.c b/src/lib/krb5/os/c_ustime.c index f69f2ea4c..7019ea197 100644 --- a/src/lib/krb5/os/c_ustime.c +++ b/src/lib/krb5/os/c_ustime.c @@ -106,14 +106,14 @@ krb5_crypto_us_timeofday(krb5_timestamp *seconds, krb5_int32 *microseconds) need to properly handle the case where the administrator intentionally adjusted time backwards. */ if (now.sec == ts_incr(last_time.sec, -1) || - (now.sec == last_time.sec && !ts_after(last_time.usec, now.usec))) { + (now.sec == last_time.sec && now.usec <= last_time.usec)) { /* Correct 'now' to be exactly one microsecond later than 'last_time'. Note that _because_ we perform this hack, 'now' may be _earlier_ than 'last_time', even though the system time is monotonically increasing. */ now.sec = last_time.sec; - now.usec = ts_incr(last_time.usec, 1); + now.usec = last_time.usec + 1; if (now.usec >= 1000000) { now.sec = ts_incr(now.sec, 1); now.usec = 0;