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

algorand/go-algorand: cmd/goal/clerk.go; 29 LoC

Open
#12,576 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 [algorand/go-algorand](https://www.github.com/algorand/go-algorand) at [cmd/goal/clerk.go](https://github.com/algorand/go-algorand/blob/c17ef9bc5dab5b98a9eb863b5c316aa06df69c27/cmd/goal/clerk.go#L1024-L1052)

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 txn was used in a composite literal at line 1028

[Click here to see the code in its original context.](https://github.com/algorand/go-algorand/blob/c17ef9bc5dab5b98a9eb863b5c316aa06df69c27/cmd/goal/clerk.go#L1024-L1052)

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

```go
for i, txn := range txgroup {
if txn.Lsig.Blank() {
continue
}
ep := logic.EvalParams{Txn: &txn, Proto: ¶ms}
cost, err := logic.Check(txn.Lsig.Logic, ep)
if err != nil {
reportErrorf("program failed Check: %s", err)
}
sb := strings.Builder{}
ep = logic.EvalParams{
Txn: &txn,
GroupIndex: i,
Proto: ¶ms,
Trace: &sb,
TxnGroup: txgroup,
}
pass, err := logic.Eval(txn.Lsig.Logic, ep)
// TODO: optionally include `inspect` output here?
fmt.Fprintf(os.Stdout, "tx[%d] cost=%d trace:\n%s\n", i, cost, sb.String())
if pass {
fmt.Fprintf(os.Stdout, " - pass -\n")
} else {
fmt.Fprintf(os.Stdout, "REJECT\n")
}
if err != nil {
fmt.Fprintf(os.Stdout, "ERROR: %s\n", err.Error())
}
}

```

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

Contributor guide

No contributing guide indexed for this repository

Research direction

Inspect cmd/goal/clerk.go around lines 1024-1052, starting with the range loop and the EvalParams composite literals that reference txn. Determine whether the analyzer finding represents a bug, mitigated behavior, or desirable behavior, then leave the corresponding reaction on this issue; completion is the requested classification.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.