From 4e938872bb04fc6b8549ef1c089e987d17f588bf Mon Sep 17 00:00:00 2001 From: "Joe Talerico (rook)" Date: Thu, 12 Oct 2023 15:59:23 -0400 Subject: [PATCH] Add additional check of netperf output (#112) If the netperf output isn't a specific length, error out Signed-off-by: Joe Talerico Co-authored-by: Joe Talerico --- pkg/netperf/netperf.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/netperf/netperf.go b/pkg/netperf/netperf.go index 21a1c3e9..a6d02355 100644 --- a/pkg/netperf/netperf.go +++ b/pkg/netperf/netperf.go @@ -94,6 +94,9 @@ func ParseResults(stdout *bytes.Buffer) (sample.Sample, error) { sample.Driver = workload send := 0.0 recv := 0.0 + if len(strings.Split(stdout.String(), "\n")) < 5 { + return sample, fmt.Errorf("Length of output from netperf was too short.") + } for _, line := range strings.Split(stdout.String(), "\n") { l := strings.Split(line, "=") if len(l) < 2 {