Crashlog: Do not try to read from other executables if /dev/null is missing

pull/393/head
Jonathan G Rennison 2 years ago
parent 9d0e3e22b7
commit 4a0fa0cc75

@ -50,6 +50,9 @@
#if !defined(WITHOUT_DBG_LLDB)
static bool ExecReadStdout(const char *file, char *const *args, char *&buffer, const char *last)
{
int null_fd = open("/dev/null", O_RDWR);
if (null_fd == -1) return false;
int pipefd[2];
if (pipe(pipefd) == -1) return false;
@ -62,11 +65,9 @@ static bool ExecReadStdout(const char *file, char *const *args, char *&buffer, c
close(pipefd[0]); /* Close unused read end */
dup2(pipefd[1], STDOUT_FILENO);
close(pipefd[1]);
int null_fd = open("/dev/null", O_RDWR);
if (null_fd != -1) {
dup2(null_fd, STDERR_FILENO);
dup2(null_fd, STDIN_FILENO);
}
dup2(null_fd, STDERR_FILENO);
dup2(null_fd, STDIN_FILENO);
close(null_fd);
execvp(file, args);
exit(42);
@ -74,6 +75,7 @@ static bool ExecReadStdout(const char *file, char *const *args, char *&buffer, c
/* parent */
close(null_fd);
close(pipefd[1]); /* Close unused write end */
while (buffer < last) {

@ -74,6 +74,9 @@ static void LogStacktraceSigSegvHandler(int sig)
static bool ExecReadStdout(const char *file, char *const *args, char *&buffer, const char *last)
{
int null_fd = open("/dev/null", O_RDWR);
if (null_fd == -1) return false;
int pipefd[2];
if (pipe(pipefd) == -1) return false;
@ -86,11 +89,9 @@ static bool ExecReadStdout(const char *file, char *const *args, char *&buffer, c
close(pipefd[0]); /* Close unused read end */
dup2(pipefd[1], STDOUT_FILENO);
close(pipefd[1]);
int null_fd = open("/dev/null", O_RDWR);
if (null_fd != -1) {
dup2(null_fd, STDERR_FILENO);
dup2(null_fd, STDIN_FILENO);
}
dup2(null_fd, STDERR_FILENO);
dup2(null_fd, STDIN_FILENO);
close(null_fd);
execvp(file, args);
exit(42);
@ -98,6 +99,7 @@ static bool ExecReadStdout(const char *file, char *const *args, char *&buffer, c
/* parent */
close(null_fd);
close(pipefd[1]); /* Close unused write end */
while (buffer < last) {

Loading…
Cancel
Save