From bcbd41e9119098a01de54e4f6a963db73bef0033 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Mon, 30 Jan 2012 14:20:37 +0000 Subject: [PATCH] -possible fix for 2124 --- src/tun/tun.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/tun/tun.c b/src/tun/tun.c index e047db713..c1e7cbcb2 100644 --- a/src/tun/tun.c +++ b/src/tun/tun.c @@ -106,7 +106,7 @@ GNUNET_TUN_calculate_tcp4_checksum (const struct GNUNET_TUN_IPv4Header *ip, uint16_t payload_length) { uint32_t sum; - uint32_t tmp; + uint16_t tmp; GNUNET_assert (payload_length + sizeof (struct GNUNET_TUN_IPv4Header) + sizeof (struct GNUNET_TUN_TcpHeader) == ntohs (ip->total_length)); @@ -116,8 +116,10 @@ GNUNET_TUN_calculate_tcp4_checksum (const struct GNUNET_TUN_IPv4Header *ip, sum = GNUNET_CRYPTO_crc16_step (0, &ip->source_address, sizeof (struct in_addr) * 2); - tmp = htonl ((IPPROTO_TCP << 16) | (payload_length + sizeof (struct GNUNET_TUN_TcpHeader))); - sum = GNUNET_CRYPTO_crc16_step (sum, &tmp, sizeof (uint32_t)); + tmp = htons (IPPROTO_TCP); + sum = GNUNET_CRYPTO_crc16_step (sum, &tmp, sizeof (uint16_t)); + tmp = htons (payload_length + sizeof (struct GNUNET_TUN_TcpHeader)); + sum = GNUNET_CRYPTO_crc16_step (sum, &tmp, sizeof (uint16_t)); sum = GNUNET_CRYPTO_crc16_step (sum, tcp, sizeof (struct GNUNET_TUN_TcpHeader)); sum = GNUNET_CRYPTO_crc16_step (sum, payload, payload_length); tcp->crc = GNUNET_CRYPTO_crc16_finish (sum); -- 2.25.1