From 7b54255cc1b3ce4c275b713e6289d0cd45ec50ea Mon Sep 17 00:00:00 2001 From: yuhan6665 <1588741+yuhan6665@users.noreply.github.com> Date: Wed, 1 Mar 2023 08:43:00 -0500 Subject: [PATCH] Fix padding extends out of bound --- proxy/vless/encoding/encoding.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/proxy/vless/encoding/encoding.go b/proxy/vless/encoding/encoding.go index 7a218aef..d42a1568 100644 --- a/proxy/vless/encoding/encoding.go +++ b/proxy/vless/encoding/encoding.go @@ -556,6 +556,9 @@ func XtlsPadding(b *buf.Buffer, command byte, userUUID *[]byte, longPadding bool b.Release() b = nil } + if paddingLen > buf.Size - newbuffer.Len() { + paddingLen = buf.Size - newbuffer.Len() + } newbuffer.Extend(paddingLen) newError("XtlsPadding ", contantLen, " ", paddingLen, " ", command).WriteToLog(session.ExportIDToError(ctx)) return newbuffer