kisom / pypcapfile

Pure Python library for handling libpcap savefiles.
http://kisom.github.com/pypcapfile
ISC License
76 stars 33 forks source link

UDP.payload is wrongly assumed to be NUL-terminated #52

Closed jchia closed 3 years ago

jchia commented 3 years ago

UDP.payload is wrong if the payload contains a NUL (b'\x00') character.

>>> from pcapfile.protocols.transport import udp
>>> u = udp.UDP(b'\x00\x00\x00\x00\x00\x01\x00\x00\x00')
>>> u.payload    # Should be b'\x00'
b''

This is because of the use of c_char_p, which is for NUL-terminated strings, but UDP payloads in general can contain NUL characters. Why is c_char_p used for payload? What is the purpose using ctypes and ctypes.Structure for the UDP class?

kisom commented 3 years ago

Fixed in #53.