]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-dhcp6: coding style cleanups
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 18 Oct 2018 18:38:59 +0000 (03:38 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 18 Oct 2018 21:11:58 +0000 (06:11 +0900)
src/libsystemd-network/sd-dhcp6-client.c

index 723e349a548ab7163cb37ada6a812ebef4f4c5d4..2ddfead4b0e6c0d4806372723cd136a9006e7887 100644 (file)
@@ -829,10 +829,11 @@ static int client_parse_message(
                 DHCP6Message *message,
                 size_t len,
                 sd_dhcp6_lease *lease) {
+
+        uint32_t lt_t1 = ~0, lt_t2 = ~0;
+        bool clientid = false;
         size_t pos = 0;
         int r;
-        bool clientid = false;
-        uint32_t lt_t1 = ~0, lt_t2 = ~0;
 
         assert(client);
         assert(message);
@@ -842,20 +843,22 @@ static int client_parse_message(
         len -= sizeof(DHCP6Message);
 
         while (pos < len) {
-                DHCP6Option *option = (DHCP6Option *)&message->options[pos];
+                DHCP6Option *option = (DHCP6Option *) &message->options[pos];
                 uint16_t optcode, optlen;
-                int status;
-                uint8_t *optval;
                 be32_t iaid_lease;
+                uint8_t *optval;
+                int status;
 
-                if (len < pos + offsetof(DHCP6Option, data) ||
-                    len < pos + offsetof(DHCP6Option, data) + be16toh(option->len))
+                if (len < pos + offsetof(DHCP6Option, data))
                         return -ENOBUFS;
 
                 optcode = be16toh(option->code);
                 optlen = be16toh(option->len);
                 optval = option->data;
 
+                if (len < pos + offsetof(DHCP6Option, data) + optlen)
+                        return -ENOBUFS;
+
                 switch (optcode) {
                 case SD_DHCP6_OPTION_CLIENTID:
                         if (clientid) {