forked from OSchip/llvm-project
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:
parent
30eff98e7e
commit
77c87c0510
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue