From 0f5b847748e00648bbf1d0961dc126ddd5257b65 Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Tue, 29 Nov 2016 16:50:07 -0500 Subject: [PATCH] Fix panic when unwrapping if the server EOFs --- api/logical.go | 5 +++-- command/unwrap.go | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/api/logical.go b/api/logical.go index d862438d4..6e9d1a129 100644 --- a/api/logical.go +++ b/api/logical.go @@ -135,9 +135,10 @@ func (c *Logical) Unwrap(wrappingToken string) (*Secret, error) { } resp, err := c.c.RawRequest(r) - if resp != nil { - defer resp.Body.Close() + if resp == nil { + return nil, nil } + defer resp.Body.Close() if err != nil && resp.StatusCode != 404 { return nil, err } diff --git a/command/unwrap.go b/command/unwrap.go index 24e4e5350..e4bfaf497 100644 --- a/command/unwrap.go +++ b/command/unwrap.go @@ -62,7 +62,7 @@ func (c *UnwrapCommand) Run(args []string) int { return 1 } if secret == nil { - c.Ui.Error("Secret returned was nil") + c.Ui.Error("Server gave empty response or secret returned was empty") return 1 }