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

arbitraryrw/MobProtID: internal/pkg/r2handler/r2handler.go; 61 LoC

Open
#14,825 0 comments 0 reactions 0 assignees View on GitHub
fresh medium
Dominant language
No language data
Stars
0
Forks
0
PR merge metrics
PR metrics pending

Description

Found a possible issue in [arbitraryrw/MobProtID](https://www.github.com/arbitraryrw/MobProtID) at [internal/pkg/r2handler/r2handler.go](https://github.com/arbitraryrw/MobProtID/blob/8c5d24910eae4dc9864a658b59d24a9dfd345b5b/internal/pkg/r2handler/r2handler.go#L38-L98)

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.

> range-loop variable path used in defer or goroutine at line 51

[Click here to see the code in its original context.](https://github.com/arbitraryrw/MobProtID/blob/8c5d24910eae4dc9864a658b59d24a9dfd345b5b/internal/pkg/r2handler/r2handler.go#L38-L98)

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

```go
for index, path := range binaryPath {
fmt.Println("\tanalysing file ->", index, path)

strings := make(chan []map[string]string)
binaryInfo := make(chan map[string]map[string]string)
symbols := make(chan []map[string]string)
syscalls := make(chan []map[string]string)
binClassMethFields := make(chan []map[string][]map[string]string)
functions := make(chan []map[string]string)

// fmt.Println(index, path)

go func(p string) {
r2Session := openR2Pipe(path)
binaryInfo <- getBinaryInfo(r2Session)
r2Session.Close()
}(path)

go func(p string) {
r2Session := openR2Pipe(path)
strings <- getStringEntireBinary(r2Session)
r2Session.Close()
}(path)

go func(p string) {
r2Session := openR2Pipe(path)
symbols <- getSymbols(r2Session)
r2Session.Close()
}(path)

go func(p string) {
r2sessionMap := openR2Pipe(path)
syscalls <- getSysCalls(r2sessionMap)
r2sessionMap.Close()
}(path)

go func(p string) {
r2Session := openR2Pipe(path)
binClassMethFields <- getClassMethFields(r2Session)
r2Session.Close()
}(path)

go func(p string) {
r2Session := openR2Pipe(path)
functions <- getFunctions(r2Session)
r2Session.Close()
}(path)

allStringsInBinary[path] = <-strings
allSymbolsInBinary[path] = <-symbols
allSyscall[path] = <-syscalls
allbinaryInfo[path] = <-binaryInfo
allBinClassMethFields[path] = <-binClassMethFields
allBinFunctions[path] = <-functions

close(strings)
close(symbols)
close(syscalls)
close(binaryInfo)
close(binClassMethFields)
}

```

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: 8c5d24910eae4dc9864a658b59d24a9dfd345b5b

Contributor guide

No contributing guide indexed for this repository

Research direction

Read internal/pkg/r2handler/r2handler.go lines 38-98 and verify whether the goroutines use the range-loop variable path rather than their p parameter. Compare the analyzer finding with the referenced commit, then leave the requested reaction classification once you determine whether it is a bug, mitigated, or desirable behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
reverse-engineering
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.