systemd/0001-dhcp-server-add-two-missing-OOM-checks.patch

36 lines
1.7 KiB
Diff
Raw Normal View History

2017-06-15 14:26:56 +00:00
From a75dde1983510900243f247b41a8cb935590ac7b Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Thu, 9 Feb 2017 10:16:52 +0100
Subject: [PATCH] dhcp-server: add two missing OOM checks
(cherry picked from commit 357e1b17b901b48714fa5301c745ae5389661798)
---
src/libsystemd-network/sd-dhcp-server.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/libsystemd-network/sd-dhcp-server.c b/src/libsystemd-network/sd-dhcp-server.c
2017-06-15 14:26:56 +00:00
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);