[Lldb-commits] [lldb] r191618 - If setgid fails for any reason, exit lldb.
Sylvestre Ledru
sylvestre at debian.org
Sat Sep 28 08:47:38 PDT 2013
Author: sylvestre
Date: Sat Sep 28 10:47:38 2013
New Revision: 191618
URL: http://llvm.org/viewvc/llvm-project?rev=191618&view=rev
Log:
If setgid fails for any reason, exit lldb.
scan-build was complaining about:
The return value from the call to 'setgid' is not checked. If an error occurs in 'setgid', the following code may execute with unexpected privileges
Modified:
lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp
Modified: lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp?rev=191618&r1=191617&r2=191618&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp (original)
+++ lldb/trunk/source/Plugins/Process/Linux/ProcessMonitor.cpp Sat Sep 28 10:47:38 2013
@@ -1111,7 +1111,8 @@ ProcessMonitor::Launch(LaunchArgs *args)
eDupStdoutFailed,
eDupStderrFailed,
eChdirFailed,
- eExecFailed
+ eExecFailed,
+ eSetGidFailed
};
// Child process.
@@ -1122,7 +1123,8 @@ ProcessMonitor::Launch(LaunchArgs *args)
exit(ePtraceFailed);
// Do not inherit setgid powers.
- setgid(getgid());
+ if (setgid(getgid()) != 0)
+ exit(eSetGidFailed);
// Let us have our own process group.
setpgid(0, 0);
@@ -1187,6 +1189,9 @@ ProcessMonitor::Launch(LaunchArgs *args)
case eExecFailed:
args->m_error.SetErrorString("Child exec failed.");
break;
+ case eSetGidFailed:
+ args->m_error.SetErrorString("Child setgid failed.");
+ break;
default:
args->m_error.SetErrorString("Child returned unknown exit status.");
break;
More information about the lldb-commits
mailing list