win: handle more than 2048 processes (#10997)

Fix an array out of bounds crash
This commit is contained in:
Daniel Hiltgen 2025-06-06 14:06:09 -07:00 committed by Ryan Schumacher
parent 1fb5a3d56a
commit 1b1eb74ab1
No known key found for this signature in database
1 changed files with 10 additions and 1 deletions

View File

@ -74,7 +74,16 @@ func isProcRunning(procName string) []uint32 {
slog.Debug("failed to check for running installers", "error", err)
return nil
}
pids = pids[:ret]
if ret > uint32(len(pids)) {
pids = make([]uint32, ret+10)
if err := windows.EnumProcesses(pids, &ret); err != nil || ret == 0 {
slog.Debug("failed to check for running installers", "error", err)
return nil
}
}
if ret < uint32(len(pids)) {
pids = pids[:ret]
}
var matches []uint32
for _, pid := range pids {
if pid == 0 {