The branch, v3-6-test has been updated
       via  79cc078 Ensure incoming timespec values correctly wrap at nsecs.
      from  c4a31cf Fix string_to_sid() to allow non '

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-6-test


- Log -----------------------------------------------------------------
commit 79cc0785353e14461ece45ae02c0a1477304e1ba
Author: Jeremy Allison <[email protected]>
Date:   Tue Sep 14 14:53:17 2010 -0700

    Ensure incoming timespec values correctly wrap at nsecs.
    
    Jeremy.
    (cherry picked from commit 0b270f014f67b8ff49b70fb41b2cceac121f337e)

-----------------------------------------------------------------------

Summary of changes:
 lib/util/time.c    |    7 +++++++
 source3/lib/time.c |    4 ++++
 2 files changed, 11 insertions(+), 0 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/util/time.c b/lib/util/time.c
index ed3b4f8..6fbeb97 100644
--- a/lib/util/time.c
+++ b/lib/util/time.c
@@ -91,8 +91,15 @@ _PUBLIC_ time_t time_mono(time_t *t)
 
 time_t convert_timespec_to_time_t(struct timespec ts)
 {
+       /* Ensure tv_nsec is less than 1sec. */
+       while (ts.tv_nsec > 1000000000) {
+               ts.tv_sec += 1;
+               ts.tv_nsec -= 1000000000;
+       }
+
        /* 1 ns == 1,000,000,000 - one thousand millionths of a second.
           increment if it's greater than 500 millionth of a second. */
+
        if (ts.tv_nsec > 500000000) {
                return ts.tv_sec + 1;
        }
diff --git a/source3/lib/time.c b/source3/lib/time.c
index 8b28de6..81106a7 100644
--- a/source3/lib/time.c
+++ b/source3/lib/time.c
@@ -409,6 +409,10 @@ void round_timespec_to_usec(struct timespec *ts)
 {
        struct timeval tv = convert_timespec_to_timeval(*ts);
        *ts = convert_timeval_to_timespec(tv);
+       while (ts->tv_nsec > 1000000000) {
+               ts->tv_sec += 1;
+               ts->tv_nsec -= 1000000000;
+       }
 }
 
 /****************************************************************************


-- 
Samba Shared Repository

Reply via email to