summaryrefslogtreecommitdiff
path: root/src/libsystemd-network/sd-dhcp6-client.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-08-30 18:31:21 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-08-30 18:42:20 -0400
commit44481a8b537839cd9ffead4d261491641f5b5260 (patch)
treef7c470f7aee00423c1603ef009243395639ac7c2 /src/libsystemd-network/sd-dhcp6-client.c
parentd182960ae974a0074010a058d0d909846a2f3f79 (diff)
sd-dhcp6-client: properly calculate buffer size when parsing options
Also make pointer calculations more explicit so they are easier to understand.
Diffstat (limited to 'src/libsystemd-network/sd-dhcp6-client.c')
-rw-r--r--src/libsystemd-network/sd-dhcp6-client.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/libsystemd-network/sd-dhcp6-client.c b/src/libsystemd-network/sd-dhcp6-client.c
index 342a231413..6860c66858 100644
--- a/src/libsystemd-network/sd-dhcp6-client.c
+++ b/src/libsystemd-network/sd-dhcp6-client.c
@@ -583,12 +583,15 @@ static int client_parse_message(sd_dhcp6_client *client,
DHCP6Message *message, size_t len,
sd_dhcp6_lease *lease) {
int r;
- uint8_t *optval, *option = (uint8_t *)(message + 1), *id = NULL;
+ uint8_t *optval, *option, *id = NULL;
uint16_t optcode, status;
size_t optlen, id_len;
bool clientid = false;
be32_t iaid_lease;
+ option = (uint8_t *)message + sizeof(DHCP6Message);
+ len -= sizeof(DHCP6Message);
+
while ((r = dhcp6_option_parse(&option, &len, &optcode, &optlen,
&optval)) >= 0) {
switch (optcode) {