Skip to content

Commit 5a37b30

Browse files
authored
fix: guard http client timeout against int overflow (#194)
Signed-off-by: Chris Gianelloni <[email protected]>
1 parent 11a979f commit 5a37b30

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

internal/api/api.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2024 Blink Labs Software
1+
// Copyright 2025 Blink Labs Software
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -20,6 +20,7 @@ import (
2020
"encoding/hex"
2121
"fmt"
2222
"io"
23+
"math"
2324
"net/http"
2425
"net/http/httptrace"
2526
"strings"
@@ -275,8 +276,12 @@ func handleSubmitTx(c *gin.Context) {
275276

276277
// createHTTPClient with custom timeout
277278
func createHTTPClient(cfg *config.Config) *http.Client {
279+
timeout := int64(60000)
280+
if cfg.Api.ClientTimeout < math.MaxInt64 {
281+
timeout = int64(cfg.Api.ClientTimeout) // #nosec G115
282+
}
278283
return &http.Client{
279-
Timeout: time.Duration(cfg.Api.ClientTimeout) * time.Millisecond,
284+
Timeout: time.Duration(timeout) * time.Millisecond,
280285
Transport: &http.Transport{
281286
MaxIdleConns: 100,
282287
IdleConnTimeout: 90 * time.Second,

0 commit comments

Comments
 (0)