diff options
author | Nick Mathewson <nickm@torproject.org> | 2008-12-27 00:20:06 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2008-12-27 00:20:06 +0000 |
commit | a87335472cc3f940854668aa66c7db30d159196a (patch) | |
tree | 3afb60f68d8512f9ac09e3083c9947c3916582df | |
parent | b3b14bf25db02e98ecd10ba42761a62b42bfae9b (diff) | |
download | tor-a87335472cc3f940854668aa66c7db30d159196a.tar.gz tor-a87335472cc3f940854668aa66c7db30d159196a.zip |
Make connection_create_listener take a sockaddr_len, not just a sockaddr whose length we try to divine.
svn:r17792
-rw-r--r-- | src/or/connection.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/or/connection.c b/src/or/connection.c index 89c8318cc6..0e5fbb539c 100644 --- a/src/or/connection.c +++ b/src/or/connection.c @@ -16,7 +16,8 @@ const char connection_c_id[] = #include "or.h" static connection_t *connection_create_listener( - struct sockaddr *listensockaddr, int type, + struct sockaddr *listensockaddr, + socklen_t listensocklen, int type, char* address); static void connection_init(time_t now, connection_t *conn, int type, int socket_family); @@ -850,10 +851,9 @@ warn_too_many_conns(void) * to the conn. */ static connection_t * -connection_create_listener(struct sockaddr *listensockaddr, int type, - char* address) +connection_create_listener(struct sockaddr *listensockaddr, socklen_t socklen, + int type, char* address) { - /*XXXX021 this function should take a socklen too. */ connection_t *conn; int s; /* the socket we're going to make */ uint16_t usePort = 0; @@ -895,7 +895,7 @@ connection_create_listener(struct sockaddr *listensockaddr, int type, (socklen_t)sizeof(one)); #endif - if (bind(s,listensockaddr,(socklen_t)sizeof(struct sockaddr_in)) < 0) { + if (bind(s,listensockaddr,socklen) < 0) { const char *helpfulhint = ""; int e = tor_socket_errno(s); if (ERRNO_IS_EADDRINUSE(e)) @@ -1424,6 +1424,7 @@ retry_listeners(int type, config_line_t *cfg, { char *address = NULL; struct sockaddr *listensockaddr; + socklen_t listensocklen; switch (socket_family) { case AF_INET: @@ -1431,18 +1432,21 @@ retry_listeners(int type, config_line_t *cfg, create_inet_sockaddr(cfg_line->value, (uint16_t) port_option, &address); + listensocklen = sizeof(struct sockaddr_in); break; case AF_UNIX: listensockaddr = (struct sockaddr *) create_unix_sockaddr(cfg_line->value, &address); + listensocklen = sizeof(struct sockaddr_un); break; default: tor_assert(0); } if (listensockaddr) { - conn = connection_create_listener(listensockaddr, type, address); + conn = connection_create_listener(listensockaddr, listensocklen, + type, address); tor_free(listensockaddr); tor_free(address); } else |