Fix CRC32c calculation on 64-bit platforms.

Patch by Pontus Andersson.
http://seclists.org/nmap-dev/2012/q4/361
This commit is contained in:
david 2012-12-01 23:03:05 +00:00
parent c11d183718
commit 8d6dce4a01
2 changed files with 8 additions and 2 deletions

View file

@ -1,5 +1,8 @@
# Nmap Changelog ($Id$); -*-text-*-
o Fixed CRC32c calculation (as used in SCTP scans) on 64-bit
platforms. [Pontus Andersson]
o [NSE] Added multicast group name output to
broadcast-igmp-discovery.nse. [Vasily Kulikov]

View file

@ -560,14 +560,17 @@ unsigned long nbase_crc32(unsigned char *buf, int len)
/*
* CRC-32C (Castagnoli) Cyclic Redundancy Check.
* Taken straight from RFC 4960 (SCTP).
* Taken straight from Appendix C of RFC 4960 (SCTP), with the difference that
* the remainder register (crc32) is initialized to 0xffffffffL rather than ~0L,
* for correct operation on platforms where unisigned long is longer than 32
* bits.
*/
/* Return the CRC-32C of the bytes buf[0..len-1] */
unsigned long nbase_crc32c(unsigned char *buf, int len)
{
int i;
unsigned long crc32 = ~0L;
unsigned long crc32 = 0xffffffffL;
unsigned long result;
unsigned char byte0, byte1, byte2, byte3;