summaryrefslogtreecommitdiff
path: root/src/libsystemd-dhcp/sd-dhcp-client.c
diff options
context:
space:
mode:
authorPatrik Flykt <patrik.flykt@linux.intel.com>2014-01-31 11:31:23 +0200
committerTom Gundersen <teg@jklm.no>2014-01-31 12:04:51 +0100
commit1aed1cbc10d33e5bf5836e6838ac16add2002152 (patch)
treea08af0687a9ba92fb257fb099e39d78eb103afc5 /src/libsystemd-dhcp/sd-dhcp-client.c
parente44127018aaae2126734aca65a3e46dc14bf1825 (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.
Diffstat (limited to 'src/libsystemd-dhcp/sd-dhcp-client.c')
-rw-r--r--src/libsystemd-dhcp/sd-dhcp-client.c15
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;