]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
fuzz-dhcp-server: also set new lease elements correctly
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 24 Jan 2022 10:26:25 +0000 (19:26 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 24 Jan 2022 10:28:21 +0000 (19:28 +0900)
The fuzzer does not send anything to the address, so it should be not
necessary, but just for safety.

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

index e90284f6f2e37c80bcf8e5b655a7c8fef95ad145..87add43270b59b995be310014877e5e624fc3c22 100644 (file)
@@ -44,7 +44,9 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
         lease->address = htobe32(UINT32_C(10) << 24 | UINT32_C(2));
         lease->gateway = htobe32(UINT32_C(10) << 24 | UINT32_C(1));
         lease->expiration = UINT64_MAX;
-        memcpy(lease->chaddr, chaddr, 16);
+        lease->htype = ARPHRD_ETHER;
+        lease->hlen = ETH_ALEN;
+        memcpy(lease->chaddr, chaddr, ETH_ALEN);
         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;