mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-21 10:19:03 +03:00
LibIPC: Make received file descriptors close-on-exec by default
I noticed that programs running in the terminal had an open file descriptor for the system theme buffer, inherited from the Terminal. Let's be nice and always mark incoming fds with FD_CLOEXEC.
This commit is contained in:
parent
2ed7f75e95
commit
05bb11f482
Notes:
sideshowbarker
2024-07-18 22:21:04 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/05bb11f4827
@ -30,6 +30,7 @@
|
||||
#include <LibIPC/Decoder.h>
|
||||
#include <LibIPC/Dictionary.h>
|
||||
#include <LibIPC/File.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <sys/socket.h>
|
||||
|
||||
@ -175,6 +176,10 @@ bool Decoder::decode([[maybe_unused]] File& file)
|
||||
dbgln("recvfd: {}", strerror(errno));
|
||||
return false;
|
||||
}
|
||||
if (fcntl(fd, F_SETFD, FD_CLOEXEC) < 0) {
|
||||
dbgln("fcntl(F_SETFD, FD_CLOEXEC)", strerror(errno));
|
||||
return false;
|
||||
}
|
||||
file = File(fd, File::ConstructWithReceivedFileDescriptor);
|
||||
return true;
|
||||
#else
|
||||
|
Loading…
Reference in New Issue
Block a user