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

bcgshyam/dsfs: plugin/rootfs/usr/local/go/src/net/dnsclient_unix.go; 39 LoC

Open
#13,003 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 [bcgshyam/dsfs](https://www.github.com/bcgshyam/dsfs) at [plugin/rootfs/usr/local/go/src/net/dnsclient_unix.go](https://github.com/bcgshyam/dsfs/blob/6da0724bcc89413ab79da284b4215651d5ec16a0/plugin/rootfs/usr/local/go/src/net/dnsclient_unix.go#L480-L518)

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.

> range-loop variable fqdn used in defer or goroutine at line 485

[Click here to see the code in its original context.](https://github.com/bcgshyam/dsfs/blob/6da0724bcc89413ab79da284b4215651d5ec16a0/plugin/rootfs/usr/local/go/src/net/dnsclient_unix.go#L480-L518)

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

```go
for _, fqdn := range conf.nameList(name) {
for _, qtype := range qtypes {
dnsWaitGroup.Add(1)
go func(qtype uint16) {
defer dnsWaitGroup.Done()
cname, rrs, err := r.tryOneName(ctx, conf, fqdn, qtype)
lane <- racer{cname, rrs, err}
}(qtype)
}
hitStrictError := false
for range qtypes {
racer := <-lane
if racer.error != nil {
if nerr, ok := racer.error.(Error); ok && nerr.Temporary() && r.StrictErrors {
// This error will abort the nameList loop.
hitStrictError = true
lastErr = racer.error
} else if lastErr == nil || fqdn == name+"." {
// Prefer error for original name.
lastErr = racer.error
}
continue
}
addrs = append(addrs, addrRecordList(racer.rrs)...)
if cname == "" {
cname = racer.cname
}
}
if hitStrictError {
// If either family hit an error with StrictErrors enabled,
// discard all addresses. This ensures that network flakiness
// cannot turn a dualstack hostname IPv4/IPv6-only.
addrs = nil
break
}
if len(addrs) > 0 {
break
}
}

```

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: 6da0724bcc89413ab79da284b4215651d5ec16a0

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.