From 195290884c1ba696486d6dedfb04ca5d9f3f9373 Mon Sep 17 00:00:00 2001 From: xjasonlyu Date: Thu, 30 Mar 2023 14:11:43 +0800 Subject: [PATCH] Fix: potential crash by bad UDP address (#238) --- proxy/socks5.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/proxy/socks5.go b/proxy/socks5.go index d169994..5d7b5c8 100644 --- a/proxy/socks5.go +++ b/proxy/socks5.go @@ -121,6 +121,10 @@ func (ss *Socks5) DialUDP(*M.Metadata) (_ net.PacketConn, err error) { }() bindAddr := addr.UDPAddr() + if bindAddr == nil { + return nil, fmt.Errorf("invalid UDP binding address: %#v", addr) + } + if bindAddr.IP.IsUnspecified() { /* e.g. "0.0.0.0" or "::" */ udpAddr, err := net.ResolveUDPAddr("udp", ss.Addr()) if err != nil {