Skip to content

Commit

Permalink
Merge pull request #1544 from JanDeDobbeleer/master
Browse files Browse the repository at this point in the history
fix(linux): validate cpu fields length before accessing index
  • Loading branch information
shirou authored Oct 30, 2023
2 parents c020a08 + ac63a56 commit a7e2bdf
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 3 deletions.
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
2 changes: 0 additions & 2 deletions load/load_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package load

import (
"context"
"log"
"math"
"sync"
"time"
Expand Down Expand Up @@ -37,7 +36,6 @@ func loadAvgGoroutine(ctx context.Context) {

counter, err := common.ProcessorQueueLengthCounter()
if err != nil || counter == nil {
log.Printf("unexpected processor queue length counter error, %v\n", err)
return
}

Expand Down

0 comments on commit a7e2bdf

Please sign in to comment.