[tor-bugs] #19483 [Core Tor/Tor]: Unit test util/time is broken on OpenBSD

Tor Bug Tracker & Wiki blackhole at torproject.org
Wed Jun 29 07:37:22 UTC 2016


#19483: Unit test util/time is broken on OpenBSD
-----------------------------------------------+---------------------------
 Reporter:  teor                               |          Owner:
     Type:  defect                             |         Status:
 Priority:  Medium                             |  needs_review
Component:  Core Tor/Tor                       |      Milestone:  Tor:
 Severity:  Normal                             |  0.2.9.x-final
 Keywords:  integer-safety, TorCoreTeam201607  |        Version:
Parent ID:                                     |     Resolution:
 Reviewer:                                     |  Actual Points:  1.0
                                               |         Points:  0.5
                                               |        Sponsor:
-----------------------------------------------+---------------------------
Changes (by teor):

 * status:  new => needs_review
 * keywords:   => integer-safety, TorCoreTeam201607
 * actualpoints:   => 1.0
 * milestone:  Tor: 0.2.8.x-final => Tor: 0.2.9.x-final


Comment:

 There are a few different issues here:

 Some BSDs have a 64-bit tv_sec, but a 32-bit time_t.
 Source:
 https://www.gnu.org/software/gnulib/manual/html_node/sys_002ftime_002eh.html
 The unit test failure on those BSDs doesn't affect 0.2.8, because the
 failing test was only introduced in 0.2.9.

 However, the integer truncation / overflow issue when time_t and tv_sec
 are different sizes still affects BSDs on 0.2.8. But we've changed the
 code in tv_udiff and tv_mdiff to fix a different bug between 0.2.8 and
 master, so it's not worth going back to change it.

 There have been integer overflow errors in tv_udiff and tv_mdiff on all
 platforms in every released version of tor. I think this is ok, because we
 typically compare internal clocks with these functions. But I didn't check
 to see if we ever use times that come from the network. And now we are
 compiling with -ftrapv, we really need to fix this issue up.

 I modified tv_udiff and tv_mdiff to use 64-bit integers and check for
 overflow internally, but they still output a long. We can fix the
 interfaces to all the time functions to be 64-bit clean in #18480.

 Please see my branch bug19483-v2 on https://github.com/teor2345/tor.git
 It's based on master (0.2.9).
 It comes with comprehensive unit tests, that exercise several different
 kinds of overflow, and check the rounding behaviour of tv_mdiff. (They
 don't test 64-bit tv_sec values on 32-bit BSDs, because that would have
 meant finding the size of tv_sec at compile time.)

 I have tested it on OS X x86_64 and i386, and Linux x86_64.
 It needs testing on multiple platforms (especially Windows and 32-bit BSDs
 with 64-bit tv_sec), but I think that's best done by merging to master.)

--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/19483#comment:2>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online


More information about the tor-bugs mailing list