From a1eedcae8efd7fdd16406bfc68b8214c7b62e1b1 Mon Sep 17 00:00:00 2001 From: Jan De Dobbeleer Date: Mon, 30 Oct 2023 08:32:36 +0100 Subject: [PATCH] fix(linux): validate cpu fields length before accessing index --- cpu/cpu_linux.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpu/cpu_linux.go b/cpu/cpu_linux.go index b5a20e366..da467e2dd 100644 --- a/cpu/cpu_linux.go +++ b/cpu/cpu_linux.go @@ -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") }