Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions src/lib/accept.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@ TSOCKS_LIBC_DECL(accept, LIBC_ACCEPT_RET_TYPE, LIBC_ACCEPT_SIG)
LIBC_ACCEPT_RET_TYPE tsocks_accept(LIBC_ACCEPT_SIG)
{
int ret;
socklen_t sa_len;
struct sockaddr sa;
socklen_t ss_len;
struct sockaddr_storage ss;

if (tsocks_config.allow_inbound) {
/* Allowed by the user so directly go to the libc. */
goto libc_call;
}

sa_len = sizeof(sa);
ss_len = sizeof(ss);

ret = getsockname(sockfd, &sa, &sa_len);
ret = getsockname(sockfd, (struct sockaddr*)&ss, &ss_len);
if (ret < 0) {
PERROR("[accept] getsockname");
goto error;
Expand All @@ -49,12 +49,12 @@ LIBC_ACCEPT_RET_TYPE tsocks_accept(LIBC_ACCEPT_SIG)
* accept() on a Unix socket is allowed else we are going to try to match
* it on INET localhost socket.
*/
if (sa.sa_family == AF_UNIX) {
if (ss.ss_family == AF_UNIX) {
goto libc_call;
}

/* Inbound localhost connections are allowed. */
ret = utils_sockaddr_is_localhost(&sa);
ret = utils_sockaddr_is_localhost((struct sockaddr*)&ss);
if (!ret) {
/*
* Accept is completely denied here since this means that the
Expand Down Expand Up @@ -97,17 +97,17 @@ TSOCKS_LIBC_DECL(accept4, LIBC_ACCEPT4_RET_TYPE, LIBC_ACCEPT4_SIG)
LIBC_ACCEPT4_RET_TYPE tsocks_accept4(LIBC_ACCEPT4_SIG)
{
int ret;
socklen_t sa_len;
struct sockaddr sa;
socklen_t ss_len;
struct sockaddr_storage ss;

if (tsocks_config.allow_inbound) {
/* Allowed by the user so directly go to the libc. */
goto libc_call;
}

sa_len = sizeof(sa);
ss_len = sizeof(ss);

ret = getsockname(sockfd, &sa, &sa_len);
ret = getsockname(sockfd, (struct sockaddr*)&ss, &ss_len);
if (ret < 0) {
PERROR("[accept4] getsockname");
goto error;
Expand All @@ -117,12 +117,12 @@ LIBC_ACCEPT4_RET_TYPE tsocks_accept4(LIBC_ACCEPT4_SIG)
* accept4() on a Unix socket is allowed else we are going to try to match
* it on INET localhost socket.
*/
if (sa.sa_family == AF_UNIX) {
if (ss.ss_family == AF_UNIX) {
goto libc_call;
}

/* Inbound localhost connections are allowed. */
ret = utils_sockaddr_is_localhost(&sa);
ret = utils_sockaddr_is_localhost((struct sockaddr*)&ss);
if (!ret) {

/*
Expand Down
10 changes: 5 additions & 5 deletions src/lib/listen.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ LIBC_LISTEN_RET_TYPE tsocks_listen(LIBC_LISTEN_SIG)
{
int ret;
socklen_t addrlen;
struct sockaddr sa;
struct sockaddr_storage ss;

if (tsocks_config.allow_inbound) {
/* Allowed by the user so directly go to the libc. */
goto libc_call;
}

addrlen = sizeof(sa);
addrlen = sizeof(ss);

ret = getsockname(sockfd, &sa, &addrlen);
ret = getsockname(sockfd, (struct sockaddr*)&ss, &addrlen);
if (ret < 0) {
PERROR("[listen] getsockname");
goto error;
Expand All @@ -49,12 +49,12 @@ LIBC_LISTEN_RET_TYPE tsocks_listen(LIBC_LISTEN_SIG)
* Listen () on a Unix socket is allowed else we are going to try to match
* it on INET localhost socket.
*/
if (sa.sa_family == AF_UNIX) {
if (ss.ss_family == AF_UNIX) {
goto libc_call;
}

/* Inbound localhost connections are allowed. */
ret = utils_sockaddr_is_localhost(&sa);
ret = utils_sockaddr_is_localhost((struct sockaddr*)&ss);
if (!ret) {
/*
* Listen is completely denied here since this means that the
Expand Down