From f789ecdcafc26e1ef6cba83af33e7f2260814ccb Mon Sep 17 00:00:00 2001 From: Michael Taufen Date: Mon, 28 Nov 2016 14:33:16 -0800 Subject: [PATCH] Fix nil pointer dereference in test framework Checking the result.Code prior to err in the if statement causes a panic if result is nil. It turns out the formatting of the error is already in IssueSSHCommandWithResult, so removing redundant code is enough to fix the issue. Logging the SSH result was also redundant, so I removed that as well. --- test/e2e/framework/util.go | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/test/e2e/framework/util.go b/test/e2e/framework/util.go index a48b9cf7bc..43a87ee3b2 100644 --- a/test/e2e/framework/util.go +++ b/test/e2e/framework/util.go @@ -3550,16 +3550,10 @@ func IssueSSHCommandWithResult(cmd, provider string, node *v1.Node) (*SSHResult, } func IssueSSHCommand(cmd, provider string, node *v1.Node) error { - result, err := IssueSSHCommandWithResult(cmd, provider, node) - if result != nil { - LogSSHResult(*result) + _, err := IssueSSHCommandWithResult(cmd, provider, node) + if err != nil { + return err } - - if result.Code != 0 || err != nil { - return fmt.Errorf("failed running %q: %v (exit code %d)", - cmd, err, result.Code) - } - return nil }