replace nil ptr exceptions with infinite loops

This commit is contained in:
Matthew Hooker 2018-03-19 15:52:43 -07:00
parent b9bcde5a97
commit e2f9204c11
No known key found for this signature in database
GPG Key ID: 7B5F933D9CE8C6A1
1 changed files with 6 additions and 0 deletions

View File

@ -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())