Skip to content

Commit

Permalink
[Inet] Fix setting for SOCK_CLOEXEC
Browse files Browse the repository at this point in the history
The linux kernel allows to set the flag SOCK_CLOEXEC through the
parameter type[1].

The implementation sets the flag through the parameter protocol and
causes the call to socket()[2] to return -1 with EINVAL.

This fixes the behaviour by OR-ing the flag SOCK_CLOEXEC to type instead
of protocol.

[1]: https://github.com/torvalds/linux/blob/v6.8/net/socket.c#L1655
[2]: https://man7.org/linux/man-pages/man2/socket.2.html
  • Loading branch information
gportay committed Apr 25, 2024
1 parent 22188b6 commit fb43d1a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/inet/InetInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ int GetIOCTLSocket()
{
int s;
#ifdef SOCK_CLOEXEC
s = socket(AF_INET, SOCK_STREAM, SOCK_CLOEXEC);
s = socket(AF_INET, SOCK_STREAM | SOCK_CLOEXEC, 0);
if (s < 0)
#endif
{
Expand Down

0 comments on commit fb43d1a

Please sign in to comment.