github-vet / github-vet/rangeloop-pointer-findings
EvanPurkhiser/prolink-go: prolink.go; 33 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [EvanPurkhiser/prolink-go](https://www.github.com/EvanPurkhiser/prolink-go) at [prolink.go](https://github.com/EvanPurkhiser/prolink-go/blob/4454c6432a01bcc930fbf443ffc2f14b39ba6fd8/prolink.go#L168-L200)
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 possibleIface is reassigned at line 190
[Click here to see the code in its original context.](https://github.com/EvanPurkhiser/prolink-go/blob/4454c6432a01bcc930fbf443ffc2f14b39ba6fd8/prolink.go#L168-L200)
Click here to show the 33 line(s) of Go which triggered the analyzer.
```go
for _, possibleIface := range ifaces {
if possibleIface.Flags&net.FlagUp == 0 {
continue
}
addrs, err := possibleIface.Addrs()
if err != nil {
return nil, err
}
var matchedIface *net.Interface
matchedSubnetLen := 0x00
for _, addr := range addrs {
ifaceIP, ok := addr.(*net.IPNet)
if !ok {
continue
}
subnetLen, _ := ifaceIP.Mask.Size()
if ifaceIP.Contains(ip) && subnetLen > matchedSubnetLen {
matchedIface = &possibleIface
matchedSubnetLen = subnetLen
}
Log.Debug("Checking iface addr", "iface", possibleIface.Name, "addr", ifaceIP)
}
if matchedIface != nil {
return matchedIface, nil
}
}
```
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: 4454c6432a01bcc930fbf443ffc2f14b39ba6fd8
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with prolink.go lines 168-200 and review the Go range-loop pointer behavior around possibleIface. Determine whether matchedIface can reference the intended interface after the loop, then classify the finding as Bug, Mitigated, or Desirable Behavior using the issue's reaction instructions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100