From 4223bde4acf110bd534da3b322cecf824a388fad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Sun, 12 May 2024 16:14:28 +0800 Subject: [PATCH] hysteria2: Fix missing message limit --- hysteria2/internal/protocol/proxy.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hysteria2/internal/protocol/proxy.go b/hysteria2/internal/protocol/proxy.go index 795b3cb..08e2361 100644 --- a/hysteria2/internal/protocol/proxy.go +++ b/hysteria2/internal/protocol/proxy.go @@ -119,6 +119,9 @@ func ReadTCPResponse(r io.Reader) (bool, string, error) { } func WriteTCPResponse(ok bool, msg string, payload []byte) *buf.Buffer { + if len(msg) > MaxMessageLength { + msg = msg[:MaxMessageLength] + } padding := tcpResponsePadding.String() paddingLen := len(padding) msgLen := len(msg) @@ -198,7 +201,7 @@ func ParseUDPMessage(msg []byte) (*UDPMessage, error) { if err != nil { return nil, err } - if lAddr == 0 || lAddr > MaxMessageLength { + if lAddr == 0 || lAddr > MaxAddressLength { return nil, E.New("invalid address length") } bs := buf.Bytes()