[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [sandboxed-tor-browser/master] Use the GCC constructor attribute for stub initialization.
commit d3e4fd26e46ab258e4a5daa0541c7253989ed35f
Author: Yawning Angel <yawning@xxxxxxxxxxxxxxx>
Date: Thu Aug 31 10:03:30 2017 +0000
Use the GCC constructor attribute for stub initialization.
Non-portable but this is cleaner.
---
ChangeLog | 1 +
src/tbb_stub/tbb_stub.c | 11 +----------
2 files changed, 2 insertions(+), 10 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 0bf64e8..09a23eb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,7 @@ Changes in version 0.0.13 - UNRELEASED:
* Use lockPref for the IDN override done as part of #22984.
* Unset the addon autoupdater URL prefs.
* Disable the "Open with" dialog, which will never work.
+ * Use the GCC constructor attribute for stub initialization.
Changes in version 0.0.12 - 2017-08-01:
* Bug 22969: Disable the addon blocklist.
diff --git a/src/tbb_stub/tbb_stub.c b/src/tbb_stub/tbb_stub.c
index 84a14e8..819c8e0 100644
--- a/src/tbb_stub/tbb_stub.c
+++ b/src/tbb_stub/tbb_stub.c
@@ -52,7 +52,6 @@
#include <stdlib.h>
#include <unistd.h>
-static pthread_once_t stub_init_once = PTHREAD_ONCE_INIT;
static int (*real_connect)(int, const struct sockaddr *, socklen_t) = NULL;
static int (*real_socket)(int, int, int) = NULL;
static void *(*real_dlopen)(const char *, int) = NULL;
@@ -66,9 +65,6 @@ static struct sockaddr_un control_addr;
#define TBB_SOCKS_PORT 9150
#define TBB_CONTROL_PORT 9151
-
-static void stub_init(void);
-
int
connect(int fd, const struct sockaddr *address, socklen_t address_len)
{
@@ -80,8 +76,6 @@ connect(int fd, const struct sockaddr *address, socklen_t address_len)
return -1;
}
- pthread_once(&stub_init_once, stub_init);
-
/* Fast path for non-outgoing sockets. */
if (address->sa_family == AF_LOCAL) {
return real_connect(fd, address, address_len);
@@ -121,8 +115,6 @@ connect(int fd, const struct sockaddr *address, socklen_t address_len)
int
socket(int domain, int type, int protocol)
{
- pthread_once(&stub_init_once, stub_init);
-
/* Replace AF_INET with AF_LOCAL. */
if (domain == AF_INET)
domain = AF_LOCAL;
@@ -145,7 +137,6 @@ void *
dlopen(const char *filename, int flags)
{
void *ret;
- pthread_once(&stub_init_once, stub_init);
if (filename != NULL) {
if (has_prefix(filename, "libgnomeui"))
@@ -301,7 +292,7 @@ pthread_attr_getstack(const pthread_attr_t *attr, void **stackaddr, size_t *stac
}
/* Initialize the stub. */
-static void
+__attribute__((constructor)) static void
stub_init(void)
{
char *socks_path = secure_getenv("TOR_STUB_SOCKS_SOCKET");
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits