samba-bugs at samba.org
2014-May-31 01:38 UTC
[Bug 10643] New: cmp_time() returns incorrect result due to integer overflow
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 --> 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: bugzilla.samba.org/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the QA contact for the bug.
samba-bugs at samba.org
2014-Jun-16 01:02 UTC
[Bug 10643] cmp_time() returns incorrect result due to integer overflow
bugzilla.samba.org/show_bug.cgi?id=10643 Wayne Davison <wayned at samba.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED --- Comment #1 from Wayne Davison <wayned at samba.org> 2014-06-16 01:02:30 UTC --- To avoid having to figure out if a system has difftime(), I just fixed the logic in cmp_time() to work even if things overflow. Thanks for noticing the wacko result and diagnosing the cause. -- Configure bugmail: bugzilla.samba.org/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the QA contact for the bug.