fix(linux): validate cpu fields length before accessing index

pull/1544/head
Jan De Dobbeleer 2 years ago
parent c020a0890e
commit a1eedcae8e
No known key found for this signature in database
GPG Key ID: D9FE64756B9A61E6

@ -309,7 +309,7 @@ func InfoWithContext(ctx context.Context) ([]InfoStat, error) {
func parseStatLine(line string) (*TimesStat, error) { func parseStatLine(line string) (*TimesStat, error) {
fields := strings.Fields(line) fields := strings.Fields(line)
if len(fields) == 0 { if len(fields) < 8 {
return nil, errors.New("stat does not contain cpu info") return nil, errors.New("stat does not contain cpu info")
} }

Loading…
Cancel
Save