summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
77e8d29)
Fix off-by-one error and notice that summing may need more than one
round for the result to be in the lower 16 bits.
if (len & 0x01) {
odd = buf;
if (len & 0x01) {
odd = buf;
- return ~((sum & 0xffff) + (sum >> 16));
+ while (sum >> 16)
+ sum = (sum & 0xffff) + (sum >> 16);
+
+ return ~sum;
}
static void client_append_ip_headers(DHCPPacket *packet, uint16_t len)
}
static void client_append_ip_headers(DHCPPacket *packet, uint16_t len)
if (len & 0x01) {
odd = buf;
if (len & 0x01) {
odd = buf;
- return ~((sum & 0xffff) + (sum >> 16));
+ while (sum >> 16)
+ sum = (sum & 0xffff) + (sum >> 16);
+
+ return ~sum;
}
static void test_checksum(void)
}
static void test_checksum(void)