[tor-bugs] #18902 [Core Tor/Tor]: Avoid variable shadowing in Tor

Tor Bug Tracker & Wiki blackhole at torproject.org
Tue Jul 26 23:49:06 UTC 2016


#18902: Avoid variable shadowing in Tor
-------------------------------------------------+-------------------------
 Reporter:  teor                                 |          Owner:  nickm
     Type:  defect                               |         Status:
 Priority:  Medium                               |  needs_review
Component:  Core Tor/Tor                         |      Milestone:  Tor:
 Severity:  Normal                               |  0.2.9.x-final
 Keywords:  easy, refactor, TorCoreTeam201607,   |        Version:
  review-group-5                                 |     Resolution:
Parent ID:  #19379                               |  Actual Points:  .3
 Reviewer:  teor                                 |         Points:  .3
                                                 |        Sponsor:
                                                 |  SponsorS-can
-------------------------------------------------+-------------------------

Comment (by teor):

 Actual-review-points: 0.1

 1135405 Fix a variable-shadowing bug in check_private_dir
 Assigns to pw_uid, but doesn't use the value after that.
 (Some compilers will warn about this.)

 I think pw_uid might need to be used in the log message, or the line
 `pw_uid = tor_getpwuid(st.st_uid);` should be deleted.

 {{{
     const struct passwd *pw_uid = NULL;
     char *process_ownername = NULL;

     pw_uid = tor_getpwuid(running_uid);
     process_ownername = pw_uid ? tor_strdup(pw_uid->pw_name) :
       tor_strdup("<unknown>");

     pw_uid = tor_getpwuid(st.st_uid);

     log_warn(LD_FS, "%s is not owned by this user (%s, %d) but by "
         "%s (%d). Perhaps you are running Tor as the wrong user?",
                          dirname, process_ownername, (int)running_uid,
                          pw ? pw->pw_name : "<unknown>", (int)st.st_uid);
 }}}

 (Looking at the rest now.)

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


More information about the tor-bugs mailing list