diff --git a/cgroups/cgroups.go b/cgroups/cgroups.go index e108f310..5495c5c0 100644 --- a/cgroups/cgroups.go +++ b/cgroups/cgroups.go @@ -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" @@ -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]), diff --git a/cmd/runtimetest/mount/mountinfo_linux.go b/cmd/runtimetest/mount/mountinfo_linux.go index be69fee1..44170c8b 100644 --- a/cmd/runtimetest/mount/mountinfo_linux.go +++ b/cmd/runtimetest/mount/mountinfo_linux.go @@ -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) }