Fix a null pointer and update status threshold

This commit is contained in:
Jeff Mitchell 2018-05-29 12:04:30 -04:00
parent bd0ac25eb9
commit 2d05e072b9
2 changed files with 16 additions and 12 deletions

View file

@ -64,11 +64,18 @@ func handleSysRekeyInitGet(ctx context.Context, core *vault.Core, recovery bool,
return return
} }
sealThreshold, err := core.RekeyThreshold(ctx, recovery)
if err != nil {
respondError(w, err.Code(), err)
return
}
// Format the status // Format the status
status := &RekeyStatusResponse{ status := &RekeyStatusResponse{
Started: false, Started: false,
T: 0, T: 0,
N: 0, N: 0,
Required: sealThreshold,
} }
if rekeyConf != nil { if rekeyConf != nil {
// Get the progress // Get the progress
@ -78,18 +85,11 @@ func handleSysRekeyInitGet(ctx context.Context, core *vault.Core, recovery bool,
return return
} }
sealThreshold, err := core.RekeyThreshold(ctx, recovery)
if err != nil {
respondError(w, err.Code(), err)
return
}
status.Nonce = rekeyConf.Nonce status.Nonce = rekeyConf.Nonce
status.Started = started status.Started = started
status.T = rekeyConf.SecretThreshold status.T = rekeyConf.SecretThreshold
status.N = rekeyConf.SecretShares status.N = rekeyConf.SecretShares
status.Progress = progress status.Progress = progress
status.Required = sealThreshold
status.VerificationRequired = rekeyConf.VerificationRequired status.VerificationRequired = rekeyConf.VerificationRequired
if rekeyConf.PGPKeys != nil && len(rekeyConf.PGPKeys) != 0 { if rekeyConf.PGPKeys != nil && len(rekeyConf.PGPKeys) != 0 {
pgpFingerprints, err := pgpkeys.GetFingerprints(rekeyConf.PGPKeys, nil) pgpFingerprints, err := pgpkeys.GetFingerprints(rekeyConf.PGPKeys, nil)

View file

@ -359,7 +359,9 @@ func (c *Core) BarrierRekeyUpdate(ctx context.Context, key []byte, nonce string)
// Schedule the rekey progress for forgetting // Schedule the rekey progress for forgetting
defer func() { defer func() {
c.barrierRekeyConfig.RekeyProgress = nil if c.barrierRekeyConfig != nil {
c.barrierRekeyConfig.RekeyProgress = nil
}
}() }()
// Recover the master key or recovery key // 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 // Schedule the rekey progress for forgetting
defer func() { defer func() {
c.recoveryRekeyConfig.RekeyProgress = nil if c.recoveryRekeyConfig != nil {
c.recoveryRekeyConfig.RekeyProgress = nil
}
}() }()
// Recover the master key // Recover the master key