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

llvm-svn: 191618
This commit is contained in:
Sylvestre Ledru 2013-09-28 15:47:38 +00:00
parent 30eff98e7e
commit 77c87c0510
1 changed files with 7 additions and 2 deletions

View File

@ -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;