-
Notifications
You must be signed in to change notification settings - Fork 42
Description
Steps:
Attempt to load attached pcap file pcap_with_error.zip
I am using something like bellow
scanner = pcapng.scanner.FileScanner(fp)
for block in scanner:
pass
The attached pcap is not 100% according with the pcapng spec. The library attempts to log following warning: "repeated option 2 'if_name' not permitted by pcapng spec"
Instead, we will see a crash:
for block in scanner:
File "C:\Users\cacatana.KEYSIGHT\AppData\Local\Programs\Python\Python37\lib\site-packages\pcapng\scanner.py", line 46, in iter
yield self._read_next_block()
File "C:\Users\cacatana.KEYSIGHT\AppData\Local\Programs\Python\Python37\lib\site-packages\pcapng\scanner.py", line 62, in _read_next_block
block = self._read_block(block_type)
File "C:\Users\cacatana.KEYSIGHT\AppData\Local\Programs\Python\Python37\lib\site-packages\pcapng\scanner.py", line 90, in _read_block
blocks.KNOWN_BLOCKS[block_type], raw=data
File "C:\Users\cacatana.KEYSIGHT\AppData\Local\Programs\Python\Python37\lib\site-packages\pcapng\blocks.py", line 207, in new_member
blk = cls(section=self, endianness=self.endianness, **kwargs)
File "C:\Users\cacatana.KEYSIGHT\AppData\Local\Programs\Python\Python37\lib\site-packages\pcapng\blocks.py", line 148, in init
super(SectionMemberBlock, self).init(**kwargs)
File "C:\Users\cacatana.KEYSIGHT\AppData\Local\Programs\Python\Python37\lib\site-packages\pcapng\blocks.py", line 50, in init
self.schema, io.BytesIO(kwargs["raw"]), kwargs["endianness"]
File "C:\Users\cacatana.KEYSIGHT\AppData\Local\Programs\Python\Python37\lib\site-packages\pcapng\structs.py", line 1033, in struct_decode
decoded[name] = field.load(stream, endianness=endianness, seen=decoded)
File "C:\Users\cacatana.KEYSIGHT\AppData\Local\Programs\Python\Python37\lib\site-packages\pcapng\structs.py", line 377, in load
return Options(schema=self.options_schema, data=options, endianness=endianness)
File "C:\Users\cacatana.KEYSIGHT\AppData\Local\Programs\Python\Python37\lib\site-packages\pcapng\structs.py", line 731, in init
self._update_data(data)
File "C:\Users\cacatana.KEYSIGHT\AppData\Local\Programs\Python\Python37\lib\site-packages\pcapng\structs.py", line 823, in _update_data
"repeated option {} not permitted by pcapng spec".format(name)
File "C:\Users\cacatana.KEYSIGHT\AppData\Local\Programs\Python\Python37\lib\site-packages\pcapng\strictness.py", line 38, in warn
if strict_level > Strictness.NONE:
TypeError: '>' not supported between instances of 'Strictness' and 'Strictness'
This is happening because the Strictness is derived from Enum instead of IntEnum. Operators like < > work only with IntEnum.