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

edwindvinas/ttn: core/components/broker/broker.go; 42 LoC

Open
#16,425 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 [edwindvinas/ttn](https://www.github.com/edwindvinas/ttn) at [core/components/broker/broker.go](https://github.com/edwindvinas/ttn/blob/7fce6394aa86cbe6f0efea016b4df8d67fe65697/core/components/broker/broker.go#L251-L292)

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 entry is reassigned at line 283

[Click here to see the code in its original context.](https://github.com/edwindvinas/ttn/blob/7fce6394aa86cbe6f0efea016b4df8d67fe65697/core/components/broker/broker.go#L251-L292)

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

```go
for _, entry := range entries {
fcntReset = false
// retrieve the network session key
key := lorawan.AES128Key(entry.NwkSKey)

// Check frame counter is in valid range
fcnt32, err := b.NetworkController.wholeCounter(fcnt16, entry.FCntUp)
if err != nil {
// invalid, is device in developer mode
if (entry.Flags & core.RelaxFcntCheck) != 0 {
fcnt32 = fcnt16
fcntReset = true
} else {
continue
}
}

// Check with 16-bits counters
fhdr.FCnt = fcnt16
ok, err := uplinkPayload.ValidateMIC(key)
if err != nil {
continue
}
fhdr.FCnt = fcnt32
if !ok { // Check with 32-bits counter
ok, err = uplinkPayload.ValidateMIC(key)
if err != nil {
continue
}
}

if ok {
mEntry = &entry
stats.MarkMeter("broker.uplink.handler_lookup.mic_match")
ctx = ctx.WithFields(log.Fields{
"DevEUI": mEntry.DevEUI,
"Handler": string(entry.Dialer.MarshalSafely()),
})
ctx.Debug("MIC check succeeded")
break // We stop at the first valid check ...
}
}

```

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

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.