From a6e263adb66f93f562f07466ba4d3cece7a2af86 Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Fri, 13 Sep 2019 16:37:19 -0700 Subject: [PATCH] don't fall for nil pointer dereference in account file --- builder/googlecompute/step_create_windows_password.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/builder/googlecompute/step_create_windows_password.go b/builder/googlecompute/step_create_windows_password.go index 2fe8595ff..4f172c642 100644 --- a/builder/googlecompute/step_create_windows_password.go +++ b/builder/googlecompute/step_create_windows_password.go @@ -55,12 +55,17 @@ func (s *StepCreateWindowsPassword) Run(ctx context.Context, state multistep.Sta buf := make([]byte, 4) binary.BigEndian.PutUint32(buf, uint32(priv.E)) + email := "" + if c.Account != nil { + email = c.Account.Email + } + data := WindowsPasswordConfig{ key: priv, UserName: c.Comm.WinRMUser, Modulus: base64.StdEncoding.EncodeToString(priv.N.Bytes()), Exponent: base64.StdEncoding.EncodeToString(buf[1:]), - Email: c.Account.Email, + Email: email, ExpireOn: time.Now().Add(time.Minute * 5), }