[or-cvs] r17792: {tor} Make connection_create_listener take a sockaddr_len, not jus (tor/trunk/src/or)
nickm at seul.org
nickm at seul.org
Sat Dec 27 00:20:06 UTC 2008
Author: nickm
Date: 2008-12-26 19:20:06 -0500 (Fri, 26 Dec 2008)
New Revision: 17792
Modified:
tor/trunk/src/or/connection.c
Log:
Make connection_create_listener take a sockaddr_len, not just a sockaddr whose length we try to divine.
Modified: tor/trunk/src/or/connection.c
===================================================================
--- tor/trunk/src/or/connection.c 2008-12-26 22:51:25 UTC (rev 17791)
+++ tor/trunk/src/or/connection.c 2008-12-27 00:20:06 UTC (rev 17792)
@@ -16,7 +16,8 @@
#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 @@
* 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 @@
(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 @@
{
char *address = NULL;
struct sockaddr *listensockaddr;
+ socklen_t listensocklen;
switch (socket_family) {
case AF_INET:
@@ -1431,18 +1432,21 @@
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
More information about the tor-commits
mailing list