systemd/0001-dhcp-server-add-two-missing-OOM-checks.patch
Michal Sekletar f5f0737829 Backport bugfixes from upstream
Most notably this commit fixes #1419501 that caused mock traceback when
running with --new-chroot.

Resolves: #1419501
2017-03-16 09:16:18 +01:00

39 lines
1.7 KiB
Diff

From 0c65886b122a26636ad049cf12b560865ffc62a6 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
index 2890681..315cbf1 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);
--
2.9.3