Bug 6765: sip2 unicode checksum

Changes checksum calculation method, as per Dan Scott's fix in openncip.
see http://sourceforge.net/tracker/?func=detail&aid=2925760&group_id=161781&atid=821216

http://bugs.koha-community.org/show_bug.cgi?id=6765
Signed-off-by: Ian Walls <ian.walls@bywatersolutions.com>
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
This commit is contained in:
Ulrich Kleiber 2011-07-29 16:35:40 +02:00 committed by Chris Cormack
parent eb7456c685
commit 8a7c916766

View file

@ -10,7 +10,7 @@ our $debug = 0;
sub checksum {
my $pkt = shift;
return (-unpack('%16U*', $pkt) & 0xFFFF);
return (-unpack('%16C*', $pkt) & 0xFFFF);
}
sub verify_cksum {
@ -29,7 +29,7 @@ sub verify_cksum {
# Convert the checksum back to hex and calculate the sum of the
# pack without the checksum.
$cksum = hex($1);
$shortsum = unpack("%16U*", substr($pkt, 0, -4));
$shortsum = unpack("%16C*", substr($pkt, 0, -4));
# The checksum is valid if the hex sum, plus the checksum of the
# base packet short when truncated to 16 bits.