commit 7330bab
Arusekk
·
2026-01-18 11:22:38 +0000 UTC
parent 95261ce
launch: prevent tty leak and other possible leaks
1 files changed,
+3,
-3
+3,
-3
1@@ -243,7 +243,7 @@ handle_socket_data(int socket)
2 goto fail;
3 }
4
5- fd = open(path, request.flags);
6+ fd = open(path, request.flags | O_CLOEXEC);
7 if (fd == -1) {
8 fprintf(stderr, "open %s: %s\n", path, strerror(errno));
9 goto fail;
10@@ -325,7 +325,7 @@ find_vt(char *vt, size_t size)
11 * new VT instead of using the current one. */
12 if (getenv("DISPLAY") || getenv("WAYLAND_DISPLAY") ||
13 !(vtnr = getenv("XDG_VTNR"))) {
14- tty0_fd = open("/dev/tty0", O_RDWR);
15+ tty0_fd = open("/dev/tty0", O_RDWR | O_CLOEXEC);
16 if (tty0_fd == -1) {
17 die("open /dev/tty0:");
18 }
19@@ -356,7 +356,7 @@ open_tty(const char *tty_name)
20 return STDIN_FILENO;
21 }
22
23- fd = open(tty_name, O_RDWR | O_NOCTTY);
24+ fd = open(tty_name, O_RDWR | O_NOCTTY | O_CLOEXEC);
25 if (fd < 0) {
26 die("open %s:", tty_name);
27 }