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

[tor-commits] [torsocks/master] Use the correct libc symbol for socket, __socket30, on newer NetBSD.



commit ede9da87cc79004992d70f5a494d4e2dfe1920be
Author: Taylor R Campbell <campbell+torsocks@xxxxxxxxxx>
Date:   Wed Jun 17 17:05:18 2015 +0000

    Use the correct libc symbol for socket, __socket30, on newer NetBSD.
    
    Otherwise, we will define the ELF symbol __socket30 due to the declaration of
    socket in <sys/socket.h>, but try using dlsym to call the libc symbol
    "socket", which in NetBSD is defined as a compatibility wrapper that calls
    __socket30...which, because of ELF symbol resolution rules, will go back and
    call our __socket30, leading to infinite recursion.
    
    Instead, call the libc symbol "__socket30" explicitly so we get the real libc
    system call stub instead of the compatibility wrapper.
    
    (I don't know any way to automatically deduce the correct ELF symbol from the
    toolchain, even though it is written in <sys/socket.h>.)
    
    Signed-off-by: David Goulet <dgoulet@xxxxxxxxx>
---
 src/lib/torsocks.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/lib/torsocks.h b/src/lib/torsocks.h
index f00af75..f8f798f 100644
--- a/src/lib/torsocks.h
+++ b/src/lib/torsocks.h
@@ -54,7 +54,11 @@
 
 /* socket(2) */
 #define LIBC_SOCKET_NAME socket
+#if defined(__NetBSD__) && __NetBSD_Version__ >= 399002200
+#define LIBC_SOCKET_NAME_STR "__socket30"
+#else
 #define LIBC_SOCKET_NAME_STR XSTR(LIBC_SOCKET_NAME)
+#endif
 #define LIBC_SOCKET_RET_TYPE int
 #define LIBC_SOCKET_SIG \
 	int domain, int type, int protocol



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