From fbc6c68f3d3955791791bd46d423839113a62b57 Mon Sep 17 00:00:00 2001 From: Mahmoud Al-Qudsi Date: Thu, 8 Feb 2018 17:05:13 -0600 Subject: [PATCH] Handle error opening /dev/null in `redirect_tty_output` This fixes coverity scan defect number 7520299 --- src/common.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/common.cpp b/src/common.cpp index 4c88ca4fc..98fc57238 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -2091,6 +2091,9 @@ bool fish_reserved_codepoint(wchar_t c) { void redirect_tty_output() { struct termios t; int fd = open("/dev/null", O_WRONLY); + if (fd == -1) { + __fish_assert("Could not open /dev/null!", __FILE__, __LINE__, errno); + } if (tcgetattr(STDIN_FILENO, &t) == -1 && errno == EIO) dup2(fd, STDIN_FILENO); if (tcgetattr(STDOUT_FILENO, &t) == -1 && errno == EIO) dup2(fd, STDOUT_FILENO); if (tcgetattr(STDERR_FILENO, &t) == -1 && errno == EIO) dup2(fd, STDERR_FILENO);