Merge pull request #11463 from flouthoc/cgroup-info-fix-panic

cgroup-info: check if user.slice is valid before accessing value
This commit is contained in:
OpenShift Merge Robot
2021-09-07 09:40:39 +02:00
committed by GitHub

View File

@ -231,7 +231,10 @@ func getCgroupPathForCurrentProcess() (string, error) {
for s.Scan() { for s.Scan() {
text := s.Text() text := s.Text()
procEntries := strings.SplitN(text, "::", 2) procEntries := strings.SplitN(text, "::", 2)
cgroupPath = procEntries[1] // set process cgroupPath only if entry is valid
if len(procEntries) > 1 {
cgroupPath = procEntries[1]
}
} }
if err := s.Err(); err != nil { if err := s.Err(); err != nil {
return cgroupPath, err return cgroupPath, err