github-vet / github-vet/rangeloop-pointer-findings

mellow-io/v2ray-core: external/github.com/refraction-networking/utls/u_roller.go; 20 LoC

Open
#10,581 0 comments 0 reactions 0 assignees View on GitHub
fresh small
Dominant language
No language data
Stars
0
Forks
0
PR merge metrics
PR metrics pending

Description

Found a possible issue in [mellow-io/v2ray-core](https://www.github.com/mellow-io/v2ray-core) at [external/github.com/refraction-networking/utls/u_roller.go](https://github.com/mellow-io/v2ray-core/blob/125528f51391b77af79d37f958fa1f66f6b45d24/external/github.com/refraction-networking/utls/u_roller.go#L71-L90)

Below is the message reported by the analyzer for this snippet of code. Beware that the analyzer only reports the first
issue it finds, so please do not limit your consideration to the contents of the below message.

> reference to helloID is reassigned at line 87

[Click here to see the code in its original context.](https://github.com/mellow-io/v2ray-core/blob/125528f51391b77af79d37f958fa1f66f6b45d24/external/github.com/refraction-networking/utls/u_roller.go#L71-L90)

Click here to show the 20 line(s) of Go which triggered the analyzer.

```go
for _, helloID := range helloIDs {
tcpConn, err = net.DialTimeout(network, addr, c.TcpDialTimeout)
if err != nil {
return nil, err // on tcp Dial failure return with error right away
}

client := UClient(tcpConn, nil, helloID)
client.SetSNI(serverName)
client.SetDeadline(time.Now().Add(c.TlsHandshakeTimeout))
err = client.Handshake()
client.SetDeadline(time.Time{}) // unset timeout
if err != nil {
continue // on tls Dial error keep trying HelloIDs
}

c.HelloIDMu.Lock()
c.WorkingHelloID = &helloID
c.HelloIDMu.Unlock()
return client, err
}

```

Leave a reaction on this issue to contribute to the project by classifying this instance as a **Bug** :-1:, **Mitigated** :+1:, or **Desirable Behavior** :rocket:
See the descriptions of the classifications [here](https://github.com/github-vet/rangeclosure-findings#how-can-i-help) for more information.

commit ID: 125528f51391b77af79d37f958fa1f66f6b45d24

Contributor guide

No contributing guide indexed for this repository

Research direction

Open external/github.com/refraction-networking/utls/u_roller.go at lines 71-90 and review the range-loop pointer behavior around WorkingHelloID. Use the linked analyzer guidance to decide whether the reported reassignment is a Bug, Mitigated, or Desirable Behavior. Done means leaving the appropriate reaction on the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.