Skip to content

Commit f4e8bf0

Browse files
fabriziosalmiclaude
andcommitted
fix: resolve gosec G115 integer overflow in retry backoff
Replace bit-shift with int-to-uint conversion with a fixed delay array, eliminating the potential integer overflow flagged by gosec. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 0b9b2d3 commit f4e8bf0

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

backend-go/internal/handlers/helpers.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,10 @@ func ssrfSafeClient(hostname string) *http.Client {
101101

102102
// downloadWithRetry fetches a URL (max maxBytes) with up to 3 retries (exp backoff).
103103
func downloadWithRetry(rawURL string, maxBytes int64) ([]byte, error) {
104+
retryDelay := [3]time.Duration{0, 1 * time.Second, 2 * time.Second}
104105
var lastErr error
105106
for attempt := 0; attempt < 3; attempt++ {
106-
if attempt > 0 {
107-
time.Sleep(time.Duration(1<<uint(attempt-1)) * time.Second)
108-
}
107+
time.Sleep(retryDelay[attempt])
109108
body, err := downloadOnce(rawURL, maxBytes)
110109
if err == nil {
111110
return body, nil

0 commit comments

Comments
 (0)