Skip to content

Commit fe01033

Browse files
committed
chore: quic sniffer should use the exact length of crypto stream when assembling
1 parent 84cd0ef commit fe01033

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

component/sniffer/quic_sniffer.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -399,9 +399,7 @@ func (q *quicPacketSender) readQuicData(b []byte) error {
399399
}
400400
}
401401

402-
_ = q.tryAssemble()
403-
404-
return nil
402+
return q.tryAssemble()
405403
}
406404

407405
func (q *quicPacketSender) tryAssemble() error {
@@ -415,7 +413,17 @@ func (q *quicPacketSender) tryAssemble() error {
415413

416414
if len(q.ranges) != 1 || q.ranges[0].Start() != 0 || q.ranges[0].End() != uint64(len(q.buffer)) {
417415
q.lock.RUnlock()
418-
return ErrNoClue
416+
// incomplete fragment, just return
417+
return nil
418+
}
419+
420+
if len(q.buffer) <= 4 ||
421+
// Handshake Type (1) + uint24 Length (3) + ClientHello body
422+
// maxCryptoStreamOffset is in the valid range of uint16 so just ignore the q.buffer[1]
423+
int(binary.BigEndian.Uint16([]byte{q.buffer[2], q.buffer[3]})+4) != len(q.buffer) {
424+
q.lock.RUnlock()
425+
// end of segment not reached, just return
426+
return nil
419427
}
420428

421429
domain, err := ReadClientHello(q.buffer)

0 commit comments

Comments
 (0)