diff --git a/CHANGELOG b/CHANGELOG index d54f6ff2c..8a6b8e525 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -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] diff --git a/nbase/nbase_misc.c b/nbase/nbase_misc.c index fc4179d3a..391ab19f6 100644 --- a/nbase/nbase_misc.c +++ b/nbase/nbase_misc.c @@ -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;