summaryrefslogtreecommitdiffstats
path: root/src/libsystemd-network/fuzz-dhcp-server.c
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2022-01-24 11:26:25 +0100
committerYu Watanabe <watanabe.yu+github@gmail.com>2022-01-24 11:28:21 +0100
commitc3da2e4732a89bceecde57e15a86948a34ed8b79 (patch)
treed38d94fcbee2a859507a011e9f4ab685f1a89e4e /src/libsystemd-network/fuzz-dhcp-server.c
parentbuild(deps): bump github/codeql-action from 1.0.27 to 1.0.29 (diff)
downloadsystemd-c3da2e4732a89bceecde57e15a86948a34ed8b79.tar.xz
systemd-c3da2e4732a89bceecde57e15a86948a34ed8b79.zip
fuzz-dhcp-server: also set new lease elements correctly
The fuzzer does not send anything to the address, so it should be not necessary, but just for safety.
Diffstat (limited to 'src/libsystemd-network/fuzz-dhcp-server.c')
-rw-r--r--src/libsystemd-network/fuzz-dhcp-server.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/libsystemd-network/fuzz-dhcp-server.c b/src/libsystemd-network/fuzz-dhcp-server.c
index e90284f6f2..87add43270 100644
--- a/src/libsystemd-network/fuzz-dhcp-server.c
+++ b/src/libsystemd-network/fuzz-dhcp-server.c
@@ -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;