From 27155a507ff3507e7fc179bf26231bea84a7ca28 Mon Sep 17 00:00:00 2001 From: Martin Stein Date: Wed, 13 Jun 2018 15:35:28 +0200 Subject: [PATCH] nic_router: fix DHCP-server deinitialization Due to a bug in the deinitialization of the DHCP server of a domain (the reference to the destroyed object was not cleared), the NIC router could end up in a page fault caused by a double-free at the heap. This also fixes the previously missing dissolving of the "DNS-server-from" relation to a remote domain. Issue #2840 --- repos/os/src/server/nic_router/domain.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/repos/os/src/server/nic_router/domain.cc b/repos/os/src/server/nic_router/domain.cc index 2a6ba96a1c..eac8df9dd2 100644 --- a/repos/os/src/server/nic_router/domain.cc +++ b/repos/os/src/server/nic_router/domain.cc @@ -295,7 +295,13 @@ void Domain::deinit() _tcp_rules.destroy_each(_alloc); _udp_forward_rules.destroy_each(_alloc); _tcp_forward_rules.destroy_each(_alloc); - try { destroy(_alloc, &_dhcp_server()); } + try { + Dhcp_server &dhcp_server = _dhcp_server(); + _dhcp_server = Pointer(); + try { dhcp_server.dns_server_from().ip_config_dependents().remove(this); } + catch (Pointer::Invalid) { } + destroy(_alloc, &dhcp_server); + } catch (Pointer::Invalid) { } }