[tor-bugs] #22870 [Core Tor/Tor]: consdiff test fails on OS X

Tor Bug Tracker & Wiki blackhole at torproject.org
Mon Jul 10 17:59:15 UTC 2017


#22870: consdiff test fails on OS X
--------------------------+------------------------------------
 Reporter:  pastly        |          Owner:
     Type:  defect        |         Status:  merge_ready
 Priority:  Low           |      Milestone:  Tor: 0.3.1.x-final
Component:  Core Tor/Tor  |        Version:
 Severity:  Normal        |     Resolution:
 Keywords:                |  Actual Points:
Parent ID:                |         Points:
 Reviewer:                |        Sponsor:
--------------------------+------------------------------------

Comment (by teor):

 Are there any other instances of this pattern in the codebase?
 I just checked, we very rarely do anything other than:
 {{{
 !strcmp()
 strcmp == 0
 strcmp()
 }}}
 and all the instances where we do > or < seem ok.

 What versions of macOS does this fail on?
 (We should test on it more often.)

 On macOS 10.12.5, Xcode 8.3.3, clang 3.9.1 I see:
 {{{
 consdiff/base64cmp: OK
 }}}

 But I also see in the macOS memcmp man page:

      The memcmp() function returns zero if the two strings are identical,
 oth-
      erwise returns the difference between the first two differing bytes
      (treated as unsigned char values, so that `\200' is greater than
 `\0',
      for example).  Zero-length strings are always identical.  This
 behavior
      is not required by C and portable code should only depend on the sign
 of
      the returned value.

 Whereas strcmp is ambiguous:

      The strcmp() and strncmp() functions return an integer greater than,
      equal to, or less than 0, according as the string s1 is greater than,
      equal to, or less than the string s2.  The comparison is done using
      unsigned characters, so that `\200' is greater than `\0'.

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


More information about the tor-bugs mailing list