diff options
author | Nick Mathewson <nickm@torproject.org> | 2011-03-07 17:09:23 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2011-03-07 17:09:23 -0500 |
commit | 3bd83b8fb64c070210c589f65ed8cc023dd47077 (patch) | |
tree | 21d47d146606c7996b4059aea4accbd27697baee | |
parent | 35fcec38809f9805326d8e2c81bad33d0ef000ae (diff) | |
parent | f83debb51d7fa4a1827967d8bea145636c855f89 (diff) | |
download | tor-3bd83b8fb64c070210c589f65ed8cc023dd47077.tar.gz tor-3bd83b8fb64c070210c589f65ed8cc023dd47077.zip |
Merge remote branch 'sebastian/bug2660' into maint-0.2.2
-rw-r--r-- | changes/bug2660 | 7 | ||||
-rw-r--r-- | src/common/address.c | 18 |
2 files changed, 16 insertions, 9 deletions
diff --git a/changes/bug2660 b/changes/bug2660 new file mode 100644 index 0000000000..2aa06d36f5 --- /dev/null +++ b/changes/bug2660 @@ -0,0 +1,7 @@ + o Minor bugfixes: + - Fix connect() failures on some platforms (BSD, OS X). Bugfix on + 0.2.0.3-alpha; fixes first part of bug 2660. Patch by piebeer. + - Set target port in get_interface_address6() correctly. Bugfix + on 0.1.1.4-alpha and 0.2.0.3-alpha; fixes second part of bug + 2660. + diff --git a/src/common/address.c b/src/common/address.c index 0e57528ae8..a2780fb051 100644 --- a/src/common/address.c +++ b/src/common/address.c @@ -1025,27 +1025,28 @@ get_interface_address6(int severity, sa_family_t family, tor_addr_t *addr) { int sock=-1, r=-1; struct sockaddr_storage my_addr, target_addr; - socklen_t my_addr_len; + socklen_t addr_len; tor_assert(addr); memset(addr, 0, sizeof(tor_addr_t)); memset(&target_addr, 0, sizeof(target_addr)); - my_addr_len = (socklen_t)sizeof(my_addr); - /* Use the "discard" service port */ - ((struct sockaddr_in*)&target_addr)->sin_port = 9; /* Don't worry: no packets are sent. We just need to use a real address * on the actual Internet. */ if (family == AF_INET6) { struct sockaddr_in6 *sin6 = (struct sockaddr_in6*)&target_addr; + /* Use the "discard" service port */ + sin6->sin6_port = htons(9); sock = tor_open_socket(PF_INET6,SOCK_DGRAM,IPPROTO_UDP); - my_addr_len = (socklen_t)sizeof(struct sockaddr_in6); + addr_len = (socklen_t)sizeof(struct sockaddr_in6); sin6->sin6_family = AF_INET6; S6_ADDR16(sin6->sin6_addr)[0] = htons(0x2002); /* 2002:: */ } else if (family == AF_INET) { struct sockaddr_in *sin = (struct sockaddr_in*)&target_addr; + /* Use the "discard" service port */ + sin->sin_port = htons(9); sock = tor_open_socket(PF_INET,SOCK_DGRAM,IPPROTO_UDP); - my_addr_len = (socklen_t)sizeof(struct sockaddr_in); + addr_len = (socklen_t)sizeof(struct sockaddr_in); sin->sin_family = AF_INET; sin->sin_addr.s_addr = htonl(0x12000001); /* 18.0.0.1 */ } else { @@ -1058,14 +1059,13 @@ get_interface_address6(int severity, sa_family_t family, tor_addr_t *addr) goto err; } - if (connect(sock,(struct sockaddr *)&target_addr, - (socklen_t)sizeof(target_addr))<0) { + if (connect(sock,(struct sockaddr *)&target_addr, addr_len) < 0) { int e = tor_socket_errno(sock); log_fn(severity, LD_NET, "connect() failed: %s", tor_socket_strerror(e)); goto err; } - if (getsockname(sock,(struct sockaddr*)&my_addr, &my_addr_len)) { + if (getsockname(sock,(struct sockaddr*)&my_addr, &addr_len)) { int e = tor_socket_errno(sock); log_fn(severity, LD_NET, "getsockname() to determine interface failed: %s", tor_socket_strerror(e)); |