github-vet / github-vet/rangeloop-pointer-findings
projectcalico/calico-bgp-daemon: main.go; 55 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [projectcalico/calico-bgp-daemon](https://www.github.com/projectcalico/calico-bgp-daemon) at [main.go](https://github.com/projectcalico/calico-bgp-daemon/blob/8ea1e249425f1e4326b7d61a1d8ac3af19328e3f/main.go#L314-L368)
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.
>
[Click here to see the code in its original context.](https://github.com/projectcalico/calico-bgp-daemon/blob/8ea1e249425f1e4326b7d61a1d8ac3af19328e3f/main.go#L314-L368)
Click here to show the 55 line(s) of Go which triggered the analyzer.
```go
for _, route := range list {
if route.Dst == nil {
continue
}
prefix := route.Dst.String()
if pool.contain(prefix) {
ipip := pool.IPIP != ""
if pool.Mode == "cross-subnet" && !isCrossSubnet(route.Gw, node.Spec.BGP.IPv4Address.Network().IPNet) {
ipip = false
}
if ipip {
i, err := net.InterfaceByName(pool.IPIP)
if err != nil {
return err
}
route.LinkIndex = i.Index
route.SetFlag(netlink.FLAG_ONLINK)
} else {
tbl, err := s.bgpServer.GetRib("", bgp.RF_IPv4_UC, []*bgptable.LookupPrefix{
&bgptable.LookupPrefix{
Prefix: prefix,
},
})
if err != nil {
return err
}
bests := tbl.Bests("")
if len(bests) == 0 {
log.Printf("no best for %s", prefix)
continue
}
best := bests[0]
if best.IsLocal() {
log.Printf("%s's best is local path", prefix)
continue
}
gw, err := recursiveNexthopLookup(best.GetNexthop())
if err != nil {
return err
}
route.Gw = gw
route.Flags = 0
rs, err := netlink.RouteGet(gw)
if err != nil {
return err
}
if len(rs) == 0 {
return fmt.Errorf("no route for path: %s", gw)
}
r := rs[0]
route.LinkIndex = r.LinkIndex
}
return netlink.RouteReplace(&route)
}
}
```
Click here to show extra information the analyzer produced.
```
No path was found through the callgraph that could lead to a function which writes a pointer argument.
No path was found through the callgraph that could lead to a function which passes a pointer to third-party code.
root signature {RouteReplace 1} was not found in the callgraph; reference was passed directly to third-party code
```
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: 8ea1e249425f1e4326b7d61a1d8ac3af19328e3f
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.