summaryrefslogtreecommitdiffstats
path: root/src/libsystemd-network/fuzz-dhcp-server.c
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2021-08-11 09:18:45 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2021-08-11 09:43:26 +0200
commitb713a99b1a04507412b387214a26e43a2916bd01 (patch)
tree9156c61032e5b8ed28285fd48f77fb9e89856a5f /src/libsystemd-network/fuzz-dhcp-server.c
parentsd-dhcp-server: fix possible double-free or use-after-free (diff)
downloadsystemd-b713a99b1a04507412b387214a26e43a2916bd01.tar.xz
systemd-b713a99b1a04507412b387214a26e43a2916bd01.zip
sd-dhcp-server: support static lease outside of address pool
Closes #20341.
Diffstat (limited to 'src/libsystemd-network/fuzz-dhcp-server.c')
-rw-r--r--src/libsystemd-network/fuzz-dhcp-server.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/libsystemd-network/fuzz-dhcp-server.c b/src/libsystemd-network/fuzz-dhcp-server.c
index 94a8faaa39..e90284f6f2 100644
--- a/src/libsystemd-network/fuzz-dhcp-server.c
+++ b/src/libsystemd-network/fuzz-dhcp-server.c
@@ -23,7 +23,6 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
static const uint8_t chaddr[] = {3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3};
uint8_t *client_id;
DHCPLease *lease;
- int pool_offset;
if (size < sizeof(DHCPMessage))
return 0;
@@ -46,9 +45,9 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
lease->gateway = htobe32(UINT32_C(10) << 24 | UINT32_C(1));
lease->expiration = UINT64_MAX;
memcpy(lease->chaddr, chaddr, 16);
- pool_offset = get_pool_offset(server, lease->address);
- server->bound_leases[pool_offset] = lease;
- assert_se(hashmap_ensure_put(&server->leases_by_client_id, &dhcp_lease_hash_ops, &lease->client_id, lease) >= 0);
+ assert_se(hashmap_ensure_put(&server->bound_leases_by_client_id, &dhcp_lease_hash_ops, &lease->client_id, lease) >= 0);
+ assert_se(hashmap_ensure_put(&server->bound_leases_by_address, NULL, UINT32_TO_PTR(lease->address), lease) >= 0);
+ lease->server = server;
(void) dhcp_server_handle_message(server, (DHCPMessage*)data, size);