Skip to content

Commit

Permalink
commetn test
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Ku authored and gconnell committed Sep 28, 2020
1 parent 57d03ad commit 62ace14
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions reassembly/tcpassembly_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1199,13 +1199,20 @@ func TestKeepWithFlush(t *testing.T) {
})
}

func TestKeepWithManualFlush(t *testing.T) {
func TestKeepWithOutOfOrderPacketAndManualFlush(t *testing.T) {
makePayload := func(length int) []byte {
data := make([]byte, length)
rand.Read(data)
return data
}

// The first packet is received out of order. It contains `pageBytes + 1`
// number of bytes, so it spans 2 pages.
// The second packet carries a single byte before the first packet, and we
// request to keep `pageBytes` bytes. Then trigger a flush.
// Prior to a fix, this would result in an slice bounds out of range panic
// when the code tries to incorrectly skip the leading bytes on the second
// page of the first packet.
testKeep(t, []testKeepSequence{
{
tcp: layers.TCP{
Expand All @@ -1223,13 +1230,11 @@ func TestKeepWithManualFlush(t *testing.T) {
Seq: 1000,
BaseLayer: layers.BaseLayer{Payload: []byte{1}},
},
keep: 3,
keep: pageBytes,
want: []byte{},
flush: true,
},
})

t.Errorf("fake error")
}

/*
Expand Down

0 comments on commit 62ace14

Please sign in to comment.