summaryrefslogtreecommitdiff
path: root/lib/Net
diff options
context:
space:
mode:
authorroot <root@chronos.fi.muni.cz>2000-11-01 13:31:32 +0100
committerJarkko Hietaniemi <jhi@iki.fi>2000-11-01 14:48:30 +0000
commit42fcf866a290d62f078d5321c995231f7b43e4f2 (patch)
tree62adbf2ba7d5913e8ddd2f1cc15c924bec7d5e91 /lib/Net
parentaa7a4b5649e7441cdc7e4a80ceb1f297664333db (diff)
downloadperl-42fcf866a290d62f078d5321c995231f7b43e4f2.tar.gz
[ID 20001101.001] Net::Ping icmp odd $bytes
Message-Id: <200011011131.MAA03310@chronos.fi.muni.cz> p4raw-id: //depot/perl@7513
Diffstat (limited to 'lib/Net')
-rw-r--r--lib/Net/Ping.pm4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/Net/Ping.pm b/lib/Net/Ping.pm
index 40da9f3817..9cc942da69 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
}