1
0
mirror of https://github.com/shirou/gopsutil.git synced 2025-04-26 13:48:59 +08:00

Merge pull request #1544 from JanDeDobbeleer/master

fix(linux): validate cpu fields length before accessing index
This commit is contained in:
shirou 2023-10-30 22:11:25 +09:00 committed by GitHub
commit a7e2bdf91c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 1 additions and 3 deletions

View File

@ -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")
}

View File

@ -5,7 +5,6 @@ package load
import (
"context"
"log"
"math"
"sync"
"time"
@ -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
}