From 2d05e072b92be797c07e610f5cd3ef150f56b92e Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Tue, 29 May 2018 12:04:30 -0400 Subject: [PATCH] Fix a null pointer and update status threshold --- http/sys_rekey.go | 20 ++++++++++---------- vault/rekey.go | 8 ++++++-- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/http/sys_rekey.go b/http/sys_rekey.go index 7fbc8d675..e8b53a1ea 100644 --- a/http/sys_rekey.go +++ b/http/sys_rekey.go @@ -64,11 +64,18 @@ func handleSysRekeyInitGet(ctx context.Context, core *vault.Core, recovery bool, return } + sealThreshold, err := core.RekeyThreshold(ctx, recovery) + if err != nil { + respondError(w, err.Code(), err) + return + } + // Format the status status := &RekeyStatusResponse{ - Started: false, - T: 0, - N: 0, + Started: false, + T: 0, + N: 0, + Required: sealThreshold, } if rekeyConf != nil { // Get the progress @@ -78,18 +85,11 @@ func handleSysRekeyInitGet(ctx context.Context, core *vault.Core, recovery bool, return } - sealThreshold, err := core.RekeyThreshold(ctx, recovery) - if err != nil { - respondError(w, err.Code(), err) - return - } - status.Nonce = rekeyConf.Nonce status.Started = started status.T = rekeyConf.SecretThreshold status.N = rekeyConf.SecretShares status.Progress = progress - status.Required = sealThreshold status.VerificationRequired = rekeyConf.VerificationRequired if rekeyConf.PGPKeys != nil && len(rekeyConf.PGPKeys) != 0 { pgpFingerprints, err := pgpkeys.GetFingerprints(rekeyConf.PGPKeys, nil) diff --git a/vault/rekey.go b/vault/rekey.go index 2bfb8fd00..c5555df07 100644 --- a/vault/rekey.go +++ b/vault/rekey.go @@ -359,7 +359,9 @@ func (c *Core) BarrierRekeyUpdate(ctx context.Context, key []byte, nonce string) // Schedule the rekey progress for forgetting defer func() { - c.barrierRekeyConfig.RekeyProgress = nil + if c.barrierRekeyConfig != nil { + c.barrierRekeyConfig.RekeyProgress = nil + } }() // Recover the master key or recovery key @@ -590,7 +592,9 @@ func (c *Core) RecoveryRekeyUpdate(ctx context.Context, key []byte, nonce string // Schedule the rekey progress for forgetting defer func() { - c.recoveryRekeyConfig.RekeyProgress = nil + if c.recoveryRekeyConfig != nil { + c.recoveryRekeyConfig.RekeyProgress = nil + } }() // Recover the master key