Open
Description
pyshark throws an exception when reading a pcap that cuts a packet in half. For reference, Wireshark displays the following error message when opening the file: "The capture file appears to have been cut short in the middle of a packet."
The following trace can be used to reproduce the error: trace.pcap.zip (Github doesn't allow me to upload a pcap, so please unzip it).
import pyshark
cap = pyshark.FileCapture("trace.pcap")
for p in cap:
print(p)
pyshark crashes saying
Traceback (most recent call last):
File "test.py", line 5, in <module>
for p in cap:
File "/usr/local/lib/python3.7/site-packages/pyshark/capture/capture.py", line 259, in _packets_from_tshark_sync
self.eventloop.run_until_complete(self._cleanup_subprocess(tshark_process))
File "/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/base_events.py", line 583, in run_until_complete
return future.result()
File "/usr/local/lib/python3.7/site-packages/pyshark/capture/capture.py", line 434, in _cleanup_subprocess
% process.returncode)
pyshark.capture.capture.TSharkCrashException: TShark seems to have crashed (retcode: 2). Try rerunning in debug mode [ capture_obj.set_debug() ] or try updating tshark.
Exception ignored in: <function Capture.__del__ at 0x10650fdd0>
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/pyshark/capture/capture.py", line 446, in __del__
File "/usr/local/lib/python3.7/site-packages/pyshark/capture/capture.py", line 437, in close
File "/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/base_events.py", line 583, in run_until_complete
File "/usr/local/lib/python3.7/site-packages/pyshark/capture/capture.py", line 441, in close_async
File "/usr/local/lib/python3.7/site-packages/pyshark/capture/capture.py", line 434, in _cleanup_subprocess
pyshark.capture.capture.TSharkCrashException: TShark seems to have crashed (retcode: 2). Try rerunning in debug mode [ capture_obj.set_debug() ] or try updating tshark.