Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graceful handling of PCAPNG option comment UTF-8 decoding errors #631

Merged
merged 8 commits into from
Jun 17, 2022

Conversation

Schwaggot
Copy link
Contributor

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).

@coveralls
Copy link

coveralls commented Jun 2, 2022

Coverage Status

Coverage increased (+0.0004%) to 99.816% when pulling 03ec7fc on Schwaggot:graceful-comment-utf-8-decoding into 23dfff7 on kbandla:master.

@Schwaggot
Copy link
Contributor Author

Added unit tests.

dpkt/pcapng.py Outdated Show resolved Hide resolved
docs/authors.md Outdated Show resolved Hide resolved
@obormot obormot merged commit e38d18d into kbandla:master Jun 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants