QUIC sniffer: Fix potential slice panic (#4732)

Fixes https://github.com/XTLS/Xray-core/issues/3914#issuecomment-2853392827
This commit is contained in:
风扇滑翔翼 2025-05-16 20:08:29 +08:00 committed by GitHub
parent bb0e561caf
commit ef1c165cc5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 22 additions and 0 deletions

View file

@ -114,6 +114,10 @@ func SniffQUIC(b []byte) (*SniffHeader, error) {
if err != nil {
return nil, errNotQuic
}
// packetLen is impossible to be shorter than this
if packetLen < 4 {
return nil, errNotQuic
}
hdrLen := len(b) - int(buffer.Len())
if len(b) < hdrLen+int(packetLen) {