samuel / python-ping

Pure Python version of ICMP ping
229 stars 309 forks source link

Incorrect packet length due to padding encoding #15

Open bitflogger opened 4 years ago

bitflogger commented 4 years ago

hi,

I noticed that the packets sent in pyping are way too big. After some investigation I found out the padding is 4x larger than expected. It looks like the encoding will add 4 bytes to the datagram for every int in the padBytes array.

I fixed this by changing 'data = bytes(padBytes)' to 'str(bytearray(padBytes))' in /pyping/core.py function 'send_one_ping'.

I understand that bytearray is only available since python 2.6, so to preserve backward compatibility, you may want to use a slightly different method.

I use python 2.7.17 by the way.

regards, /steven

ps; sorry if i did not put a savvy diff in here. i'm new to this.