wgengine/magicsock: fix looksLikeInitiationMsg endianness (#16771)

WireGuard message type is little-endian encoded.

Updates tailscale/corp#30903

Signed-off-by: Jordan Whited <jordan@tailscale.com>
This commit is contained in:
Jordan Whited
2025-08-04 14:21:32 -07:00
committed by GitHub
parent 834630fedf
commit b0018f1e7d
2 changed files with 14 additions and 9 deletions

View File

@@ -1765,11 +1765,8 @@ func (c *Conn) mkReceiveFunc(ruc *RebindingUDPConn, healthItem *health.ReceiveFu
// looksLikeInitiationMsg returns true if b looks like a WireGuard initiation
// message, otherwise it returns false.
func looksLikeInitiationMsg(b []byte) bool {
if len(b) == device.MessageInitiationSize &&
binary.BigEndian.Uint32(b) == device.MessageInitiationType {
return true
}
return false
return len(b) == device.MessageInitiationSize &&
binary.LittleEndian.Uint32(b) == device.MessageInitiationType
}
// receiveIP is the shared bits of ReceiveIPv4 and ReceiveIPv6.