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

cynt4k/wygops: internal/services/wireguard/wireguard_impl.go; 5 LoC

Open
#17,288 0 comments 0 reactions 0 assignees View on GitHub
fresh tiny
Dominant language
No language data
Stars
0
Forks
0
PR merge metrics
PR metrics pending

Description

Found a possible issue in [cynt4k/wygops](https://www.github.com/cynt4k/wygops) at [internal/services/wireguard/wireguard_impl.go](https://github.com/cynt4k/wygops/blob/74788a28dd8d45cb6291cc58fc921f2406eaacc8/internal/services/wireguard/wireguard_impl.go#L135-L139)

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 peer is reassigned at line 137

[Click here to see the code in its original context.](https://github.com/cynt4k/wygops/blob/74788a28dd8d45cb6291cc58fc921f2406eaacc8/internal/services/wireguard/wireguard_impl.go#L135-L139)

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

```go
for _, peer := range w.server.Peers {
if peer.PublicKey.String() == device.PublicKey.String() {
selectedPeer = &peer
}
}

```

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: 74788a28dd8d45cb6291cc58fc921f2406eaacc8

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in internal/services/wireguard/wireguard_impl.go around lines 135-139 and inspect the surrounding peer-selection logic. Confirm whether selectedPeer remains valid after the range loop and check the repository's Go tests if available. Done means resolving or validating the reported range-variable reference without changing intended peer selection behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
networking
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.