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:
commit
a7e2bdf91c
@ -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")
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user