Skip to content

Commit

Permalink
prevent handlers from inheriting connected sockets
Browse files Browse the repository at this point in the history
  • Loading branch information
dimkr committed May 4, 2023
1 parent 205db52 commit 1841bef
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion gplaces.c
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ static int tcp_connect(const URL *url) {

for (it = result; it && err != EINTR; it = it->ai_next) {
if ((fd = socket(it->ai_family, it->ai_socktype, it->ai_protocol)) == -1) { err = errno; continue; }
if (setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)) == 0 && setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv)) == 0 && connect(fd, it->ai_addr, it->ai_addrlen) == 0) break;
if (fcntl(fd, F_SETFD, FD_CLOEXEC) == 0 && setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)) == 0 && setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv)) == 0 && connect(fd, it->ai_addr, it->ai_addrlen) == 0) break;
err = errno;
close(fd); fd = -1;
}
Expand Down

0 comments on commit 1841bef

Please sign in to comment.