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