mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-10 01:51:03 +09:00
LibCore: Make sockets close-on-exec by default
This mirrors the previous default in Core::LocalSocket, and is the safer default anyway. This prevents fds from living on in other processes when exec() is called in certain programs such as Assistant. Fixes #12029.
This commit is contained in:
parent
483ab7fe26
commit
3de51a4b99
Notes:
sideshowbarker
2024-07-17 20:32:19 +09:00
Author: https://github.com/sin-ack
Commit: 3de51a4b99
Pull-request: https://github.com/SerenityOS/serenity/pull/12045
Issue: https://github.com/SerenityOS/serenity/issues/12029
1 changed files with 8 additions and 1 deletions
|
@ -241,7 +241,14 @@ ErrorOr<int> Socket::create_fd(SocketDomain domain, SocketType type)
|
|||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
return System::socket(socket_domain, socket_type, 0);
|
||||
// Let's have a safe default of CLOEXEC. :^)
|
||||
#ifdef SOCK_CLOEXEC
|
||||
return System::socket(socket_domain, socket_type | SOCK_CLOEXEC, 0);
|
||||
#else
|
||||
auto fd = TRY(System::socket(socket_domain, socket_type, 0));
|
||||
TRY(System::fcntl(fd, F_SETFD, FD_CLOEXEC));
|
||||
return fd;
|
||||
#endif
|
||||
}
|
||||
|
||||
ErrorOr<IPv4Address> Socket::resolve_host(String const& host, SocketType type)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue