[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [torsocks/master] Fix: overload listen and not bind
commit 94ac23e2ea4d937839460367c123fd54f505e2d3
Author: David Goulet <dgoulet@xxxxxxxxx>
Date: Thu Feb 20 14:39:57 2014 +0000
Fix: overload listen and not bind
Signed-off-by: David Goulet <dgoulet@xxxxxxxxx>
---
src/lib/Makefile.am | 2 +-
src/lib/bind.c | 46 ----------------------------------------------
src/lib/listen.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
src/lib/torsocks.h | 22 +++++++++++-----------
4 files changed, 58 insertions(+), 58 deletions(-)
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am
index 403fab3..cccecf1 100644
--- a/src/lib/Makefile.am
+++ b/src/lib/Makefile.am
@@ -9,6 +9,6 @@ lib_LTLIBRARIES = libtorsocks.la
libtorsocks_la_SOURCES = torsocks.c torsocks.h \
connect.c gethostbyname.c getaddrinfo.c close.c \
getpeername.c socket.c syscall.c socketpair.c recv.c \
- exit.c accept.c bind.c
+ exit.c accept.c listen.c
libtorsocks_la_LIBADD = $(top_builddir)/src/common/libcommon.la
diff --git a/src/lib/bind.c b/src/lib/bind.c
deleted file mode 100644
index 3b1ba91..0000000
--- a/src/lib/bind.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2014 - David Goulet <dgoulet@xxxxxxxxx>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License, version 2 only, as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 51
- * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include <assert.h>
-
-#include "torsocks.h"
-
-TSOCKS_LIBC_DECL(bind, LIBC_BIND_RET_TYPE, LIBC_BIND_SIG)
-
-/*
- * Torsocks call for bind(2).
- */
-LIBC_BIND_RET_TYPE tsocks_bind(LIBC_BIND_SIG)
-{
- DBG("[accept] Syscall denied since inbound connection are not allowed.");
-
- /*
- * Bind is completely denied here since this means that the application
- * can accept inbound connections that are obviously NOT handled by the Tor
- * network thus reject this call.
- */
- errno = EPERM;
- return -1;
-}
-
-/*
- * Libc hijacked symbol bind(2).
- */
-LIBC_BIND_DECL
-{
- return tsocks_bind(LIBC_BIND_ARGS);
-}
diff --git a/src/lib/listen.c b/src/lib/listen.c
new file mode 100644
index 0000000..e72f1f6
--- /dev/null
+++ b/src/lib/listen.c
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2014 - David Goulet <dgoulet@xxxxxxxxx>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License, version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <assert.h>
+
+#include "torsocks.h"
+
+TSOCKS_LIBC_DECL(listen, LIBC_LISTEN_RET_TYPE, LIBC_LISTEN_SIG)
+
+/*
+ * Torsocks call for listen(2).
+ */
+LIBC_LISTEN_RET_TYPE tsocks_listen(LIBC_LISTEN_SIG)
+{
+ DBG("[accept] Syscall denied since inbound connection are not allowed.");
+
+ /*
+ * Bind is completely denied here since this means that the application
+ * can accept inbound connections that are obviously NOT handled by the Tor
+ * network thus reject this call.
+ */
+ errno = EPERM;
+ return -1;
+}
+
+/*
+ * Libc hijacked symbol listen(2).
+ */
+LIBC_LISTEN_DECL
+{
+ return tsocks_listen(LIBC_LISTEN_ARGS);
+}
diff --git a/src/lib/torsocks.h b/src/lib/torsocks.h
index 4dd0281..01c25b0 100644
--- a/src/lib/torsocks.h
+++ b/src/lib/torsocks.h
@@ -177,13 +177,13 @@ struct hostent **result, int *h_errnop
int sockfd, struct sockaddr *addr, socklen_t *addrlen
#define LIBC_ACCEPT_ARGS sockfd, addr, addrlen
-/* bind(2) */
-#define LIBC_BIND_NAME bind
-#define LIBC_BIND_NAME_STR XSTR(LIBC_BIND_NAME)
-#define LIBC_BIND_RET_TYPE int
-#define LIBC_BIND_SIG \
- int sockfd, const struct sockaddr *addr, socklen_t addrlen
-#define LIBC_BIND_ARGS sockfd, addr, addrlen
+/* listen(2) */
+#define LIBC_LISTEN_NAME listen
+#define LIBC_LISTEN_NAME_STR XSTR(LIBC_LISTEN_NAME)
+#define LIBC_LISTEN_RET_TYPE int
+#define LIBC_LISTEN_SIG \
+ int sockfd, int backlog
+#define LIBC_LISTEN_ARGS sockfd, backlog
#else
#error "OS not supported."
@@ -357,10 +357,10 @@ extern TSOCKS_LIBC_DECL(accept4, LIBC_ACCEPT4_RET_TYPE, LIBC_ACCEPT4_SIG)
LIBC_ACCEPT4_NAME(LIBC_ACCEPT4_SIG)
#endif
-/* bind(2) */
-extern TSOCKS_LIBC_DECL(bind, LIBC_BIND_RET_TYPE, LIBC_BIND_SIG)
-#define LIBC_BIND_DECL LIBC_BIND_RET_TYPE \
- LIBC_BIND_NAME(LIBC_BIND_SIG)
+/* listen(2) */
+extern TSOCKS_LIBC_DECL(bind, LIBC_LISTEN_RET_TYPE, LIBC_LISTEN_SIG)
+#define LIBC_LISTEN_DECL LIBC_LISTEN_RET_TYPE \
+ LIBC_LISTEN_NAME(LIBC_LISTEN_SIG)
/*
* Those are actions to do during the lookup process of libc symbols. For
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits