[tor-bugs] #28815 [Core Tor/Tor]: Refactor similar compression buffer code in dircache.c

Tor Bug Tracker & Wiki blackhole at torproject.org
Tue Dec 11 04:28:07 UTC 2018


#28815: Refactor similar compression buffer code in dircache.c
-------------------------+-------------------------------------------------
     Reporter:  teor     |      Owner:  (none)
         Type:  defect   |     Status:  new
     Priority:  Medium   |  Milestone:  Tor: unspecified
    Component:  Core     |    Version:
  Tor/Tor                |
     Severity:  Normal   |   Keywords:  technical-debt, tor-dir, tor-bwauth
Actual Points:           |  Parent ID:
       Points:  1        |   Reviewer:
      Sponsor:           |
-------------------------+-------------------------------------------------
 After #21377, we will have 3 copies of similar compression buffer code in
 dircache.c.

 Copying code is a bad idea, because:
 * people make mistakes when they copy, and
 * when people make changes, they sometimes miss the copies.

 Instead, we should write a function that correctly adds compressed or
 uncompressed data to the connection, based on conn, compress_method,
 uncompressed_body_len, lifetime, estimated_len, and the data that needs to
 be added to the buffer.

 Perhaps the dirserv_spool_* functions could help here.

 Then we can call the new function from handle_get_next_bandwidth():
 https://github.com/torproject/tor/blob/b03091842bc4590e11e3ac026daae8ed6d8f7554/src/feature/dircache/dircache.c#L1463-L1468

 handle_get_status_vote():
 https://github.com/torproject/tor/blob/8020d6fb05d9477e77c6ca554dc1288873f6115c/src/feature/dircache/dircache.c#L1034-L1048

 and handle_get_keys():
 https://github.com/torproject/tor/blob/8020d6fb05d9477e77c6ca554dc1288873f6115c/src/feature/dircache/dircache.c#L1292-L1310

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


More information about the tor-bugs mailing list