Skip to content

Commit 9e2366f

Browse files
authored
Merge pull request #7294 from mikhail5555/fix/data-race-condition-global-variable
Fix(clientpool): remove global variable from clientpool in favour for local variable
2 parents aa529cd + a8c8645 commit 9e2366f

File tree

2 files changed

+4
-19
lines changed

2 files changed

+4
-19
lines changed

pkg/protocols/common/protocolinit/init.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"github.com/projectdiscovery/nuclei/v3/pkg/js/compiler"
55
"github.com/projectdiscovery/nuclei/v3/pkg/protocols/common/protocolstate"
66
"github.com/projectdiscovery/nuclei/v3/pkg/protocols/dns/dnsclientpool"
7-
"github.com/projectdiscovery/nuclei/v3/pkg/protocols/http/httpclientpool"
87
"github.com/projectdiscovery/nuclei/v3/pkg/protocols/http/signerpool"
98
"github.com/projectdiscovery/nuclei/v3/pkg/protocols/network/networkclientpool"
109
"github.com/projectdiscovery/nuclei/v3/pkg/protocols/whois/rdapclientpool"
@@ -20,9 +19,6 @@ func Init(options *types.Options) error {
2019
if err := dnsclientpool.Init(options); err != nil {
2120
return err
2221
}
23-
if err := httpclientpool.Init(options); err != nil {
24-
return err
25-
}
2622
if err := signerpool.Init(options); err != nil {
2723
return err
2824
}

pkg/protocols/http/httpclientpool/clientpool.go

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,6 @@ import (
2828
urlutil "github.com/projectdiscovery/utils/url"
2929
)
3030

31-
var (
32-
forceMaxRedirects int
33-
)
34-
35-
// Init initializes the clientpool implementation
36-
func Init(options *types.Options) error {
37-
if options.ShouldFollowHTTPRedirects() {
38-
forceMaxRedirects = options.MaxRedirects
39-
}
40-
41-
return nil
42-
}
43-
4431
// ConnectionConfiguration contains the custom configuration options for a connection
4532
type ConnectionConfiguration struct {
4633
// DisableKeepAlive of the connection
@@ -221,15 +208,17 @@ func wrappedGet(options *types.Options, configuration *Configuration) (*retryabl
221208
redirectFlow := configuration.RedirectFlow
222209
maxRedirects := configuration.MaxRedirects
223210

224-
if forceMaxRedirects > 0 {
211+
if options.ShouldFollowHTTPRedirects() {
225212
// by default we enable general redirects following
226213
switch {
227214
case options.FollowHostRedirects:
228215
redirectFlow = FollowSameHostRedirect
229216
default:
230217
redirectFlow = FollowAllRedirect
231218
}
232-
maxRedirects = forceMaxRedirects
219+
if options.MaxRedirects > 0 {
220+
maxRedirects = options.MaxRedirects
221+
}
233222
}
234223
if options.DisableRedirects {
235224
options.FollowRedirects = false

0 commit comments

Comments
 (0)