From b16a5f03fe1a42c5c35bdf04732cd5671e765adf Mon Sep 17 00:00:00 2001 From: vemneyy Date: Thu, 20 Nov 2025 15:21:22 +0300 Subject: [PATCH] Socks: Fix buffer full panic when encoding large UDP packets (#5252) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 风扇滑翔翼 --- proxy/socks/protocol.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/proxy/socks/protocol.go b/proxy/socks/protocol.go index 9bccf607..76ceb47c 100644 --- a/proxy/socks/protocol.go +++ b/proxy/socks/protocol.go @@ -353,6 +353,11 @@ func EncodeUDPPacket(request *protocol.RequestHeader, data []byte) (*buf.Buffer, b.Release() return nil, err } + // if data is too large, return an empty buffer (drop too big data) + if b.Available() < int32(len(data)) { + b.Clear() + return b, nil + } common.Must2(b.Write(data)) return b, nil }