Skip to content

Commit

Permalink
fix(linux): validate cpu fields length before accessing index
Browse files Browse the repository at this point in the history
  • Loading branch information
JanDeDobbeleer committed Oct 30, 2023
1 parent c020a08 commit a1eedca
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion cpu/cpu_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ func InfoWithContext(ctx context.Context) ([]InfoStat, error) {
func parseStatLine(line string) (*TimesStat, error) {
fields := strings.Fields(line)

if len(fields) == 0 {
if len(fields) < 8 {
return nil, errors.New("stat does not contain cpu info")
}

Expand Down

0 comments on commit a1eedca

Please # to comment.