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?
UDP.payload
is wrong if the payload contains a NUL (b'\x00') character.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 isc_char_p
used forpayload
? What is the purpose usingctypes
andctypes.Structure
for theUDP
class?