Created
January 11, 2018 19:27
-
-
Save jld/85fb031ecb64cac34731dc0c57b3b7c3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extern "C" MOZ_EXPORT int | |
connect(int sockfd, const struct sockaddr* addr, socklen_t addrlen) | |
{ | |
static auto sRealFunc = | |
(int (*)(int, const struct sockaddr*, socklen_t)) | |
dlsym(RTLD_NEXT, "connect"); | |
auto pid = getpid(); | |
if (addr == nullptr) { | |
SANDBOX_LOG_ERROR("connect[%d]: %d to nullptr", pid, sockfd); | |
} else { | |
if (addr->sa_family != AF_UNIX) { | |
SANDBOX_LOG_ERROR("connect[%d]: %d to family %d", pid, sockfd, addr->sa_family); | |
} else { | |
auto sun = reinterpret_cast<const struct sockaddr_un*>(addr); | |
if (sun->sun_path[0] == '\0') { | |
SANDBOX_LOG_ERROR("connect[%d]: %d to abstract %s", pid, sockfd, sun->sun_path + 1); | |
} else { | |
SANDBOX_LOG_ERROR("connect[%d]: %d to path %s", pid, sockfd, sun->sun_path); | |
} | |
} | |
} | |
return sRealFunc(sockfd, addr, addrlen); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment