[tor-bugs] #18105 [Core Tor/Tor]: Replace getsockname with tor_getsockname

Tor Bug Tracker & Wiki blackhole at torproject.org
Sat Nov 4 15:57:05 UTC 2017


#18105: Replace getsockname with tor_getsockname
-------------------------------------------------+-------------------------
 Reporter:  teor                                 |          Owner:
                                                 |  eewayhsu
     Type:  enhancement                          |         Status:
                                                 |  needs_revision
 Priority:  Medium                               |      Milestone:  Tor:
                                                 |  0.3.3.x-final
Component:  Core Tor/Tor                         |        Version:
 Severity:  Normal                               |     Resolution:
 Keywords:  easy, intro, api, code-              |  Actual Points:
  simplification                                 |
Parent ID:                                       |         Points:  small
 Reviewer:                                       |        Sponsor:
-------------------------------------------------+-------------------------

Comment (by callumw):

 Would this suffice for a new tor_getsockname function?

 MOCK_IMPL(int,
 tor_getsockname,(tor_socket_t sock, struct sockaddr *sock_address,
                  tor_addr_t *tor_address, socklen_t *address_len))
 {
    if (getsockname(sock, address, address_len) < 0) { return -1 }

    return tor_addr_from_sockaddr(&tor_address, (struct
 sockaddr*)&sock_address, NULL);
 }

 I have done it this way so that each call to tor_getsockname can be dealt
 with individually as they are now with getsockname.

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


More information about the tor-bugs mailing list