From b45f43da38b46f0e3dd104c59deb09594d77c6de Mon Sep 17 00:00:00 2001 From: Salomakhin Timur Date: Sat, 20 Dec 2025 22:55:13 +0100 Subject: [PATCH] conn: fix IPv6 address corruption in StdNetBind.Send() Ensure the IP slice is properly sized before copying address bytes when reusing objects from the udpAddrPool. Previously, copying before resizing could truncate IPv6 addresses and leave leftover bytes from previous uses, causing datagrams to be sent to incorrect addresses. Signed-off-by: Salomakhin Timur --- conn/bind_std.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conn/bind_std.go b/conn/bind_std.go index f5c88160e..cd9b2c125 100644 --- a/conn/bind_std.go +++ b/conn/bind_std.go @@ -367,12 +367,12 @@ func (s *StdNetBind) Send(bufs [][]byte, endpoint Endpoint) error { defer s.udpAddrPool.Put(ua) if is6 { as16 := endpoint.DstIP().As16() - copy(ua.IP, as16[:]) ua.IP = ua.IP[:16] + copy(ua.IP, as16[:]) } else { as4 := endpoint.DstIP().As4() - copy(ua.IP, as4[:]) ua.IP = ua.IP[:4] + copy(ua.IP, as4[:]) } ua.Port = int(endpoint.(*StdNetEndpoint).Port()) var (