[SCM] The rsync repository. - branch master updated

Rsync CVS commit messages rsync-cvs at lists.samba.org
Sun Jun 15 19:02:35 MDT 2014


The branch, master has been updated
       via  aa4c6db Make sure cmp_time() doesn't mess up due to a time_t overflow. Fixes bug 10643.
      from  edb0d9c Updated NEWS & tweaked a comment.

;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit aa4c6db04379322551e3b3ae5f84108f7564864f
Author: Wayne Davison <wayned at samba.org>
Date:   Sun Jun 15 17:30:09 2014 -0700

    Make sure cmp_time() doesn't mess up due to a time_t overflow.
    Fixes bug 10643.

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

Summary of changes:
 NEWS   |    3 +++
 util.c |   15 ++++++++-------
 2 files changed, 11 insertions(+), 7 deletions(-)


Changeset truncated at 500 lines:

diff --git a/NEWS b/NEWS
index 9ad8306..a65b3bb 100644
--- a/NEWS
+++ b/NEWS
@@ -104,6 +104,9 @@ Changes since 3.1.0:
       inc-recursive copy that is preserving directory times. e.g. using
       --omit-dir-times will avoid these early directories being created.
 
+    - Fix a bug in cmp_time() that would return a wrong result if the 2 times
+      differed by an amount greater than what a time_t can hold.
+
   DEVELOPER RELATED:
 
     - We now include an example systemd file (in packaging/systemd).
diff --git a/util.c b/util.c
index bd537ae..05aa86a 100644
--- a/util.c
+++ b/util.c
@@ -1325,16 +1325,17 @@ char *timestring(time_t t)
 int cmp_time(time_t file1, time_t file2)
 {
 	if (file2 > file1) {
-		if (file2 - file1 <= modify_window)
-			return 0;
-		return -1;
+		/* The final comparison makes sure that modify_window doesn't overflow a
+		 * time_t, which would mean that file2 must be in the equality window. */
+		if (!modify_window || (file2 > file1 + modify_window && file1 + modify_window > file1))
+			return -1;
+	} else if (file1 > file2) {
+		if (!modify_window || (file1 > file2 + modify_window && file2 + modify_window > file2))
+			return 1;
 	}
-	if (file1 - file2 <= modify_window)
-		return 0;
-	return 1;
+	return 0;
 }
 
-
 #ifdef __INSURE__XX
 #include <dlfcn.h>
 


-- 
The rsync repository.


More information about the rsync-cvs mailing list