From 9b4148b12ca631b9cb8f48a03adb1fad146ee53d Mon Sep 17 00:00:00 2001 From: deraadt Date: Sun, 24 Oct 2021 21:24:17 +0000 Subject: For open/openat, if the flags parameter does not contain O_CREAT, the 3rd (variadic) mode_t parameter is irrelevant. Many developers in the past have passed mode_t (0, 044, 0644, or such), which might lead future people to copy this broken idiom, and perhaps even believe this parameter has some meaning or implication or application. Delete them all. This comes out of a conversation where tb@ noticed that a strange (but intentional) pledge behaviour is to always knock-out high-bits from mode_t on a number of system calls as a safety factor, and his bewilderment that this appeared to be happening against valid modes (at least visually), but no sorry, they are all irrelevant junk. They could all be 0xdeafbeef. ok millert --- cmd-pipe-pane.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmd-pipe-pane.c') diff --git a/cmd-pipe-pane.c b/cmd-pipe-pane.c index ed08e618..1a8c851b 100644 --- a/cmd-pipe-pane.c +++ b/cmd-pipe-pane.c @@ -131,7 +131,7 @@ cmd_pipe_pane_exec(struct cmd *self, struct cmdq_item *item) sigprocmask(SIG_SETMASK, &oldset, NULL); close(pipe_fd[0]); - null_fd = open(_PATH_DEVNULL, O_WRONLY, 0); + null_fd = open(_PATH_DEVNULL, O_WRONLY); if (out) { if (dup2(pipe_fd[1], STDIN_FILENO) == -1) _exit(1); -- cgit From 3b7dae9a5339c4495d30a4c1bb28ffe8aead0b27 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Mon, 2 May 2022 10:46:11 +0100 Subject: Do not allow pipe-pane on dead panes, from Anindya Mukherjee, GitHub issue 3174. --- cmd-pipe-pane.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'cmd-pipe-pane.c') diff --git a/cmd-pipe-pane.c b/cmd-pipe-pane.c index aac23a0f..0fa656ce 100644 --- a/cmd-pipe-pane.c +++ b/cmd-pipe-pane.c @@ -67,6 +67,12 @@ cmd_pipe_pane_exec(struct cmd *self, struct cmdq_item *item) struct format_tree *ft; sigset_t set, oldset; + /* Do nothing if pane is dead. */ + if (wp->fd == -1 || (wp->flags & PANE_EXITED)) { + cmdq_error(item, "target pane has exited"); + return (CMD_RETURN_ERROR); + } + /* Destroy the old pipe. */ old_fd = wp->pipe_fd; if (wp->pipe_fd != -1) { -- cgit