pypacker icon indicating copy to clipboard operation
pypacker copied to clipboard

IPv4 Packet Creation failed : TypeError: object of type 'NoneType' has no len()

Open sunilkr opened this issue 7 years ago • 1 comments

While crafting IPv4 packet, following exception was raise. Code:

        pkt = ip.IP(src_s='127.0.0.1', dst_s='127.0.0.2', tos=0, id=12, off=1024, ttl=64)
        pkt.flags = ip.IP_DF|ip.IP_MF
        pkt.body_bytes = b'12345678'
        raw = pkt.bin()

TraceBack:

Traceback (most recent call last):
  File "/home/user/code/py3/project/unittests/test_ip.py", line 57, in test_match_unicast_true
    raw = pkt.bin()
  File "/home/user/.local/lib/python3.6/site-packages/pypacker/pypacker.py", line 820, in bin
    layer._update_fields()
  File "/home/user/.local/lib/python3.6/site-packages/pypacker/layer3/ip.py", line 229, in _update_fields
    self.sum = in_cksum(self._pack_header())
  File "/home/user/.local/lib/python3.6/site-packages/pypacker/checksum.py", line 49, in in_cksum
    return in_cksum_done(in_cksum_add(0, buf))
  File "/home/user/.local/lib/python3.6/site-packages/pypacker/checksum.py", line 23, in in_cksum_add
    n = len(buf)
TypeError: object of type 'NoneType' has no len()

Something I did wrong, or its some corner case. Hoe to access error object from pypacker.PyPacket

sunilkr avatar Jul 16 '18 09:07 sunilkr

Thanks, fixed in gitlab repo at https://gitlab.com/mike01/pypacker

mike01 avatar Jul 16 '18 16:07 mike01