chunk: Fix internet checksum calculation on big-endian systems
ntohs() might be defined as noop (#define ntohs(x) (x)) so we have to manually shorten the negated value (gets promoted to an int). Fixes #747.
This commit is contained in:
@@ -992,7 +992,7 @@ u_int32_t chunk_hash_static(chunk_t chunk)
|
||||
*/
|
||||
u_int16_t chunk_internet_checksum_inc(chunk_t data, u_int16_t checksum)
|
||||
{
|
||||
u_int32_t sum = ntohs(~checksum);
|
||||
u_int32_t sum = ntohs((u_int16_t)~checksum);
|
||||
|
||||
while (data.len > 1)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user