From 59a7938d1f3c972e76ddf9e645b226e8ccb7ffed Mon Sep 17 00:00:00 2001 From: Ryan Uber Date: Thu, 2 Oct 2014 17:14:52 -0700 Subject: [PATCH] agent: guard against empty keyring files --- command/agent/keyring.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/command/agent/keyring.go b/command/agent/keyring.go index f6d80a9dce..6df94d3c9b 100644 --- a/command/agent/keyring.go +++ b/command/agent/keyring.go @@ -50,6 +50,11 @@ func loadKeyringFile(c *serf.Config) error { keysDecoded[i] = keyBytes } + // Guard against empty keyring + if len(keysDecoded) == 0 { + return fmt.Errorf("no keys present in keyring file: %s", c.KeyringFile) + } + // Create the keyring keyring, err := memberlist.NewKeyring(keysDecoded, keysDecoded[0]) if err != nil {