diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-01-30 14:20:37 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-01-30 14:20:37 +0000 |
commit | bcbd41e9119098a01de54e4f6a963db73bef0033 (patch) | |
tree | 05720bd61fdcd945d4e39c78ae0bc9bcdcd9be06 /src/tun | |
parent | 2e522732d14b925f6fbf94a4db75b80a04f8cb7a (diff) | |
download | gnunet-bcbd41e9119098a01de54e4f6a963db73bef0033.tar.gz gnunet-bcbd41e9119098a01de54e4f6a963db73bef0033.zip |
-possible fix for 2124
Diffstat (limited to 'src/tun')
-rw-r--r-- | src/tun/tun.c | 8 |
1 files 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, | |||
106 | uint16_t payload_length) | 106 | uint16_t payload_length) |
107 | { | 107 | { |
108 | uint32_t sum; | 108 | uint32_t sum; |
109 | uint32_t tmp; | 109 | uint16_t tmp; |
110 | 110 | ||
111 | GNUNET_assert (payload_length + sizeof (struct GNUNET_TUN_IPv4Header) + sizeof (struct GNUNET_TUN_TcpHeader) == | 111 | GNUNET_assert (payload_length + sizeof (struct GNUNET_TUN_IPv4Header) + sizeof (struct GNUNET_TUN_TcpHeader) == |
112 | ntohs (ip->total_length)); | 112 | ntohs (ip->total_length)); |
@@ -116,8 +116,10 @@ GNUNET_TUN_calculate_tcp4_checksum (const struct GNUNET_TUN_IPv4Header *ip, | |||
116 | sum = GNUNET_CRYPTO_crc16_step (0, | 116 | sum = GNUNET_CRYPTO_crc16_step (0, |
117 | &ip->source_address, | 117 | &ip->source_address, |
118 | sizeof (struct in_addr) * 2); | 118 | sizeof (struct in_addr) * 2); |
119 | tmp = htonl ((IPPROTO_TCP << 16) | (payload_length + sizeof (struct GNUNET_TUN_TcpHeader))); | 119 | tmp = htons (IPPROTO_TCP); |
120 | sum = GNUNET_CRYPTO_crc16_step (sum, &tmp, sizeof (uint32_t)); | 120 | sum = GNUNET_CRYPTO_crc16_step (sum, &tmp, sizeof (uint16_t)); |
121 | tmp = htons (payload_length + sizeof (struct GNUNET_TUN_TcpHeader)); | ||
122 | sum = GNUNET_CRYPTO_crc16_step (sum, &tmp, sizeof (uint16_t)); | ||
121 | sum = GNUNET_CRYPTO_crc16_step (sum, tcp, sizeof (struct GNUNET_TUN_TcpHeader)); | 123 | sum = GNUNET_CRYPTO_crc16_step (sum, tcp, sizeof (struct GNUNET_TUN_TcpHeader)); |
122 | sum = GNUNET_CRYPTO_crc16_step (sum, payload, payload_length); | 124 | sum = GNUNET_CRYPTO_crc16_step (sum, payload, payload_length); |
123 | tcp->crc = GNUNET_CRYPTO_crc16_finish (sum); | 125 | tcp->crc = GNUNET_CRYPTO_crc16_finish (sum); |