From 3f202002d9c2b510400216aea71ab1a71e8d5d2c Mon Sep 17 00:00:00 2001 From: Bryan Frimin Date: Wed, 22 Jul 2026 13:20:33 +0200 Subject: [PATCH] Fix parsing int error Signed-off-by: Bryan Frimin --- pkg/certmanager/acme_errors.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/certmanager/acme_errors.go b/pkg/certmanager/acme_errors.go index c8b80e880..75feee026 100644 --- a/pkg/certmanager/acme_errors.go +++ b/pkg/certmanager/acme_errors.go @@ -151,12 +151,12 @@ func parseRetryAfter(header http.Header) (time.Duration, bool) { } // The delta-seconds form is an unsigned decimal integer (RFC 9110 ยง10.2.3). - // Parsing it as unsigned rejects negative or otherwise malformed values so - // they fall back to the caller's default cooldown instead of collapsing to a - // zero/negative duration that would disable the rate-limit cooldown. A value + // Parse as signed 64-bit to match time.Duration's underlying type and avoid + // unsigned-to-signed narrowing conversions. Negative or malformed values are + // treated as unparseable so callers can apply their default cooldown. A value // larger than time.Duration can hold is clamped to the maximum duration. - if seconds, err := strconv.ParseUint(value, 10, 64); err == nil { - maxSeconds := uint64(math.MaxInt64 / int64(time.Second)) + if seconds, err := strconv.ParseInt(value, 10, 64); err == nil && seconds >= 0 { + maxSeconds := int64(math.MaxInt64 / int64(time.Second)) if seconds > maxSeconds { return time.Duration(math.MaxInt64), true }