QUIC sniffer: Fix potential slice panic

This commit is contained in:
风扇滑翔翼 2025-05-16 11:42:54 +00:00 committed by GitHub
parent 72170d8b6b
commit 1bfc956858
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 22 additions and 0 deletions

View file

@ -267,3 +267,21 @@ func TestSniffQUICPacketNumberLength4(t *testing.T) {
t.Error("failed")
}
}
func TestSniffFakeQUICPacketWithInvalidPacketNumberLength(t *testing.T) {
pkt, err := hex.DecodeString("cb00000001081c8c6d5aeb53d54400000090709b8600000000000000000000000000000000")
common.Must(err)
_, err = quic.SniffQUIC(pkt)
if err == nil {
t.Error("failed")
}
}
func TestSniffFakeQUICPacketWithTooShortData(t *testing.T) {
pkt, err := hex.DecodeString("cb00000001081c8c6d5aeb53d54400000090709b86")
common.Must(err)
_, err = quic.SniffQUIC(pkt)
if err == nil {
t.Error("failed")
}
}