[tor-bugs] #20692 [Core Tor/Tor]: risky duplicate code in rend_config_services()

Tor Bug Tracker & Wiki blackhole at torproject.org
Thu Nov 17 03:30:05 UTC 2016


#20692: risky duplicate code in rend_config_services()
------------------------------+--------------------------------
     Reporter:  arma          |      Owner:
         Type:  defect        |     Status:  new
     Priority:  Medium        |  Milestone:  Tor: 0.3.0.x-final
    Component:  Core Tor/Tor  |    Version:
     Severity:  Normal        |   Keywords:  easy
Actual Points:                |  Parent ID:
       Points:                |   Reviewer:
      Sponsor:                |
------------------------------+--------------------------------
 In rend_config_services(), we have a loop over options->RendConfigLines,
 and one of the things it does is:
 {{{
       if (service) { /* register the one we just finished parsing */
         if (rend_service_check_private_dir(options, service, 0) < 0) {
           rend_service_free(service);
           return -1;
         }

         if (validate_only)
           rend_service_free(service);
         else
           rend_add_service(service);
       }
 }}}

 Then once the loop is finished, it proceeds to call
 {{{
   if (service) {
     if (rend_service_check_private_dir(options, service, 0) < 0) {
       rend_service_free(service);
       return -1;
     }

     if (validate_only) {
       rend_service_free(service);
     } else {
       rend_add_service(service);
     }
   }
 }}}

 Look familiar? This duplication is going to bite us when somebody changes
 one part but not the other.

 Found while looking at #20638.

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


More information about the tor-bugs mailing list