Skip to content

Commit

Permalink
fix(ari): avoid Int63n panic in ShouldRenewAt() (#2246)
Browse files Browse the repository at this point in the history
  • Loading branch information
robstradling authored Aug 21, 2024
1 parent c083a98 commit 29e98f8
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions certificate/renewal.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@ func (r *RenewalInfoResponse) ShouldRenewAt(now time.Time, willingToSleep time.D
end := r.SuggestedWindow.End.UTC()

// Select a uniform random time within the suggested window.
window := end.Sub(start)
randomDuration := time.Duration(rand.Int63n(int64(window)))
rt := start.Add(randomDuration)
rt := start
if window := end.Sub(start); window > 0 {
randomDuration := time.Duration(rand.Int63n(int64(window)))
rt = rt.Add(randomDuration)
}

// If the selected time is in the past, attempt renewal immediately.
if rt.Before(now) {
Expand Down

0 comments on commit 29e98f8

Please sign in to comment.