github-vet / github-vet/rangeloop-pointer-findings
Factom-Asset-Tokens/fatd: cli/transact.go; 22 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [Factom-Asset-Tokens/fatd](https://www.github.com/Factom-Asset-Tokens/fatd) at [cli/transact.go](https://github.com/Factom-Asset-Tokens/fatd/blob/f8331d1d63aad652e6ae481475458bb57a037f5b/cli/transact.go#L269-L290)
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 adr is reassigned at line 271
[Click here to see the code in its original context.](https://github.com/Factom-Asset-Tokens/fatd/blob/f8331d1d63aad652e6ae481475458bb57a037f5b/cli/transact.go#L269-L290)
Click here to show the 22 line(s) of Go which triggered the analyzer.
```go
for _, adr := range inputAdrs {
vrbLog.Println("Checking FAT Token balance...", adr)
paramsGetBalance.Address = &adr
var balance uint64
if err := FATClient.Request(context.Background(),
"get-balance",
paramsGetBalance, &balance); err != nil {
errLog.Fatal(err)
}
var inputAmount uint64
switch cmdType {
case fat0.Type:
inputAmount = fat0Tx.Inputs[adr]
case fat1.Type:
inputAmount = uint64(len(fat1Tx.Inputs[adr]))
}
if inputAmount > balance {
errLog.Fatalf(
"--input %v:%v has insufficient balance (%v)",
adr, addressValueStrMap[adr], balance)
}
}
```
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: f8331d1d63aad652e6ae481475458bb57a037f5b
Contributor guide
No contributing guide indexed for this repository
Research direction
Read cli/transact.go around lines 269-290 at commit f8331d1d63aad652e6ae481475458bb57a037f5b, then inspect how the address pointer is used by the balance request and how the loop values are consumed. Compare the analyzer finding with Go range-loop behavior and the surrounding transaction logic. Finish by reacting to the issue as Bug, Mitigated, or Desirable Behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100