Browse Source

Fix unreleased cache buffer in QUIC sniffing (#3320)

Vigilans 9 months ago
parent
commit
3d54bec86a
1 changed files with 4 additions and 3 deletions
  1. 4 3
      common/protocol/quic/sniff.go

+ 4 - 3
common/protocol/quic/sniff.go

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