Graceful handling of PCAPNG option comment UTF-8 decoding errors #631
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I believe before the current PCAPNG standard it was customary to have zero-terminated C-strings as comments, similar to the PCAP format. Although by now deprecated and switched to UTF-8 strings there are still capture files out there that have this old format. At the moment dpkt would just crash with a
UnicodeDecodeError
while trying to read these comments, which is a bit harsh for a field that has usually no contribution to the capture itself.When merged this will add gracefull support for UTF-8 decoding errors, i.e., it will first try to parse comments as UTF-8 (new standard), if that fails it will check whether the data contains a zero-terminator and interpret it as a C-string. If no zero-terminator is found, the
UnicodeDecodeError
will still be raised (as previously).