[tor-bugs] #6877 [Core Tor/Tor]: Finally replace all char[] buffers with uint8_t[] buffers

Tor Bug Tracker & Wiki blackhole at torproject.org
Mon May 29 20:42:08 UTC 2017


#6877: Finally replace all char[] buffers with uint8_t[] buffers
-------------------------------------------------+-------------------------
 Reporter:  nickm                                |          Owner:
     Type:  defect                               |         Status:  new
 Priority:  High                                 |      Milestone:  Tor:
                                                 |  unspecified
Component:  Core Tor/Tor                         |        Version:
 Severity:  Normal                               |     Resolution:
 Keywords:  tor-client tor-relay refactoring     |  Actual Points:
  technical-debt lots-of-work                    |
Parent ID:                                       |         Points:  10
 Reviewer:                                       |        Sponsor:
-------------------------------------------------+-------------------------

Comment (by catalyst):

 Things get really hairy once you consider the possibility that uint8_t can
 be different from unsigned char (on a CHAR_BIT==8 system).  Unfortunately,
 compiler developers have apparently seriously considered this in the past.

 https://stackoverflow.com/questions/16138237/when-is-uint8-t-%E2%89%A0
 -unsigned-char#16138470
 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66110
 https://stackoverflow.com/questions/26297571/how-to-create-an-uint8-t
 -array-that-does-not-undermine-strict-aliasing

 An additional direction is having (void *) parameters for functions that
 read or write byte arrays.  In that case, a pointer to any type can be
 passed in so the implementation of those functions must use a can-alias-
 anything byte type like unsigned char internally.

 (Also if uint8_t is an extended integer type, it looks like nothing in C99
 guarantees that its bits will even be in the same order as those of an
 unsigned char.  I think it might be feasible but annoying to test for that
 at compile time once we detect that they're different types.)

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


More information about the tor-bugs mailing list