From f92951b835c3e35a3b2e408344d959f5e51cee6e Mon Sep 17 00:00:00 2001 From: Vladimir Mihailenco Date: Wed, 28 Oct 2020 11:12:46 +0200 Subject: [PATCH] Guard against overflow in retry --- internal/internal.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/internal/internal.go b/internal/internal.go index 735d6aff..4a59c599 100644 --- a/internal/internal.go +++ b/internal/internal.go @@ -15,6 +15,10 @@ func RetryBackoff(retry int, minBackoff, maxBackoff time.Duration) time.Duration } d := minBackoff << uint(retry) + if d < minBackoff { + return maxBackoff + } + d = minBackoff + time.Duration(rand.Int63n(int64(d))) if d > maxBackoff || d < minBackoff {