[Bug 10643] New: cmp_time() returns incorrect result due to integer overflow
samba-bugs at samba.org
samba-bugs at samba.org
Fri May 30 19:38:27 MDT 2014
https://bugzilla.samba.org/show_bug.cgi?id=10643
Summary: cmp_time() returns incorrect result due to integer
overflow
Product: rsync
Version: 3.1.1
Platform: All
OS/Version: All
Status: NEW
Severity: normal
Priority: P5
Component: core
AssignedTo: wayned at samba.org
ReportedBy: William.Hooper at ntc.com
QAContact: rsync-qa at samba.org
Created attachment 9998
--> https://bugzilla.samba.org/attachment.cgi?id=9998
Patch to change cmp_time() to use difftime(3)
In rsync-3.1.1pre1, if time_t is a signed integer, the cmp_time() function in
util.c returns an incorrect result if one of its arguments is far in the past
and the other is close to the present or in the future. This causes rsync to
treat the times as equal when they actually differ by many years.
For example, if time_t is a 32-bit signed integer, when cmp_time() is called
with the following times (in either order):
1401411396 (May 30 00:56:36 2014)
-2146953600 (Dec 20 00:00:00 1901)
it returns 0, indicating that the times should be treated as the same, not the
expected -1 or +1, indicating that the times are different.
This behavior is apparently caused by integer overflows in the subtraction
operations in the conditional expressions on lines 1322 and 1326 of util.c. The
difference between two signed integer values can be greater than can be
represented in a signed integer of the same size.
Attached is a patch to change cmp_time() to use the difftime() library
function, available in C89 and later, to compute the difference between the
time_t values.
--
Configure bugmail: https://bugzilla.samba.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
More information about the rsync
mailing list