From: root Date: Wed, 1 Nov 2000 12:31:32 +0000 (+0100) Subject: [ID 20001101.001] Net::Ping icmp odd $bytes X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=42fcf866a290d62f078d5321c995231f7b43e4f2;p=p5sagit%2Fp5-mst-13.2.git [ID 20001101.001] Net::Ping icmp odd $bytes Message-Id: <200011011131.MAA03310@chronos.fi.muni.cz> p4raw-id: //depot/perl@7513 --- diff --git a/lib/Net/Ping.pm b/lib/Net/Ping.pm index 40da9f3..9cc942d 100644 --- a/lib/Net/Ping.pm +++ b/lib/Net/Ping.pm @@ -269,13 +269,13 @@ sub checksum ); $len_msg = length($msg); - $num_short = $len_msg / 2; + $num_short = int($len_msg / 2); $chk = 0; foreach $short (unpack("S$num_short", $msg)) { $chk += $short; } # Add the odd byte in - $chk += unpack("C", substr($msg, $len_msg - 1, 1)) if $len_msg % 2; + $chk += (unpack("C", substr($msg, $len_msg - 1, 1)) << 8) if $len_msg % 2; $chk = ($chk >> 16) + ($chk & 0xffff); # Fold high into low return(~(($chk >> 16) + $chk) & 0xffff); # Again and complement }