Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accept connections even when syncookies are disabled. #8

Merged
merged 3 commits into from
Jan 8, 2017
Merged
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
11 changes: 9 additions & 2 deletions common.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ int tcp_bind(const struct sockaddr *addr, socklen_t len)
break;
default:
errno = EINVAL;
UNIXERR("addr");
return -1;
}

Expand Down Expand Up @@ -119,7 +120,10 @@ int tcp_bind(const struct sockaddr *addr, socklen_t len)
int tcp_listen(const struct sockaddr *addr, socklen_t len)
{
int sock = tcp_bind(addr, len);
if (listen(sock, 0) < 0) {
if (sock < 0) {
return -1;
}
if (listen(sock, SOMAXCONN) < 0) {
UNIXERR("bind");
close(sock);
return -1;
Expand All @@ -130,11 +134,14 @@ int tcp_listen(const struct sockaddr *addr, socklen_t len)
int tcp_listen_nonblock(const struct sockaddr *addr, socklen_t len)
{
int sock = tcp_bind(addr, len);
if (sock < 0) {
return -1;
}
if (setnonblock(sock)) {
close(sock);
return -1;
}
if (listen(sock, 0) < 0) {
if (listen(sock, SOMAXCONN) < 0) {
UNIXERR("bind");
close(sock);
return -1;
Expand Down
2 changes: 0 additions & 2 deletions server.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,6 @@ listener_t *start_unix_listener(const char *socketfile)
int sock;
mode_t old;

unlink(socketfile);

old = umask(0111);
strncpy(addr.sun_path, socketfile, sizeof(addr.sun_path) - 1);
addr.sun_path[sizeof(addr.sun_path) - 1] = 0;
Expand Down