Skip to content

Commit

Permalink
restrict ping sequence number to 16bit
Browse files Browse the repository at this point in the history
cherry-picking #120

```improvement operator
Fix ping failure due to 16bit overflow in sequence number check.
```
  • Loading branch information
MartinWeindel committed Dec 9, 2024
1 parent 0fdf64d commit 5ed13de
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cmd/vpn_client/app/pathcontroller/ping.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ func (p *icmpPinger) ping(client net.IP) error {
return fmt.Errorf("error setting deadline: %w", err)
}

seq := p.lastSeq.Add(1)
seq := p.lastSeq.Add(1) & 0xffff // is marshalled as uint16 so we need to mask it
msg := icmp.Message{
Type: ipv6.ICMPTypeEchoRequest,
Code: 0,
Body: &icmp.Echo{
ID: os.Getpid() & 0xffff,
ID: os.Getpid() & 0xffff, // is marshalled as uint16 so we need to mask it
Seq: int(seq),
Data: []byte(echoPayload),
},
Expand Down

0 comments on commit 5ed13de

Please sign in to comment.