From 485497ee6744ca29d26a806418810d2d27cf5655 Mon Sep 17 00:00:00 2001 From: Benoit Jacob Date: Mon, 16 Nov 2020 23:01:44 -0500 Subject: [PATCH] redirect stderr to /dev/null when trying potentially incorrect flags --- client/TracySysTrace.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/client/TracySysTrace.cpp b/client/TracySysTrace.cpp index b1b4abdb..6783fbb1 100644 --- a/client/TracySysTrace.cpp +++ b/client/TracySysTrace.cpp @@ -847,6 +847,10 @@ static bool TrySuCommandFlag(const char* flag) { close( read_end ); dup2( write_end, STDOUT_FILENO ); close( write_end ); + // We redirect stderr to /dev/null because by nature this function + // tries incorrect command lines. + int null_fd = open("/dev/null", O_WRONLY); + dup2( null_fd, STDERR_FILENO ); execlp( "su", "su", flag, "id", "-u", nullptr ); exit( EXIT_FAILURE ); }