github-vet / github-vet/rangeloop-pointer-findings
networkservicemesh/networkservicemesh: forwarder/pkg/common/egress_interface.go; 52 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [networkservicemesh/networkservicemesh](https://www.github.com/networkservicemesh/networkservicemesh) at [forwarder/pkg/common/egress_interface.go](https://github.com/networkservicemesh/networkservicemesh/blob/cb2e62e24eb38c3ff7faa62f8e78ff8af197f675/forwarder/pkg/common/egress_interface.go#L171-L222)
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 iface was used in a composite literal at line 212
[Click here to see the code in its original context.](https://github.com/networkservicemesh/networkservicemesh/blob/cb2e62e24eb38c3ff7faa62f8e78ff8af197f675/forwarder/pkg/common/egress_interface.go#L171-L222)
Click here to show the 52 line(s) of Go which triggered the analyzer.
```go
for _, iface := range ifaces {
addrs, err := iface.Addrs()
logrus.Infof("INTERFACE: %v : %v", iface.Name, addrs)
if err != nil {
return nil, err
}
var v6 *net.IPNet
// Some clouds require localSID to be equal local ipv6 address, or gateway will deny packets
var localSID net.IP
for _, addr := range addrs {
switch v := addr.(type) {
case *net.IPNet:
if strings.Contains(v.String(), ":") {
if !(v.IP[0] == 0xfe && v.IP[1] == 0x80) {
if v6 == nil {
v6 = v
} else {
localSID = v.IP
}
}
}
}
}
for _, addr := range addrs {
switch v := addr.(type) {
case *net.IPNet:
if v.IP.Equal(srcIP) {
if v6 != nil && localSID == nil {
localSID = v6.IP
v6.IP = make(net.IP, len(v6.IP))
copy(v6.IP, localSID)
v6.IP[0] = 0xfd
v6.IP[1] = 0x24
}
return &egressInterface{
srcNet: v,
srcV6Net: v6,
localSID: localSID,
iface: &iface,
defaultGateway: gw,
outgoingInterface: outgoingInterface,
arpEntries: arpEntries,
}, nil
}
default:
return nil, errors.New("type of addr not net.IPNET")
}
}
}
```
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: cb2e62e24eb38c3ff7faa62f8e78ff8af197f675
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.