From 65d391dbeba24ebcb9a2bc8ea38b35654f996ddf Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sun, 13 Oct 2013 22:21:52 -1000 Subject: [PATCH] communicator/ssh: explicitly set c.conn = nil --- CHANGELOG.md | 2 ++ communicator/ssh/communicator.go | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 63505717d..68f07c792 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ BUG FIXES: * builder/digitalocean: scrub API keys from config debug output [GH-516] * builder/virtualbox: error if VirtualBox version cant be detected. [GH-488] * builder/virtualbox: detect if vboxdrv isn't properly setup. [GH-488] +* communicator/ssh: Fix issue where a panic could arise from a nil + dereference. [GH-525] ## 0.3.9 (October 2, 2013) diff --git a/communicator/ssh/communicator.go b/communicator/ssh/communicator.go index abdc46461..780dc425a 100644 --- a/communicator/ssh/communicator.go +++ b/communicator/ssh/communicator.go @@ -238,6 +238,14 @@ func (c *comm) reconnect() (err error) { log.Printf("reconnecting to TCP connection for SSH") c.conn, err = c.config.Connection() if err != nil { + // Explicitly set this to the REAL nil. Connection() can return + // a nil implementation of net.Conn which will make the + // "if c.conn == nil" check fail above. Read here for more information + // on this psychotic language feature: + // + // http://golang.org/doc/faq#nil_error + c.conn = nil + log.Printf("reconnection error: %s", err) return }