github-vet / github-vet/rangeloop-pointer-findings
keybase/client: go/teams/audit.go; 34 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [keybase/client](https://www.github.com/keybase/client) at [go/teams/audit.go](https://github.com/keybase/client/blob/a144e0ce38ee9e495cc5acbcd4ef859f5534d820/go/teams/audit.go#L343-L376)
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 375
[Click here to see the code in its original context.](https://github.com/keybase/client/blob/a144e0ce38ee9e495cc5acbcd4ef859f5534d820/go/teams/audit.go#L343-L376)
Click here to show the 34 line(s) of Go which triggered the analyzer.
```go
for _, tuple := range probeTuples {
m.Debug("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]
if !ok {
return 0, keybase1.Seqno(0), probeTuples, NewAuditError("team chain rollback: merkle seqno %v referred to team chain seqno %v which is not part of our chain (which at merkle seqno %v ends at %v)", tuple.merkle, tuple.team, latestMerkleSeqno, maxChainSeqno)
}
if !expectedLinkID.Eq(tuple.linkID) {
return 0, keybase1.Seqno(0), probeTuples, NewAuditError("team chain linkID mismatch at %d: wanted %s but got %s via merkle seqno %d", tuple.team, expectedLinkID, tuple.linkID, tuple.merkle)
}
}
if err = checkProbeHidden(m, firstRootWithHidden, hiddenChain, &tuple, prev, latestMerkleSeqno, maxHiddenSeqno, auditMode); err != nil {
return 0, keybase1.Seqno(0), probeTuples, err
}
ret++
// 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), probeTuples, 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: a144e0ce38ee9e495cc5acbcd4ef859f5534d820
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.