From 5d4db4f093de1256bcb25e1958a76a03102dc77d Mon Sep 17 00:00:00 2001 From: Max Lv Date: Tue, 4 Aug 2015 09:23:15 +0800 Subject: [PATCH] use abstract namespace --- src/android.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/android.c b/src/android.c index 33a76eea..eb30fb32 100644 --- a/src/android.c +++ b/src/android.c @@ -61,13 +61,15 @@ int protect_socket(int fd) { setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof(struct timeval)); setsockopt(sock, SOL_SOCKET, SO_SNDTIMEO, (char *)&tv, sizeof(struct timeval)); - const char path[] = "/data/data/com.github.shadowsocks/protect_path"; + const char path[] = "#shadowsocks_protect"; memset(&addr, 0, sizeof(addr)); addr.sun_family = AF_UNIX; strncpy(addr.sun_path, path, sizeof(addr.sun_path)-1); + addr.sun_path[0] = 0; + socklen_t len = strlen(path) + offsetof(struct sockaddr_un, sun_path); - if (connect(sock, (struct sockaddr*)&addr, sizeof(addr)) == -1) { + if (connect(sock, (struct sockaddr*)&addr, len) == -1) { LOGE("[android] connect() failed: %s (socket fd = %d)\n", strerror(errno), sock); close(sock); return -1;