Skip to content

Commit 29e98f8

Browse files
authored
fix(ari): avoid Int63n panic in ShouldRenewAt() (#2246)
1 parent c083a98 commit 29e98f8

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

certificate/renewal.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,11 @@ func (r *RenewalInfoResponse) ShouldRenewAt(now time.Time, willingToSleep time.D
4141
end := r.SuggestedWindow.End.UTC()
4242

4343
// Select a uniform random time within the suggested window.
44-
window := end.Sub(start)
45-
randomDuration := time.Duration(rand.Int63n(int64(window)))
46-
rt := start.Add(randomDuration)
44+
rt := start
45+
if window := end.Sub(start); window > 0 {
46+
randomDuration := time.Duration(rand.Int63n(int64(window)))
47+
rt = rt.Add(randomDuration)
48+
}
4749

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

0 commit comments

Comments
 (0)