github-vet / github-vet/rangeloop-pointer-findings
fiersk17/F9_PubKey-v8.13: go/teams/audit.go; 38 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [fiersk17/F9_PubKey-v8.13](https://www.github.com/fiersk17/F9_PubKey-v8.13) at [go/teams/audit.go](https://github.com/fiersk17/F9_PubKey-v8.13/blob/1dbfb49d0f660861b632e60857d0cfba0f0a357e/go/teams/audit.go#L263-L300)
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 tuple is reassigned at line 299
[Click here to see the code in its original context.](https://github.com/fiersk17/F9_PubKey-v8.13/blob/1dbfb49d0f660861b632e60857d0cfba0f0a357e/go/teams/audit.go#L263-L300)
Click here to show the 38 line(s) of Go which triggered the analyzer.
```go
for _, tuple := range probeTuples {
m.CDebugf("postProbe: checking probe at %+v", tuple)
// Note that we might see tuple.team == 0 in a legit case. There is a race here. If seqno=1
// of team foo was made when the last merkle seqno was 2000, let's say, then for merkle seqnos
// 2000-2001, the team foo might not be in the tree. So we'd expect the tuple.team to be 0
// in that (unlikely) case. So we don't check the validity of the linkID in that case
// (since it doesn't exist). However, we still do check that tuple.team's are non-decreasing,
// so this 0 value is checked below (see comment).
if tuple.team > keybase1.Seqno(0) {
expectedLinkID, ok := chain[tuple.team]
// It could be that our view of the chain is stale, and that the merkle tree is advertising
// chain links that we've never fetched. That's OK, we don't need to error out of the
// auditor. But if we're missing links before maxChainSeqno, then we have big problems.
if !ok {
if tuple.team < maxChainSeqno {
return 0, keybase1.Seqno(0), NewAuditError("team chain didn't contain seqno=%d even though we expected links through %d", tuple.team, maxChainSeqno)
}
continue
}
if !expectedLinkID.Eq(tuple.linkID) {
return 0, keybase1.Seqno(0), NewAuditError("team chain linkID mismatch at %d: wanted %s but got %s via merkle seqno %d", tuple.team, expectedLinkID, tuple.linkID, tuple.merkle)
}
}
ret++
history.PostProbes[tuple.merkle] = keybase1.Probe{Index: probeID, TeamSeqno: tuple.team}
// This condition is the key ordering condition. It is still checked in the case of the race
// condition at tuple.team==0 mentioned just above.
if prev != nil && prev.team > tuple.team {
return 0, keybase1.Seqno(0), NewAuditError("team chain unexpected jump: %d > %d via merkle seqno %d", prev.team, tuple.team, tuple.merkle)
}
if tuple.merkle > maxMerkleProbe {
maxMerkleProbe = tuple.merkle
}
prev = &tuple
}
```
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: 1dbfb49d0f660861b632e60857d0cfba0f0a357e
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.