[tor-bugs] #32994 [Core Tor/Tor]: Get all flag defaults from port_cfg_new()

Tor Bug Tracker & Wiki blackhole at torproject.org
Wed Mar 11 17:42:24 UTC 2020


#32994: Get all flag defaults from port_cfg_new()
-------------------------------------------------+-------------------------
 Reporter:  teor                                 |          Owner:
                                                 |  MrSquanchee
     Type:  defect                               |         Status:
                                                 |  assigned
 Priority:  Medium                               |      Milestone:  Tor:
                                                 |  unspecified
Component:  Core Tor/Tor                         |        Version:
 Severity:  Normal                               |     Resolution:
 Keywords:  technical-debt, tor-client, easy,    |  Actual Points:
  intro, outreachy-ipv6                          |
Parent ID:                                       |         Points:  1
 Reviewer:                                       |        Sponsor:
-------------------------------------------------+-------------------------

Comment (by nickm):

 So the problem with `port_parse_config()` is that the all of its defaults
 would have to be kept in sync with `port_cfg_new()`.  If we make a change
 to one place, we have to make it to the other, or else we don't get the
 expected results.  This has caused hard-to-diagnose bugs in the past.

 A good solution here might be to create the port_cfg_t object near the
 start of the loop in port_cfg_t, and then assign to its flags directly,
 rather than first assigning them to intermediate variables and only
 copying them at the end of the loop.  Teor might have some thoughts here
 as the original opener of this bug.

 As for `port_cfg_new()`: it isn't actually necessary to set any flags to
 `0` there, since the object is allocated with `tor_malloc_zero()`, which
 initializes all the memory in it to 0.

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


More information about the tor-bugs mailing list