Skip to content

Commit

Permalink
Merge aa042f2 into 23dfff7
Browse files Browse the repository at this point in the history
  • Loading branch information
Schwaggot committed Jun 2, 2022
2 parents 23dfff7 + aa042f2 commit 927f2a6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions docs/authors.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,7 @@ Dug Song \<<dugsong@monkey.org>\>
- crocogorical \<<crocogorical@gmail.com>\>
Extend test coverage

- Schwaggot \<<tom.ryan@posteo.de>\>
Graceful handling of PCAPNG option comment UTF-8 decoding errors

If you want to contribute to dpkt, see `contributing`.
8 changes: 7 additions & 1 deletion dpkt/pcapng.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,13 @@ def unpack(self, buf):

# decode comment
if self.code == PCAPNG_OPT_COMMENT:
self.text = self.data.decode('utf-8')
try:
self.text = self.data.decode('utf-8')
except UnicodeDecodeError as ude:
if b'\x00' in self.data:
self.text = self.data[:self.data.index(b'\x00')].decode('ascii')
else:
raise ude

def __bytes__(self):
# encode comment
Expand Down

0 comments on commit 927f2a6

Please sign in to comment.