[NO NEW TESTS NEEDED] Fix off-by-one index comparision (reported by LGTM)

LGTM alert:

    Off-by-one index comparison against length may lead to out-of-bounds read.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
Stefan Weil 2021-10-24 22:44:38 +02:00
parent 283ce3de6c
commit d7662edf66

View file

@ -332,7 +332,7 @@ func readKernelVersion() (string, error) {
return "", err
}
f := bytes.Fields(buf)
if len(f) < 2 {
if len(f) < 3 {
return string(bytes.TrimSpace(buf)), nil
}
return string(f[2]), nil