[or-cvs] r13697: Patch from tup: use sizeof sockaddr_un as the size of a unix (in tor/trunk: . src/or)

nickm at seul.org nickm at seul.org
Sun Feb 24 22:11:04 UTC 2008


Author: nickm
Date: 2008-02-24 17:11:00 -0500 (Sun, 24 Feb 2008)
New Revision: 13697

Modified:
   tor/trunk/
   tor/trunk/ChangeLog
   tor/trunk/src/or/connection.c
Log:
 r14419 at tombo:  nickm | 2008-02-24 16:55:11 -0500
 Patch from tup: use sizeof sockaddr_un as the size of a unix sockaddr.  Fixes unix controlsocket binding on openbsd.



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/trunk [r14419] on 49666b30-7950-49c5-bedf-9dc8f3168102

Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog	2008-02-24 22:10:08 UTC (rev 13696)
+++ tor/trunk/ChangeLog	2008-02-24 22:11:00 UTC (rev 13697)
@@ -102,6 +102,8 @@
       the TLS shutdown handshake is hardly unexpected.
     - Send NAMESERVER_STATUS messages for a single failed nameserver
       correctly.
+    - Make Unix controlsockets work correctly on OpenBSD.  Patch from
+      tup. Bugfix on 0.2.0.3-alpha.
 
   o Code simplifications and refactoring:
     - Remove the tor_strpartition function: its logic was confused,

Modified: tor/trunk/src/or/connection.c
===================================================================
--- tor/trunk/src/or/connection.c	2008-02-24 22:10:08 UTC (rev 13696)
+++ tor/trunk/src/or/connection.c	2008-02-24 22:11:00 UTC (rev 13697)
@@ -746,8 +746,9 @@
  */
 static connection_t *
 connection_create_listener(struct sockaddr *listensockaddr, int type,
-  char* address)
+                           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;
@@ -814,7 +815,6 @@
     }
 #ifdef HAVE_SYS_UN_H
   } else if (listensockaddr->sa_family == AF_UNIX) {
-    size_t len;
     start_reading = 1;
 
     /* For now only control ports can be unix domain sockets
@@ -835,9 +835,7 @@
       goto err;
     }
 
-    len = strlen(((struct sockaddr_un *)listensockaddr)->sun_path) +
-          sizeof(((struct sockaddr_un *)listensockaddr)->sun_family);
-    if (bind(s, listensockaddr, (socklen_t)len) == -1) {
+    if (bind(s, listensockaddr, (socklen_t)sizeof(struct sockaddr_un)) == -1) {
       log_warn(LD_NET,"Bind to %s failed: %s.", address,
                tor_socket_strerror(tor_socket_errno(s)));
       goto err;



More information about the tor-commits mailing list