fix(daemon): Validate process handle and ID before shutdown

This commit is contained in:
Nick Bolton
2025-04-15 23:10:46 +01:00
committed by Chris Rizzitello
parent 901dacf593
commit 8a2b6bd688

View File

@ -121,6 +121,16 @@ void MSWindowsProcess::shutdown(HANDLE handle, DWORD pid, int timeout)
{
LOG_DEBUG("shutting down process %d", pid);
if (handle == nullptr) {
LOG_ERR("invalid process handle, cannot shutdown process %d", pid);
return;
}
if (pid == 0) {
LOG_ERR("invalid process id, cannot shutdown process %d", pid);
return;
}
LOG_DEBUG("sending close event to close process gracefully");
HANDLE hCloseEvent = OpenEvent(EVENT_MODIFY_STATE, FALSE, kCloseEventName);
if (hCloseEvent != nullptr) { // NOSONAR -- Readability