diff options
author | Patrik Flykt <patrik.flykt@linux.intel.com> | 2014-01-31 11:31:23 +0200 |
---|---|---|
committer | Tom Gundersen <teg@jklm.no> | 2014-01-31 12:04:51 +0100 |
commit | 1aed1cbc10d33e5bf5836e6838ac16add2002152 (patch) | |
tree | a08af0687a9ba92fb257fb099e39d78eb103afc5 | |
parent | e44127018aaae2126734aca65a3e46dc14bf1825 (diff) |
libsystemd-dhcp: Compute UDP checksum only if set
A checksum field with value zero means no UDP checksum has been
computed for the packet.
-rw-r--r-- | src/libsystemd-dhcp/sd-dhcp-client.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/libsystemd-dhcp/sd-dhcp-client.c b/src/libsystemd-dhcp/sd-dhcp-client.c index 130a61d6f8..37fad9a301 100644 --- a/src/libsystemd-dhcp/sd-dhcp-client.c +++ b/src/libsystemd-dhcp/sd-dhcp-client.c @@ -838,13 +838,18 @@ static int client_verify_headers(sd_dhcp_client *client, DHCPPacket *message, hdrlen)) return -EINVAL; - message->ip.check = message->udp.len; - message->ip.ttl = 0; - - if (hdrlen + be16toh(message->udp.len) > len || - client_checksum(&message->ip.ttl, be16toh(message->udp.len) + 12)) + if (hdrlen + be16toh(message->udp.len) > len) return -EINVAL; + if (message->udp.check) { + message->ip.check = message->udp.len; + message->ip.ttl = 0; + + if (client_checksum(&message->ip.ttl, + be16toh(message->udp.len) + 12)) + return -EINVAL; + } + if (be16toh(message->udp.source) != DHCP_PORT_SERVER || be16toh(message->udp.dest) != DHCP_PORT_CLIENT) return -EINVAL; |