mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-07-05 04:18:50 +00:00
Fix a nil pointer dereference
error that occurs in tcpReader
's Read
method (#1090)
* Fix a `nil pointer dereference` error that occurs in `tcpReader`'s `Read` method
* #run_acceptance_tests
* #run_acceptance_tests
* Revert "Fix a `nil pointer dereference` error that occurs in `tcpReader`'s `Read` method"
This reverts commit ccef6cb393
.
* Fix the race condition using locks #run_acceptance_tests
This commit is contained in:
parent
8418802c7e
commit
fc194354bc
@ -82,10 +82,14 @@ func (reader *tcpReader) isProtocolIdentified() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (reader *tcpReader) rewind() {
|
func (reader *tcpReader) rewind() {
|
||||||
// Reset the data and msgBuffer from the master record
|
// Reset the data
|
||||||
reader.data = make([]byte, 0)
|
reader.data = make([]byte, 0)
|
||||||
|
|
||||||
|
// Reset msgBuffer from the master record
|
||||||
|
reader.parent.Lock()
|
||||||
reader.msgBuffer = make([]api.TcpReaderDataMsg, len(reader.msgBufferMaster))
|
reader.msgBuffer = make([]api.TcpReaderDataMsg, len(reader.msgBufferMaster))
|
||||||
copy(reader.msgBuffer, reader.msgBufferMaster)
|
copy(reader.msgBuffer, reader.msgBufferMaster)
|
||||||
|
reader.parent.Unlock()
|
||||||
|
|
||||||
// Reset the read progress
|
// Reset the read progress
|
||||||
reader.progress.Reset()
|
reader.progress.Reset()
|
||||||
|
@ -72,8 +72,10 @@ func (t *tcpStream) SetProtocol(protocol *api.Protocol) {
|
|||||||
t.protocol = protocol
|
t.protocol = protocol
|
||||||
|
|
||||||
// Clean the buffers
|
// Clean the buffers
|
||||||
|
t.Lock()
|
||||||
t.client.msgBufferMaster = make([]api.TcpReaderDataMsg, 0)
|
t.client.msgBufferMaster = make([]api.TcpReaderDataMsg, 0)
|
||||||
t.server.msgBufferMaster = make([]api.TcpReaderDataMsg, 0)
|
t.server.msgBufferMaster = make([]api.TcpReaderDataMsg, 0)
|
||||||
|
t.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *tcpStream) GetOrigin() api.Capture {
|
func (t *tcpStream) GetOrigin() api.Capture {
|
||||||
|
Loading…
Reference in New Issue
Block a user