Reject out-of-range UDP port before narrowing to uint16 in fakeAddress

This commit is contained in:
Viktor Liu
2026-05-04 13:40:00 +02:00
parent 14ef880fc1
commit 2394972131

View File

@@ -203,6 +203,9 @@ func fakeAddress(peerAddress *net.UDPAddr) (*netip.AddrPort, error) {
if peerAddress == nil {
return nil, fmt.Errorf("nil peer address")
}
if peerAddress.Port < 0 || peerAddress.Port > 65535 {
return nil, fmt.Errorf("invalid UDP port: %d", peerAddress.Port)
}
addr, ok := netip.AddrFromSlice(peerAddress.IP)
if !ok {