Merge pull request #2456 from mitchellh/b-2416
Guard against uninitialized pointers in io.Copy in WinRM calls
This commit is contained in:
commit
e7092ff5c5
|
@ -85,8 +85,17 @@ func (c *Communicator) Start(rc *packer.RemoteCmd) error {
|
|||
func runCommand(shell *winrm.Shell, cmd *winrm.Command, rc *packer.RemoteCmd) {
|
||||
defer shell.Close()
|
||||
|
||||
go io.Copy(rc.Stdout, cmd.Stdout)
|
||||
go io.Copy(rc.Stderr, cmd.Stderr)
|
||||
if rc.Stdout != nil && cmd.Stdout != nil {
|
||||
go io.Copy(rc.Stdout, cmd.Stdout)
|
||||
} else {
|
||||
log.Printf("[WARN] Failed to read stdout for command '%s'", rc.Command)
|
||||
}
|
||||
|
||||
if rc.Stderr != nil && cmd.Stderr != nil {
|
||||
go io.Copy(rc.Stderr, cmd.Stderr)
|
||||
} else {
|
||||
log.Printf("[WARN] Failed to read stderr for command '%s'", rc.Command)
|
||||
}
|
||||
|
||||
cmd.Wait()
|
||||
|
||||
|
|
Loading…
Reference in New Issue