diff options
author | Lennart Poettering <lennart@poettering.net> | 2017-02-09 10:16:52 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2017-02-09 16:12:03 +0100 |
commit | 357e1b17b901b48714fa5301c745ae5389661798 (patch) | |
tree | 095575f6dba60919a8ea3e43fb385eec882ff6cd /src | |
parent | 1d450bda706abedb6724cc2c0f834ebc1686309f (diff) |
dhcp-server: add two missing OOM checks
Diffstat (limited to 'src')
-rw-r--r-- | src/libsystemd-network/sd-dhcp-server.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/libsystemd-network/sd-dhcp-server.c b/src/libsystemd-network/sd-dhcp-server.c index 2890681561..315cbf1ac5 100644 --- a/src/libsystemd-network/sd-dhcp-server.c +++ b/src/libsystemd-network/sd-dhcp-server.c @@ -197,7 +197,11 @@ int sd_dhcp_server_new(sd_dhcp_server **ret, int ifindex) { server->address = htobe32(INADDR_ANY); server->netmask = htobe32(INADDR_ANY); server->ifindex = ifindex; + server->leases_by_client_id = hashmap_new(&client_id_hash_ops); + if (!server->leases_by_client_id) + return -ENOMEM; + server->default_lease_time = DIV_ROUND_UP(DHCP_DEFAULT_LEASE_TIME_USEC, USEC_PER_SEC); server->max_lease_time = DIV_ROUND_UP(DHCP_MAX_LEASE_TIME_USEC, USEC_PER_SEC); @@ -857,6 +861,8 @@ int dhcp_server_handle_message(sd_dhcp_server *server, DHCPMessage *message, if (!existing_lease) { lease = new0(DHCPLease, 1); + if (!lease) + return -ENOMEM; lease->address = address; lease->client_id.data = memdup(req->client_id.data, req->client_id.length); |