diff options
author | Emiliano Ciavatta | 2020-12-16 14:28:25 +0000 |
---|---|---|
committer | Emiliano Ciavatta | 2020-12-16 14:28:25 +0000 |
commit | 56fb63868006268ce32ccd9a0f64b1dcbe65ec70 (patch) | |
tree | c9a2ee1e4d362e7bfba682a054e187fcb2bc3f06 /stream_handler.go | |
parent | 7a684f3b161ce4515b67b2f383631088867d0c39 (diff) |
Fix crashes in stream handler
Diffstat (limited to 'stream_handler.go')
-rw-r--r-- | stream_handler.go | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/stream_handler.go b/stream_handler.go index f08bd70..8042bcb 100644 --- a/stream_handler.go +++ b/stream_handler.go @@ -80,20 +80,22 @@ func NewStreamHandler(connection ConnectionHandler, streamFlow StreamFlow, scann func (sh *StreamHandler) Reassembled(reassembly []tcpassembly.Reassembly) { for _, r := range reassembly { skip := r.Skip + isLoss := skip != 0 + if r.Start { sh.firstPacketSeen = r.Seen } if r.End { sh.lastPacketSeen = r.Seen } - if skip < 0 { // start or flush ~ workaround - skip = 0 - } reassemblyLen := len(r.Bytes) if reassemblyLen == 0 { continue } + if skip < 0 || skip >= reassemblyLen { // start or flush ~ workaround + skip = 0 + } if sh.buffer.Len()+len(r.Bytes)-skip > MaxDocumentSize { sh.storageCurrentDocument() @@ -106,7 +108,7 @@ func (sh *StreamHandler) Reassembled(reassembly []tcpassembly.Reassembly) { } sh.indexes = append(sh.indexes, sh.currentIndex) sh.timestamps = append(sh.timestamps, r.Seen) - sh.lossBlocks = append(sh.lossBlocks, skip != 0) + sh.lossBlocks = append(sh.lossBlocks, isLoss) sh.currentIndex += n sh.streamLength += n |