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:
Tobias Brunner
2014-10-23 11:13:28 +02:00
parent 4736ba0657
commit eb218ff80b
+1 -1
View File
@@ -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)
{