aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrik Flykt <patrik.flykt@linux.intel.com>2018-01-04 15:11:42 +0200
committerPatrik Flykt <patrik.flykt@linux.intel.com>2018-01-04 15:22:43 +0200
commitc6b4f32a507c5ad885265309b2ecb56e618564d5 (patch)
treed32cb199b81a63d999e8b6aba1cb63e71daa48c3 /src/libsystemd-network/sd-dhcp6-client.c
parentdhcp6: Sanitize DHCPv6 IA option parsing (diff)
downloadsystemd-c6b4f32a507c5ad885265309b2ecb56e618564d5.tar.gz
systemd-c6b4f32a507c5ad885265309b2ecb56e618564d5.tar.bz2
systemd-c6b4f32a507c5ad885265309b2ecb56e618564d5.zip
dhcp6: Add function for DHCPv6 Status option
Factor out code to parse a DHCPv6 Status option using a common function.
Diffstat (limited to 'src/libsystemd-network/sd-dhcp6-client.c')
-rw-r--r--src/libsystemd-network/sd-dhcp6-client.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/libsystemd-network/sd-dhcp6-client.c b/src/libsystemd-network/sd-dhcp6-client.c
index 9c758a4d0..3659356b5 100644
--- a/src/libsystemd-network/sd-dhcp6-client.c
+++ b/src/libsystemd-network/sd-dhcp6-client.c
@@ -740,7 +740,8 @@ static int client_parse_message(
while (pos < len) {
DHCP6Option *option = (DHCP6Option *)&message->options[pos];
- uint16_t optcode, optlen, status;
+ uint16_t optcode, optlen;
+ int status;
uint8_t *optval;
be32_t iaid_lease;
@@ -795,14 +796,13 @@ static int client_parse_message(
break;
case SD_DHCP6_OPTION_STATUS_CODE:
- if (optlen < 2)
- return -EINVAL;
-
- status = optval[0] << 8 | optval[1];
+ status = dhcp6_option_parse_status(option);
if (status) {
log_dhcp6_client(client, "%s Status %s",
dhcp6_message_type_to_string(message->type),
dhcp6_message_status_to_string(status));
+ dhcp6_lease_free_ia(&lease->ia);
+
return -EINVAL;
}