d743bb5
From a75dde1983510900243f247b41a8cb935590ac7b Mon Sep 17 00:00:00 2001
d743bb5
From: Lennart Poettering <lennart@poettering.net>
d743bb5
Date: Thu, 9 Feb 2017 10:16:52 +0100
d743bb5
Subject: [PATCH] dhcp-server: add two missing OOM checks
d743bb5
d743bb5
(cherry picked from commit 357e1b17b901b48714fa5301c745ae5389661798)
d743bb5
---
d743bb5
 src/libsystemd-network/sd-dhcp-server.c | 6 ++++++
d743bb5
 1 file changed, 6 insertions(+)
d743bb5
d743bb5
diff --git a/src/libsystemd-network/sd-dhcp-server.c b/src/libsystemd-network/sd-dhcp-server.c
d743bb5
index 2890681561..315cbf1ac5 100644
d743bb5
--- a/src/libsystemd-network/sd-dhcp-server.c
d743bb5
+++ b/src/libsystemd-network/sd-dhcp-server.c
d743bb5
@@ -197,7 +197,11 @@ int sd_dhcp_server_new(sd_dhcp_server **ret, int ifindex) {
d743bb5
         server->address = htobe32(INADDR_ANY);
d743bb5
         server->netmask = htobe32(INADDR_ANY);
d743bb5
         server->ifindex = ifindex;
d743bb5
+
d743bb5
         server->leases_by_client_id = hashmap_new(&client_id_hash_ops);
d743bb5
+        if (!server->leases_by_client_id)
d743bb5
+                return -ENOMEM;
d743bb5
+
d743bb5
         server->default_lease_time = DIV_ROUND_UP(DHCP_DEFAULT_LEASE_TIME_USEC, USEC_PER_SEC);
d743bb5
         server->max_lease_time = DIV_ROUND_UP(DHCP_MAX_LEASE_TIME_USEC, USEC_PER_SEC);
d743bb5
 
d743bb5
@@ -857,6 +861,8 @@ int dhcp_server_handle_message(sd_dhcp_server *server, DHCPMessage *message,
d743bb5
 
d743bb5
                         if (!existing_lease) {
d743bb5
                                 lease = new0(DHCPLease, 1);
d743bb5
+                                if (!lease)
d743bb5
+                                        return -ENOMEM;
d743bb5
                                 lease->address = address;
d743bb5
                                 lease->client_id.data = memdup(req->client_id.data,
d743bb5
                                                                req->client_id.length);