Skip to content

Commit

Permalink
[MAR-3131] Set grace to 0 on non-positive lease duration (hashicorp#1…
Browse files Browse the repository at this point in the history
…2372)

* [MAR-3131] Set grace to 0 on non-positive lease duration

* [MAR-3131] Add changelog

* [VAULT-3131] Add test for negative lease duration
  • Loading branch information
pmmukh authored and jartek committed Sep 11, 2021
1 parent fc0bf70 commit 2004a6a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion api/lifetime_watcher.go
Expand Up @@ -377,7 +377,7 @@ func (r *LifetimeWatcher) doRenewWithOptions(tokenMode bool, nonRenewable bool,
// assumptions given the total lease time; it also adds some jitter to not have
// clients be in sync.
func (r *LifetimeWatcher) calculateGrace(leaseDuration time.Duration) {
if leaseDuration == 0 {
if leaseDuration <= 0 {
r.grace = 0
return
}
Expand Down
11 changes: 11 additions & 0 deletions api/renewer_test.go
Expand Up @@ -149,6 +149,17 @@ func TestLifetimeWatcher(t *testing.T) {
nil,
false,
},
{
15 * time.Second,
"negative_lease_duration",
-15,
15,
func(_ string, _ int) (*Secret, error) {
return renewedSecret, nil
},
nil,
true,
},
}

for _, tc := range cases {
Expand Down
3 changes: 3 additions & 0 deletions changelog/12372.txt
@@ -0,0 +1,3 @@
```release-note: bug
core/api: Fix an arm64 bug converting a negative int to an unsigned int
```

0 comments on commit 2004a6a

Please sign in to comment.