Fix panic when unwrapping if the server EOFs

This commit is contained in:
Jeff Mitchell
2016-11-29 16:50:07 -05:00
parent 4e4693e5de
commit b7c655f45c
2 changed files with 4 additions and 3 deletions

View File

@@ -135,9 +135,10 @@ func (c *Logical) Unwrap(wrappingToken string) (*Secret, error) {
} }
resp, err := c.c.RawRequest(r) resp, err := c.c.RawRequest(r)
if resp != nil { if resp == nil {
defer resp.Body.Close() return nil, nil
} }
defer resp.Body.Close()
if err != nil && resp.StatusCode != 404 { if err != nil && resp.StatusCode != 404 {
return nil, err return nil, err
} }

View File

@@ -62,7 +62,7 @@ func (c *UnwrapCommand) Run(args []string) int {
return 1 return 1
} }
if secret == nil { if secret == nil {
c.Ui.Error("Secret returned was nil") c.Ui.Error("Server gave empty response or secret returned was empty")
return 1 return 1
} }