[tor-bugs] #17739 [Tor]: Refactor clock skew warning code to avoid duplication

Tor Bug Tracker & Wiki blackhole at torproject.org
Thu Dec 10 20:47:03 UTC 2015


#17739: Refactor clock skew warning code to avoid duplication
---------------------------------------------+-----------------------------
 Reporter:  teor                             |          Owner:
     Type:  enhancement                      |         Status:
 Priority:  Medium                           |  needs_revision
Component:  Tor                              |      Milestone:  Tor:
 Severity:  Normal                           |  0.2.8.x-final
 Keywords:  easy refactor TorCoreTeam201512  |        Version:  Tor:
Parent ID:  #9675                            |  unspecified
  Sponsor:                                   |     Resolution:
                                             |  Actual Points:
                                             |         Points:
---------------------------------------------+-----------------------------

Comment (by teor):

 Replying to [comment:11 arlolra]:
 > > We can't guarantee that source will be large enough to hold the
 combined strings of source, conn->address, and conn->port.
 >
 > https://gitweb.torproject.org/tor.git/tree/src/common/compat.c#n501

 Apologies. I didn't understand tor_asprintf().

 Please don't re-use source as a mutable variable. It works, but it changes
 the function signature, and confuses people. Please declare another char *
 to hold the result of tor_asprintf, and make source const.

 If conn is NULL, you can use tor_strdup() on source and assign the newly
 allocated string to the same char *. This will make sure that you have a
 string allocated via malloc whether conn is NULL or not.

 Please also call tor_free() on the newly allocated string from
 tor_asprintf() at the end of the function.

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


More information about the tor-bugs mailing list