Skip to content

Commit 4223bde

Browse files
committed
hysteria2: Fix missing message limit
1 parent a7af781 commit 4223bde

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

hysteria2/internal/protocol/proxy.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ func ReadTCPResponse(r io.Reader) (bool, string, error) {
119119
}
120120

121121
func WriteTCPResponse(ok bool, msg string, payload []byte) *buf.Buffer {
122+
if len(msg) > MaxMessageLength {
123+
msg = msg[:MaxMessageLength]
124+
}
122125
padding := tcpResponsePadding.String()
123126
paddingLen := len(padding)
124127
msgLen := len(msg)
@@ -198,7 +201,7 @@ func ParseUDPMessage(msg []byte) (*UDPMessage, error) {
198201
if err != nil {
199202
return nil, err
200203
}
201-
if lAddr == 0 || lAddr > MaxMessageLength {
204+
if lAddr == 0 || lAddr > MaxAddressLength {
202205
return nil, E.New("invalid address length")
203206
}
204207
bs := buf.Bytes()

0 commit comments

Comments
 (0)