From: russor Date: Mon, 18 Apr 2016 22:13:21 +0000 (-0700) Subject: copy odd byte into a 16-bit temp value; used bit-sized types for calrity X-Git-Tag: v0.87~12^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f9e7efec1372eb6fe2828f3771c200e247886f34;p=thirdparty%2Fmtr.git copy odd byte into a 16-bit temp value; used bit-sized types for calrity --- diff --git a/net.c b/net.c index 66319e2..f743492 100644 --- a/net.c +++ b/net.c @@ -233,13 +233,15 @@ int calc_deltatime (float waittime) int checksum(void *data, int sz) { - unsigned short *ch; - unsigned int sum; + uint16 *ch; + uint32 sum; + uint16 odd; sum = 0; ch = data; if (sz % 2) { - ((char *)&sum)[0] = ((char *)data)[sz - 1]; + ((char *)&odd)[0] = ((char *)data)[sz - 1]; + sum = odd; } sz = sz / 2; while (sz--) {