Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions cgroups/cgroups.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func FindCgroup() (Cgroup, error) {
fields := strings.Split(text, " ")
// Safe as mountinfo encodes mountpoints with spaces as \040.
index := strings.Index(text, " - ")
postSeparatorFields := strings.Fields(text[index+3:])
postSeparatorFields := strings.Split(text[index+3:], " ")
numPostFields := len(postSeparatorFields)

// This is an error as we can't detect if the mount is for "cgroup"
Expand All @@ -53,10 +53,7 @@ func FindCgroup() (Cgroup, error) {
}

if postSeparatorFields[0] == "cgroup" {
// Check that the mount is properly formated.
if numPostFields < 3 {
return nil, fmt.Errorf("Error found less than 3 fields post '-' in %q", text)
}
// No need to parse the rest of the postSeparatorFields

cg := &CgroupV1{
MountPath: filepath.Dir(fields[4]),
Expand Down
2 changes: 1 addition & 1 deletion cmd/runtimetest/mount/mountinfo_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func parseInfoFile(r io.Reader) ([]*Info, error) {
}
// Safe as mountinfo encodes mountpoints with spaces as \040.
index := strings.Index(text, " - ")
postSeparatorFields := strings.Fields(text[index+3:])
postSeparatorFields := strings.Split(text[index+3:], " ")
if len(postSeparatorFields) < 3 {
return nil, fmt.Errorf("Error found less than 3 fields post '-' in %q", text)
}
Expand Down