github-vet / github-vet/rangeloop-pointer-findings
PaulForgey/dns: service/service.go; 63 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [PaulForgey/dns](https://www.github.com/PaulForgey/dns) at [service/service.go](https://github.com/PaulForgey/dns/blob/ca29f65b367f97956983de7bd9fd849f48df87e2/service/service.go#L197-L259)
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 u used in defer or goroutine at line 249
[Click here to see the code in its original context.](https://github.com/PaulForgey/dns/blob/ca29f65b367f97956983de7bd9fd849f48df87e2/service/service.go#L197-L259)
Click here to show the 63 line(s) of Go which triggered the analyzer.
```go
for _, u := range s.Update {
// create the update record set for this domain
tname, err := dns.NameWithString(fmt.Sprintf("_%s._%s.%v", serviceType, protocol, u))
if err != nil {
return err
}
sname, err := dns.NameWithString(fmt.Sprintf("%s.%v", name, tname))
if err != nil {
return err
}
var textRecords []string
if len(text) == 0 {
textRecords = []string{"\000"}
} else {
for k, v := range text {
textRecords = append(textRecords, k+"="+v)
}
}
var connErr resolver.ConnectionError
for _, service := range s.servicesForDomain(u) {
self, err := service.Self()
if err != nil && !errors.As(err, &connErr) {
return err
}
if len(self) == 0 {
continue
}
// TTLs from RFC-6762
names := make(resolver.OwnerNames)
err = names.Enter(nil, "", []*dns.Record{
&dns.Record{
H: dns.NewMDNSHeader(sname, dns.SRVType, rrclass, 75*time.Minute, true),
D: &dns.SRVRecord{Priority: priority, Weight: weight, Port: port, Name: self},
},
&dns.Record{
H: dns.NewMDNSHeader(sname, dns.TXTType, rrclass, 75*time.Minute, true),
D: &dns.TXTRecord{Text: textRecords},
},
&dns.Record{
H: dns.NewMDNSHeader(tname, dns.PTRType, rrclass, 75*time.Minute, false),
D: &dns.PTRRecord{Name: sname},
},
})
if err != nil {
return err
}
wg.Add(1)
go func(service Service) {
err := service.Announce(actx, u, names)
if err != nil && !errors.As(err, &connErr) {
select {
case errch <- err:
default: // do not block. We will wake up on and use one arbitrarily
}
}
wg.Done()
}(service)
}
}
```
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: ca29f65b367f97956983de7bd9fd849f48df87e2
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.