]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-dhcp6-client: use memcmp_nn() at one more place
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 7 Feb 2022 12:09:53 +0000 (21:09 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 14 Feb 2022 06:01:02 +0000 (15:01 +0900)
src/libsystemd-network/sd-dhcp6-lease.c

index 90c3373bd50f0e9cf9f6e185c5687d89e7bb9c81..5617e85212f7856de76cbd67f67df11a5197dbbd 100644 (file)
@@ -621,12 +621,13 @@ static int dhcp6_lease_parse_message(
         uint8_t *clientid;
         size_t clientid_len;
         if (dhcp6_lease_get_clientid(lease, &clientid, &clientid_len) < 0)
-                return log_dhcp6_client_errno(client, SYNTHETIC_ERRNO(EINVAL), "%s message does not contain client ID. Ignoring.",
+                return log_dhcp6_client_errno(client, SYNTHETIC_ERRNO(EINVAL),
+                                              "%s message does not contain client ID. Ignoring.",
                                               dhcp6_message_type_to_string(message->type));
 
-        if (clientid_len != client->duid_len ||
-            memcmp(clientid, &client->duid, clientid_len) != 0)
-                return log_dhcp6_client_errno(client, SYNTHETIC_ERRNO(EINVAL), "The client ID in %s message does not match. Ignoring.",
+        if (memcmp_nn(clientid, clientid_len, &client->duid, client->duid_len) != 0)
+                return log_dhcp6_client_errno(client, SYNTHETIC_ERRNO(EINVAL),
+                                              "The client ID in %s message does not match. Ignoring.",
                                               dhcp6_message_type_to_string(message->type));
 
         if (client->state != DHCP6_STATE_INFORMATION_REQUEST) {
@@ -636,7 +637,8 @@ static int dhcp6_lease_parse_message(
                                                       dhcp6_message_type_to_string(message->type));
 
                 if (!lease->ia_na && !lease->ia_pd)
-                        return log_dhcp6_client_errno(client, SYNTHETIC_ERRNO(EINVAL), "No IA_PD prefix or IA_NA address received. Ignoring.");
+                        return log_dhcp6_client_errno(client, SYNTHETIC_ERRNO(EINVAL),
+                                                      "No IA_PD prefix or IA_NA address received. Ignoring.");
 
                 dhcp6_lease_set_lifetime(lease);
         }