]> git.ipfire.org Git - thirdparty/krb5.git/commitdiff
Fix krb5_crypto_us_timeofday() microseconds check 1374/head
authorAlexey Tikhonov <atikhono@redhat.com>
Thu, 3 Oct 2024 16:40:04 +0000 (18:40 +0200)
committerGreg Hudson <ghudson@mit.edu>
Mon, 7 Oct 2024 23:23:30 +0000 (19:23 -0400)
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.

[ghudson@mit.edu: rewrote commit message]

ticket: 9141 (new)
tags: pullup
target_version: 1.21-next

src/lib/krb5/os/c_ustime.c

index f69f2ea4c332016db5ad01bfd19672ec2deacc71..7019ea1970e78c7baa16f1d5f1091985fe62d584 100644 (file)
@@ -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;