Skip to content

Commit a7e2bdf

Browse files
authored
Merge pull request #1544 from JanDeDobbeleer/master
fix(linux): validate cpu fields length before accessing index
2 parents c020a08 + ac63a56 commit a7e2bdf

File tree

2 files changed

+1
-3
lines changed

2 files changed

+1
-3
lines changed

cpu/cpu_linux.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ func InfoWithContext(ctx context.Context) ([]InfoStat, error) {
309309
func parseStatLine(line string) (*TimesStat, error) {
310310
fields := strings.Fields(line)
311311

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

load/load_windows.go

-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ package load
55

66
import (
77
"context"
8-
"log"
98
"math"
109
"sync"
1110
"time"
@@ -37,7 +36,6 @@ func loadAvgGoroutine(ctx context.Context) {
3736

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

0 commit comments

Comments
 (0)