Commit e7092ff5 authored by Chris Bednarski's avatar Chris Bednarski

Merge pull request #2456 from mitchellh/b-2416

Guard against uninitialized pointers in io.Copy in WinRM calls
parents c614bb70 29e6194e
...@@ -85,8 +85,17 @@ func (c *Communicator) Start(rc *packer.RemoteCmd) error { ...@@ -85,8 +85,17 @@ func (c *Communicator) Start(rc *packer.RemoteCmd) error {
func runCommand(shell *winrm.Shell, cmd *winrm.Command, rc *packer.RemoteCmd) { func runCommand(shell *winrm.Shell, cmd *winrm.Command, rc *packer.RemoteCmd) {
defer shell.Close() defer shell.Close()
go io.Copy(rc.Stdout, cmd.Stdout) if rc.Stdout != nil && cmd.Stdout != nil {
go io.Copy(rc.Stderr, cmd.Stderr) 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() cmd.Wait()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment