From 0bbc2c1f3b8f01eac7826dab1a3e1e073f63da8a Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Mon, 16 Jun 2014 15:24:28 +0200 Subject: sd-dhcp: checksum - make endianess-neutral For efficiency, we group bytes together before adding them up. This is guaranteed to always work (regardless of the byte order) as long as the i-th byte in each group lign up with the i-th byte in each other group. On big-endian machines this broke when handling the trailing few bytes which did not make up a full group of 4 bytes. This patch fixes the problem by explicitly creating a 4 byte zero-padded group out of the trailing bytes. Reported and tested by Thomas Ritter . --- src/libsystemd-network/dhcp-internal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/libsystemd-network/dhcp-internal.h') diff --git a/src/libsystemd-network/dhcp-internal.h b/src/libsystemd-network/dhcp-internal.h index 76d357a6ed..03cc8243a9 100644 --- a/src/libsystemd-network/dhcp-internal.h +++ b/src/libsystemd-network/dhcp-internal.h @@ -48,7 +48,7 @@ int dhcp_option_parse(DHCPMessage *message, size_t len, int dhcp_message_init(DHCPMessage *message, uint8_t op, uint32_t xid, uint8_t type, size_t optlen, size_t *optoffset); -uint16_t dhcp_packet_checksum(void *buf, size_t len); +uint16_t dhcp_packet_checksum(uint8_t *buf, size_t len); void dhcp_packet_append_ip_headers(DHCPPacket *packet, be32_t source_addr, uint16_t source, be32_t destination_addr, -- cgit v1.2.3-54-g00ecf