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

ypapax/kpi_dashboard: util.go; 25 LoC

Open
#15,335 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 [ypapax/kpi_dashboard](https://www.github.com/ypapax/kpi_dashboard) at [util.go](https://github.com/ypapax/kpi_dashboard/blob/cb26be148b03e99920a30b3a49068730761140ca/util.go#L51-L75)

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 intf is reassigned at line 64

[Click here to see the code in its original context.](https://github.com/ypapax/kpi_dashboard/blob/cb26be148b03e99920a30b3a49068730761140ca/util.go#L51-L75)

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

```go
for _, intf := range intfs {
cidrs, err := GetIPAddrs(intf.Name)
if err != nil {
return "", "", UNDEFINED, nil, fmt.Errorf("error looking interface - %v", err)
}

for _, cidr := range cidrs {
ip, _, err := net.ParseCIDR(cidr.String())
if err != nil {
continue
}
if ip.String() == h {
localAddr = h
localIntf = &intf
break OuterLoop
}
// Use 1st interface for bind = 0.0.0.0
// XXX Bad idea
if h == "0.0.0.0" {
localAddr = ip.String()
localIntf = &intf
break OuterLoop
}
}
}

```

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: cb26be148b03e99920a30b3a49068730761140ca

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with util.go at lines 51-75 in commit cb26be148b03e99920a30b3a49068730761140ca. Review how the range variable intf is referenced after taking its address and decide whether that creates incorrect behavior. Done means adding the appropriate Bug, Mitigated, or Desirable Behavior reaction.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.