From e555fd65ecb8450eb583a287dd16d008e4a975d1 Mon Sep 17 00:00:00 2001 From: gVisor bot Date: Fri, 20 Jan 2023 17:35:49 +0800 Subject: [PATCH] fix: ShadowTLS header use array instead --- transport/shadowtls/shadowtls.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/transport/shadowtls/shadowtls.go b/transport/shadowtls/shadowtls.go index 86a23779..2c0c5946 100644 --- a/transport/shadowtls/shadowtls.go +++ b/transport/shadowtls/shadowtls.go @@ -54,8 +54,8 @@ func (h HashedConn) Read(b []byte) (n int, err error) { } func (s *ShadowTLS) read(b []byte) (int, error) { - buf := pool.Get(tlsHeaderLen) - _, err := io.ReadFull(s.Conn, buf) + var buf [tlsHeaderLen]byte + _, err := io.ReadFull(s.Conn, buf[:]) if err != nil { return 0, fmt.Errorf("shadowtls read failed %w", err) } @@ -63,7 +63,6 @@ func (s *ShadowTLS) read(b []byte) (int, error) { return 0, fmt.Errorf("invalid shadowtls header %v", buf) } length := int(binary.BigEndian.Uint16(buf[3:])) - pool.Put(buf) if length > len(b) { n, err := s.Conn.Read(b)