If krb5_us_timeofday() now checks the microsecond field for overflow
authorTheodore Tso <tytso@mit.edu>
Fri, 1 Mar 1991 15:24:50 +0000 (15:24 +0000)
committerTheodore Tso <tytso@mit.edu>
Fri, 1 Mar 1991 15:24:50 +0000 (15:24 +0000)
into the seconds field when it is bumping the value last returned by
gettimeofday.

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@1831 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/krb5/os/ustime.c

index 65146492f89bc7febcab63cb46278a6b74044f9f..46117343a645159bb0c1f2e98c8a75596a039081 100644 (file)
@@ -36,9 +36,13 @@ register krb5_int32 *seconds, *microseconds;
        /* failed, return errno */
        return (krb5_error_code) errno;
     }
-    if ((tv.tv_sec == last_tv.tv_sec) && (tv.tv_usec == last_tv.tv_usec))
-           tv.tv_usec = ++last_tv.tv_usec;
-    else 
+    if ((tv.tv_sec == last_tv.tv_sec) && (tv.tv_usec == last_tv.tv_usec)) {
+           if (++last_tv.tv_usec >= 1000000) {
+                   last_tv.tv_usec = 0;
+                   last_tv.tv_sec++;
+           }
+           tv = last_tv;
+    } else 
            last_tv = tv;
            
     *seconds = tv.tv_sec;