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

minecrafter/go-pe-proxy: packets/raknet/datagram.go; 29 LoC

Open
#16,635 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 [minecrafter/go-pe-proxy](https://www.github.com/minecrafter/go-pe-proxy) at [packets/raknet/datagram.go](https://github.com/minecrafter/go-pe-proxy/blob/f2efa46a56739c8d1e0a24ffbf0ae1e279770ee6/packets/raknet/datagram.go#L43-L71)

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

[Click here to see the code in its original context.](https://github.com/minecrafter/go-pe-proxy/blob/f2efa46a56739c8d1e0a24ffbf0ae1e279770ee6/packets/raknet/datagram.go#L43-L71)

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

```go
for _, p := range *encapsulated {
err = p.Encode(thisPktBuf)
if err != nil {
return nil, err
}

// Reject this datagram if it is obviously too big.
if thisPktBuf.Len() > int(maxDataSize) {
return nil, errors.New("Datagram too big")
}

if curSz+thisPktBuf.Len() > int(maxDataSize) {
// This datagram is full. Create a new one.
currentDatagram.Payload = currentPayload
datagrams = append(datagrams, currentDatagram)
curSz = 0

currentPayload = []*EncapsulatedPacketPart{&p}
currentDatagram = RakNetDatagram{
Type: t,
DatagramSequenceNumber: dsn.IncrementAndGet(),
}
} else {
currentPayload = append(currentPayload, &p)
curSz = curSz + thisPktBuf.Len()
}

thisPktBuf.Reset()
}

```

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

Contributor guide

No contributing guide indexed for this repository

Research direction

Read packets/raknet/datagram.go at lines 43–71 and review the Go range-loop pointer behavior around the references to p. Compare the analyzer finding with how currentPayload and currentDatagram are built, then leave the requested Bug, Mitigated, or Desirable Behavior reaction. Done means the finding has been classified.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.