From e2d71abecd40dfff82460742efb74fb94b377c9f Mon Sep 17 00:00:00 2001 From: Kaming Chan Date: Mon, 25 Jul 2022 12:44:00 +0800 Subject: [PATCH] Fix: handle parse socks5 udp address properly (#2220) (cherry picked from commit bec4df7b122e6a4db0f831ed6176732b2a09fb63) --- transport/snell/snell.go | 3 +++ transport/trojan/trojan.go | 3 +++ 2 files changed, 6 insertions(+) diff --git a/transport/snell/snell.go b/transport/snell/snell.go index c6b7a569..e2bd2820 100644 --- a/transport/snell/snell.go +++ b/transport/snell/snell.go @@ -241,6 +241,9 @@ func ReadPacket(r io.Reader, payload []byte) (net.Addr, int, error) { return nil, 0, errors.New("remote address invalid") } uAddr := addr.UDPAddr() + if uAddr == nil { + return nil, 0, errors.New("parse addr error") + } length := len(payload) if n-headLen < length { diff --git a/transport/trojan/trojan.go b/transport/trojan/trojan.go index 4ebb431b..937b5f91 100644 --- a/transport/trojan/trojan.go +++ b/transport/trojan/trojan.go @@ -250,6 +250,9 @@ func ReadPacket(r io.Reader, payload []byte) (net.Addr, int, int, error) { return nil, 0, 0, errors.New("read addr error") } uAddr := addr.UDPAddr() + if uAddr == nil { + return nil, 0, 0, errors.New("parse addr error") + } if _, err = io.ReadFull(r, payload[:2]); err != nil { return nil, 0, 0, errors.New("read length error")