From 1bdaee475b32266e20a58f2f12dffff18853f259 Mon Sep 17 00:00:00 2001 From: Tim Schumacher Date: Mon, 11 Apr 2022 00:01:58 +0200 Subject: [PATCH] DHCPClient: Close outgoing sockets after use --- Userland/Services/DHCPClient/DHCPv4Client.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Userland/Services/DHCPClient/DHCPv4Client.cpp b/Userland/Services/DHCPClient/DHCPv4Client.cpp index 35b8ea2028..5b366db8dc 100644 --- a/Userland/Services/DHCPClient/DHCPv4Client.cpp +++ b/Userland/Services/DHCPClient/DHCPv4Client.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -40,6 +41,8 @@ static bool send(InterfaceDescriptor const& iface, DHCPv4Packet const& packet, C return false; } + ScopeGuard socket_close_guard = [&] { close(fd); }; + if (setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, iface.ifname.characters(), IFNAMSIZ) < 0) { dbgln("ERROR: setsockopt(SO_BINDTODEVICE) :: {}", strerror(errno)); return false;