[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/master] Fix setting target port in get_interface_address6



commit f83debb51d7fa4a1827967d8bea145636c855f89
Author: Sebastian Hahn <sebastian@xxxxxxxxxxxxxx>
Date:   Sat Mar 5 15:20:55 2011 +0100

    Fix setting target port in get_interface_address6
    
    We want to use the discard port correctly, so a htons() was missing.
    Also we need to set it correctly depending on address family.
    
    Review provided by danieldg
---
 changes/bug2660      |    6 +++++-
 src/common/address.c |    6 ++++--
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/changes/bug2660 b/changes/bug2660
index fe22956..2aa06d3 100644
--- a/changes/bug2660
+++ b/changes/bug2660
@@ -1,3 +1,7 @@
   o Minor bugfixes:
     - Fix connect() failures on some platforms (BSD, OS X). Bugfix on
-      0.2.0.3-alpha; fixes bug 2660. Patch by piebeer.
+      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 90beae0..a2780fb 100644
--- a/src/common/address.c
+++ b/src/common/address.c
@@ -1031,18 +1031,20 @@ get_interface_address6(int severity, sa_family_t family, tor_addr_t *addr)
 
   memset(addr, 0, sizeof(tor_addr_t));
   memset(&target_addr, 0, sizeof(target_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);
     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);
     addr_len = (socklen_t)sizeof(struct sockaddr_in);
     sin->sin_family = AF_INET;



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits