Skip to content

Commit

Permalink
Correct out of range checking
Browse files Browse the repository at this point in the history
  • Loading branch information
tanghaowillow authored and stv0g committed Aug 9, 2023
1 parent 4160a9f commit 53779ad
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions transport_layer_cc.go
Original file line number Diff line number Diff line change
Expand Up @@ -523,17 +523,20 @@ func (t *TransportLayerCC) Unmarshal(rawPacket []byte) error { //nolint:gocognit

recvDeltasPos := packetStatusPos
for _, delta := range t.RecvDeltas {
if recvDeltasPos >= totalLength {
return errPacketTooShort
}
if delta.Type == TypeTCCPacketReceivedSmallDelta {
if recvDeltasPos+1 > totalLength {
return errPacketTooShort
}
err := delta.Unmarshal(rawPacket[recvDeltasPos : recvDeltasPos+1])
if err != nil {
return err
}
recvDeltasPos++
}
if delta.Type == TypeTCCPacketReceivedLargeDelta {
if recvDeltasPos+2 > totalLength {
return errPacketTooShort
}
err := delta.Unmarshal(rawPacket[recvDeltasPos : recvDeltasPos+2])
if err != nil {
return err
Expand Down

0 comments on commit 53779ad

Please sign in to comment.