Other: Consider vault corrupt if it cannot be unmarshaled

This commit is contained in:
James Houlahan
2022-10-27 13:12:57 +02:00
parent b1ce2dd73f
commit d4c1016e55
2 changed files with 37 additions and 2 deletions

View File

@ -223,9 +223,13 @@ func newVault(path, gluonDir string, gcm cipher.AEAD) (*Vault, bool, error) {
var corrupt bool
if _, err := decrypt(gcm, enc); err != nil {
if dec, err := decrypt(gcm, enc); err != nil {
corrupt = true
} else if err := msgpack.Unmarshal(dec, new(Data)); err != nil {
corrupt = true
}
if corrupt {
newEnc, err := initVault(path, gluonDir, gcm)
if err != nil {
return nil, false, err