File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed
Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -114,6 +114,10 @@ func SniffQUIC(b []byte) (*SniffHeader, error) {
114114 if err != nil {
115115 return nil , errNotQuic
116116 }
117+ // packetLen is impossible to be shorter than this
118+ if packetLen < 4 {
119+ return nil , errNotQuic
120+ }
117121
118122 hdrLen := len (b ) - int (buffer .Len ())
119123 if len (b ) < hdrLen + int (packetLen ) {
Original file line number Diff line number Diff line change @@ -267,3 +267,21 @@ func TestSniffQUICPacketNumberLength4(t *testing.T) {
267267 t .Error ("failed" )
268268 }
269269}
270+
271+ func TestSniffFakeQUICPacketWithInvalidPacketNumberLength (t * testing.T ) {
272+ pkt , err := hex .DecodeString ("cb00000001081c8c6d5aeb53d54400000090709b8600000000000000000000000000000000" )
273+ common .Must (err )
274+ _ , err = quic .SniffQUIC (pkt )
275+ if err == nil {
276+ t .Error ("failed" )
277+ }
278+ }
279+
280+ func TestSniffFakeQUICPacketWithTooShortData (t * testing.T ) {
281+ pkt , err := hex .DecodeString ("cb00000001081c8c6d5aeb53d54400000090709b86" )
282+ common .Must (err )
283+ _ , err = quic .SniffQUIC (pkt )
284+ if err == nil {
285+ t .Error ("failed" )
286+ }
287+ }
You can’t perform that action at this time.
0 commit comments