Fix unreleased cache buffer in QUIC sniffing (#3320)

This commit is contained in:
Vigilans 2025-02-21 04:57:11 +08:00 committed by GitHub
parent 14bc04a889
commit 3d54bec86a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -54,6 +54,9 @@ func SniffQUIC(b []byte) (*SniffHeader, error) {
cryptoData := bytespool.Alloc(int32(len(b))) cryptoData := bytespool.Alloc(int32(len(b)))
defer bytespool.Free(cryptoData) defer bytespool.Free(cryptoData)
cache := buf.New()
defer cache.Release()
// Parse QUIC packets // Parse QUIC packets
for len(b) > 0 { for len(b) > 0 {
buffer := buf.FromBytes(b) buffer := buf.FromBytes(b)
@ -139,9 +142,7 @@ func SniffQUIC(b []byte) (*SniffHeader, error) {
return nil, err return nil, err
} }
cache := buf.New() cache.Clear()
defer cache.Release()
mask := cache.Extend(int32(block.BlockSize())) mask := cache.Extend(int32(block.BlockSize()))
block.Encrypt(mask, b[hdrLen+4:hdrLen+4+16]) block.Encrypt(mask, b[hdrLen+4:hdrLen+4+16])
b[0] ^= mask[0] & 0xf b[0] ^= mask[0] & 0xf