Skip to content

Commit

Permalink
Fix missing config key panic
Browse files Browse the repository at this point in the history
Changes the error message for a 0-length array to not reference the first
element of the array (thereby causing a panic)
  • Loading branch information
oholiab committed Aug 12, 2019
1 parent 6293434 commit ea6de15
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions config/vault_mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func (c *Config) parseMountConfig(list *ast.ObjectList) ([]*MountConfig, error)

for _, mountConfigAST := range list.Items {
if len(mountConfigAST.Keys) < 1 {
return nil, fmt.Errorf("Missing mount role name in line %+v", mountConfigAST.Keys[0].Pos())
return nil, fmt.Errorf("Missing mount role name in mount config stanza")
}

var m map[string]interface{}
Expand All @@ -218,7 +218,7 @@ func (c *Config) parseMountConfig(list *ast.ObjectList) ([]*MountConfig, error)
func (c *Config) parseMountRole(list *ast.ObjectList, mount *Mount) error {
for _, config := range list.Items {
if len(config.Keys) < 1 {
return fmt.Errorf("Missing mount role name in line %+v", config.Keys[0].Pos())
return fmt.Errorf("Missing mount role name in mount config stanza")
}

var m map[string]interface{}
Expand Down

0 comments on commit ea6de15

Please sign in to comment.