Skip to content

Commit

Permalink
Barrier: Fix potential locking issue (hashicorp#17944)
Browse files Browse the repository at this point in the history
* Barrier: Fix potential locking issue

* add changelog
  • Loading branch information
briankassouf authored and jayant07-yb committed Mar 15, 2023
1 parent c071ffa commit 23abf6c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions changelog/17944.txt
@@ -0,0 +1,3 @@
```release-note:bug
core: Fix potential deadlock if barrier ciphertext is less than 4 bytes.
```
2 changes: 2 additions & 0 deletions vault/barrier_aes_gcm.go
Expand Up @@ -1069,11 +1069,13 @@ func (b *AESGCMBarrier) Decrypt(_ context.Context, key string, ciphertext []byte
}

if len(ciphertext) == 0 {
b.l.RUnlock()
return nil, fmt.Errorf("empty ciphertext")
}

// Verify the term
if len(ciphertext) < 4 {
b.l.RUnlock()
return nil, fmt.Errorf("invalid ciphertext term")
}
term := binary.BigEndian.Uint32(ciphertext[:4])
Expand Down

0 comments on commit 23abf6c

Please sign in to comment.