]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-dhcp-server: drop unnecessary buffer duplication
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 22 Jan 2022 17:27:26 +0000 (02:27 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 23 Jan 2022 19:16:41 +0000 (04:16 +0900)
The block try to find and remove the existing static lease which matches
the provided client ID, and the provided client ID will not be stored
anywhere. Hence, it is not necessary to duplicate it.

src/libsystemd-network/sd-dhcp-server.c

index ea98060ea2026e6bb0ba17589a2193e8c9ece67e..4124abfc8cd3accfb8a2109b7acc9bc40dfa994a 100644 (file)
@@ -1536,18 +1536,13 @@ int sd_dhcp_server_set_static_lease(
         assert_return(!sd_dhcp_server_is_running(server), -EBUSY);
 
         /* Static lease with an empty or omitted address is a valid entry,
-        * the server removes any static lease with the specified mac address. */
+         * the server removes any static lease with the specified mac address. */
         if (!address || address->s_addr == 0) {
-                _cleanup_free_ void *data = NULL;
                 DHCPClientId c;
 
-                data = memdup(client_id, client_id_size);
-                if (!data)
-                        return -ENOMEM;
-
                 c = (DHCPClientId) {
                         .length = client_id_size,
-                        .data = data,
+                        .data = client_id,
                 };
 
                 dhcp_lease_free(hashmap_remove(server->static_leases_by_client_id, &c));