From c5444a03acc80e1261aaada0b178140bea8adea4 Mon Sep 17 00:00:00 2001 From: H1JK Date: Fri, 24 Feb 2023 21:19:57 +0800 Subject: [PATCH] Fix short buffer --- transport/vless/conn.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/transport/vless/conn.go b/transport/vless/conn.go index 7a01d71a..fd683dda 100644 --- a/transport/vless/conn.go +++ b/transport/vless/conn.go @@ -104,7 +104,12 @@ func (vc *Conn) ReadBuffer(buffer *buf.Buffer) error { if vc.readFilterUUID { headerUUIDLen = uuid.Size } - header := buffer.FreeBytes()[:paddingHeaderLen+headerUUIDLen] + var header []byte + if need := headerUUIDLen + paddingHeaderLen; buffer.FreeLen() < need { + header = make([]byte, need) + } else { + header = buffer.FreeBytes()[:need] + } _, err := io.ReadFull(vc.ExtendedReader, header) if err != nil { return err