From e2f9204c11bc5623e9284832e2e5231f01112fa2 Mon Sep 17 00:00:00 2001 From: Matthew Hooker Date: Mon, 19 Mar 2018 15:52:43 -0700 Subject: [PATCH] replace nil ptr exceptions with infinite loops --- communicator/ssh/communicator.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/communicator/ssh/communicator.go b/communicator/ssh/communicator.go index d81ab750a..6fedb479c 100644 --- a/communicator/ssh/communicator.go +++ b/communicator/ssh/communicator.go @@ -423,6 +423,9 @@ func (c *comm) sftpUploadFile(path string, input io.Reader, client *sftp.Client, } cmd.Wait() if cmd.ExitStatus == 0 { + if fi == nil { + return fmt.Errorf("Upload path is a directory, unable to continue.") + } log.Printf("path is a directory; copying file into directory.") path = filepath.Join(path, filepath.Base((*fi).Name())) } @@ -586,6 +589,9 @@ func (c *comm) scpUploadSession(path string, input io.Reader, fi *os.FileInfo) e } cmd.Wait() if cmd.ExitStatus == 0 { + if fi == nil { + return fmt.Errorf("Upload path is a directory, unable to continue.") + } log.Printf("path is a directory; copying file into directory.") target_dir = path target_file = filepath.Base((*fi).Name())