X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Froute.c;h=d1048e76dc7c4890ad23c08a4e68048c6d7106a6;hb=de7d5a03c2b956ab5753faf63b8148a279a71f29;hp=fc08f5f7aae7c8cb3a1a87bb3c96821677e1a672;hpb=d6b45d005530496e48325a6174ecdd889a17bfc1;p=tinc diff --git a/src/route.c b/src/route.c index fc08f5f7..d1048e76 100644 --- a/src/route.c +++ b/src/route.c @@ -59,33 +59,30 @@ static const size_t opt_size = sizeof(struct nd_opt_hdr); #define MAX(a, b) ((a) > (b) ? (a) : (b)) #endif -volatile int dummy; static timeout_t age_subnets_timeout; /* RFC 1071 */ -static uint16_t inet_checksum(void *data, int len, uint16_t prevsum) { - uint16_t *p = data; +static uint16_t inet_checksum(void *vdata, int len, uint16_t prevsum) { + uint8_t *data = vdata; + uint16_t word; uint32_t checksum = prevsum ^ 0xFFFF; while(len >= 2) { - checksum += *p++; + memcpy(&word, data, sizeof(word)); + checksum += word; + data += 2; len -= 2; } if(len) { - checksum += *(uint8_t *)p; + checksum += *data; } while(checksum >> 16) { checksum = (checksum & 0xFFFF) + (checksum >> 16); } - // Work around a compiler optimization bug. - if(checksum) { - dummy = 1; - } - return ~checksum; }