From e9c9ef8b439b448524ce9af2866a5b921adb87f9 Mon Sep 17 00:00:00 2001 From: Andrew Ayer Date: Wed, 7 May 2025 17:54:36 -0400 Subject: [PATCH] Avoid integer overflow leading to panic in rand.N --- monitor/monitor.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/monitor/monitor.go b/monitor/monitor.go index 8561fc3..92e73f6 100644 --- a/monitor/monitor.go +++ b/monitor/monitor.go @@ -60,9 +60,8 @@ func (e *verifyEntriesError) Error() string { } func withRetry(ctx context.Context, maxRetries int, f func() error) error { - const minSleep = 1 * time.Second - const maxSleep = 10 * time.Minute + minSleep := 1 * time.Second numRetries := 0 for ctx.Err() == nil { err := f() @@ -72,12 +71,11 @@ func withRetry(ctx context.Context, maxRetries int, f func() error) error { if maxRetries != -1 && numRetries >= maxRetries { return fmt.Errorf("%w (retried %d times)", err, numRetries) } - upperBound := min(minSleep*(1<