Skip to content

Commit ac843e0

Browse files
authored
Merge pull request #1806 from nanjj/badpid
incusd/instance/common: Improve PID validation
2 parents 36e1756 + 35943f8 commit ac843e0

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

internal/server/instance/drivers/driver_common.go

+4
Original file line numberDiff line numberDiff line change
@@ -1597,6 +1597,10 @@ func (d *common) balanceNUMANodes() error {
15971597

15981598
// Gets the process starting time.
15991599
func (d *common) processStartedAt(pid int) (time.Time, error) {
1600+
if pid < 1 {
1601+
return time.Time{}, fmt.Errorf("Invalid PID %q", pid)
1602+
}
1603+
16001604
file, err := os.Stat(fmt.Sprintf("/proc/%d", pid))
16011605
if err != nil {
16021606
return time.Time{}, err

0 commit comments

Comments
 (0)