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