From 2d10a2ccb2f0f6ab1e04729aeb431ce50c337155 Mon Sep 17 00:00:00 2001
From: Upgrade Helper <auh@yoctoproject.org>
Date: Thu, 6 Aug 2026 05:28:57 +0000
Subject: [PATCH] dhcpcd: upgrade 10.3.2 -> 10.5.0

1d608519 pkgsrc gpg2 now installs as gpg
6f3dcb38 Fix a compile error for SMALL builds
78b9286f DHCP: deconfigure even when state is NULL or NONE
e3363cf4 control: remove unprivileged socket
8b312918 Build all the targets on macos
a7935e28 options: Introduce policy groups
59b32c80 privsep: Fix compile without INET
1f593762 dhcp: add configurable backoff parameters for DHCPv4 (#593)
b6588aa6 IPv4: uset old_ia when adding an address causes early removal
5733d3c5 DHCPv6: When deprecating addresses, restart on prefix deletions
2f00c7bf DHCPv6: Prefix exclude option can be 17 octets (#671)
708b4a56 IPv6ND: Free routeinfo when it expires (#670)
78ea09ed control: Avoid hangup in the recvdata path
7240d832 script: Fix buffer over and under flows in script_buftoenv
7891a22d capsicum: Avoid some overflow issues in privsep sysctl
a52bc9f6 IPv6: Fix numerous issues extending temporary address times
d28c9717 DHCP6: Fix configuring the suffix to delegated prefixes (#665)
2752331f vsio: Allow zero length options
b746a5bd eloop: Fix compile warning where UTIME_MAX is a calculation
12d2e981 workflows: limit to read only
22f39097 eloop: Improve timespecdiff
e1387b5c configure: Don't define _BSD_SOURCE for explicit_zero()
77a6d6fe ipv6: Only regen temp addrs with sufficent pltime
93e1a81f hooks: don't read past truncated ip6 address starting fe
764bb43a auth: Ensure remaining dlen matches hash digest length
cc05008e auth: clear keys with memset_explicit
99804fbe privsep: Check data is terminated when a string
1199f7fa ARP: Iterate over states safely as the cb could remove ours
e636ba2b DHCP: Sanitise messages from servers for output
26e4325d Fix CI build
69f10757 udev: Ensure we have a subsystem, action and ifname
7cc5caaa hooks: Quote assignment of compat vars correctly
4f426005 ARP: check we have enough to read the frame header
805fe4ac ND: Enforce require and reject policy
a92f79b0 DHCP6: Ensure IA_PD Prefix Length is valid
06f84e4a ND6: fix OOB reject mask for an undefined option
6e51c1e2 options: Fix userclass boundary
7efb4fe0 linux: Ensure NLA data boundaries are valid
393c3509 privsep: ps_root_readfile should return the real file size
e7d1013d timezone: disallow directory traversal
56fdb163 privsep: Simplify readerror
cfac52dc privsep: Remove PS_BUFLEN
ddc57fe8 script: Use correct buffer length variable (#641)
2d2d28e7 sun: Enable building for privsep
c64f7076 privsep: Don't open PF_INET socket for each ioctl
82bbc038 BPF: fix libpcap compile
74d818b5 DHCP6: guard against an interface delegated too disappearing
cd0864bf options: Remove some const to fix compile warnings
ecdac6bc privsep: guard setproctitle and only use compat on linux
da9a2457 privsep: avoid a compile warning on systems without setproctitle
4fc8cb8b DHCP: Don't add a trailing : on vendor if no machine arch
025e128e DHCP: Don't really expire the lease when testing
f64a7ad7 privsep: Add ps_root_gethostname
7143fc37 privsep: Always seed arc4random
5417ec90 if: if_init inits the interface from

[Changelog truncated as it exceeds 3000 characters;
the full changelog can be found in an attachment to the AUH email]
---
 .../{dhcpcd_10.3.2.bb => dhcpcd_10.5.0.bb}    |   6 +-
 ...mprove-the-sitation-of-working-with-.patch |  14 +-
 ...-conflict-error-when-enable-multilib.patch |   6 +-
 ...e-INCLUDEDIR-to-prevent-build-issues.patch |  10 +-
 .../dhcpcd/files/CVE-2026-56113.patch         |  92 ----------
 .../dhcpcd/files/CVE-2026-56114.patch         |  34 ----
 .../dhcpcd/files/CVE-2026-56116.patch         |  31 ----
 .../dhcpcd/files/CVE-2026-56117.patch         | 167 ------------------
 8 files changed, 16 insertions(+), 344 deletions(-)
 rename meta/recipes-connectivity/dhcpcd/{dhcpcd_10.3.2.bb => dhcpcd_10.5.0.bb} (91%)
 delete mode 100644 meta/recipes-connectivity/dhcpcd/files/CVE-2026-56113.patch
 delete mode 100644 meta/recipes-connectivity/dhcpcd/files/CVE-2026-56114.patch
 delete mode 100644 meta/recipes-connectivity/dhcpcd/files/CVE-2026-56116.patch
 delete mode 100644 meta/recipes-connectivity/dhcpcd/files/CVE-2026-56117.patch

diff --git a/meta/recipes-connectivity/dhcpcd/dhcpcd_10.3.2.bb b/meta/recipes-connectivity/dhcpcd/dhcpcd_10.5.0.bb
similarity index 91%
rename from meta/recipes-connectivity/dhcpcd/dhcpcd_10.3.2.bb
rename to meta/recipes-connectivity/dhcpcd/dhcpcd_10.5.0.bb
index cc12b4a005..73f55969cd 100644
--- a/meta/recipes-connectivity/dhcpcd/dhcpcd_10.3.2.bb
+++ b/meta/recipes-connectivity/dhcpcd/dhcpcd_10.5.0.bb
@@ -15,13 +15,9 @@ SRC_URI = "git://github.com/NetworkConfiguration/dhcpcd;protocol=https;branch=ma
            file://dhcpcd.service \
            file://dhcpcd@.service \
            file://0001-dhcpcd.8-Fix-conflict-error-when-enable-multilib.patch \
-           file://CVE-2026-56113.patch \
-           file://CVE-2026-56114.patch \
-           file://CVE-2026-56116.patch \
-           file://CVE-2026-56117.patch \
            "
 
-SRCREV = "243ad84ac67a87d631ff7eb83b2eed2727acebb5"
+SRCREV = "1d608519abb398006b77f11c7b720147adf4cfcc"
 
 # Doesn't use automake so we can't do out-of-tree builds
 inherit pkgconfig autotools-brokensep systemd useradd
diff --git a/meta/recipes-connectivity/dhcpcd/files/0001-20-resolv.conf-improve-the-sitation-of-working-with-.patch b/meta/recipes-connectivity/dhcpcd/files/0001-20-resolv.conf-improve-the-sitation-of-working-with-.patch
index 7e04b5c303..04c1d92897 100644
--- a/meta/recipes-connectivity/dhcpcd/files/0001-20-resolv.conf-improve-the-sitation-of-working-with-.patch
+++ b/meta/recipes-connectivity/dhcpcd/files/0001-20-resolv.conf-improve-the-sitation-of-working-with-.patch
@@ -1,4 +1,4 @@
-From c91f9cdc0ef56fa64f6ffdd811cc5b0e41991b2e Mon Sep 17 00:00:00 2001
+From a3e397d3764fdb779e2f995b690ba365956612f5 Mon Sep 17 00:00:00 2001
 From: Chen Qi <Qi.Chen@windriver.com>
 Date: Wed, 9 Nov 2022 16:33:18 +0800
 Subject: [PATCH] 20-resolv.conf: improve the sitation of working with systemd
@@ -27,10 +27,10 @@ Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
  1 file changed, 13 insertions(+), 4 deletions(-)
 
 diff --git a/hooks/20-resolv.conf b/hooks/20-resolv.conf
-index bd0b0df5..9c7721de 100644
+index 6aae9cc1..0fbcc9e8 100644
 --- a/hooks/20-resolv.conf
 +++ b/hooks/20-resolv.conf
-@@ -11,8 +11,12 @@ nocarrier_roaming_dir="$state_dir/roaming"
+@@ -14,8 +14,12 @@ nocarrier_roaming_dir="$state_dir/roaming"
  NL="
  "
  : ${resolvconf:=resolvconf}
@@ -43,9 +43,9 @@ index bd0b0df5..9c7721de 100644
  else
  	have_resolvconf=false
  fi
-@@ -69,8 +73,13 @@ build_resolv_conf()
+@@ -72,8 +76,13 @@ build_resolv_conf()
  	else
- 		echo "# /etc/resolv.conf.tail can replace this line" >> "$cf"
+ 		printf '%s\n' "# /etc/resolv.conf.tail can replace this line" >> "$cf"
  	fi
 -	if change_file /etc/resolv.conf "$cf"; then
 -		chmod 644 /etc/resolv.conf
@@ -59,7 +59,7 @@ index bd0b0df5..9c7721de 100644
  	fi
  	rm -f "$cf"
  }
-@@ -179,7 +188,7 @@ add_resolv_conf()
+@@ -182,7 +191,7 @@ add_resolv_conf()
  	for x in ${new_domain_name_servers}; do
  		conf="${conf}nameserver $x$NL"
  	done
@@ -68,7 +68,7 @@ index bd0b0df5..9c7721de 100644
  		[ -n "$ifmetric" ] && export IF_METRIC="$ifmetric"
  		printf %s "$conf" | "$resolvconf" -a "$ifname"
  		return $?
-@@ -195,7 +204,7 @@ add_resolv_conf()
+@@ -198,7 +207,7 @@ add_resolv_conf()
  
  remove_resolv_conf()
  {
diff --git a/meta/recipes-connectivity/dhcpcd/files/0001-dhcpcd.8-Fix-conflict-error-when-enable-multilib.patch b/meta/recipes-connectivity/dhcpcd/files/0001-dhcpcd.8-Fix-conflict-error-when-enable-multilib.patch
index 9d3065a48b..c2afb83b54 100644
--- a/meta/recipes-connectivity/dhcpcd/files/0001-dhcpcd.8-Fix-conflict-error-when-enable-multilib.patch
+++ b/meta/recipes-connectivity/dhcpcd/files/0001-dhcpcd.8-Fix-conflict-error-when-enable-multilib.patch
@@ -1,4 +1,4 @@
-From dd892eba0147120efdcae923746c444a9d2a76d2 Mon Sep 17 00:00:00 2001
+From d3e517be04e660d72233cde91b44c3cf705126e2 Mon Sep 17 00:00:00 2001
 From: Lei Maohui <leimaohui@fujitsu.com>
 Date: Fri, 10 Mar 2023 03:48:46 +0000
 Subject: [PATCH] dhcpcd.8: Fix conflict error when enable multilib.
@@ -29,10 +29,10 @@ Signed-off-by: Lei Maohui <leimaohui@fujitsu.com>
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/src/dhcpcd.8.in b/src/dhcpcd.8.in
-index ebbf06c0..c7ffee6b 100644
+index 26d37772..1b13dc4e 100644
 --- a/src/dhcpcd.8.in
 +++ b/src/dhcpcd.8.in
-@@ -826,7 +826,7 @@ Configuration file for dhcpcd.
+@@ -825,7 +825,7 @@ Configuration file for dhcpcd.
  If you always use the same options, put them here.
  .It Pa @SCRIPT@
  Bourne shell script that is run to configure or de-configure an interface.
diff --git a/meta/recipes-connectivity/dhcpcd/files/0001-remove-INCLUDEDIR-to-prevent-build-issues.patch b/meta/recipes-connectivity/dhcpcd/files/0001-remove-INCLUDEDIR-to-prevent-build-issues.patch
index bebc79831d..69ebc6026f 100644
--- a/meta/recipes-connectivity/dhcpcd/files/0001-remove-INCLUDEDIR-to-prevent-build-issues.patch
+++ b/meta/recipes-connectivity/dhcpcd/files/0001-remove-INCLUDEDIR-to-prevent-build-issues.patch
@@ -1,4 +1,4 @@
-From 0775eb1b965bbf9b0efb0b1c42c3adf3d8cd31cb Mon Sep 17 00:00:00 2001
+From 278ef78e007ab74c701961e108262d9d733a3975 Mon Sep 17 00:00:00 2001
 From: Stefano Cappa <stefano.cappa.ks89@gmail.com>
 Date: Sun, 13 Jan 2019 01:50:52 +0100
 Subject: [PATCH] remove INCLUDEDIR to prevent build issues
@@ -11,10 +11,10 @@ Signed-off-by: Stefano Cappa <stefano.cappa.ks89@gmail.com>
  1 file changed, 5 deletions(-)
 
 diff --git a/configure b/configure
-index e9c08f18..3f0770b7 100755
+index 32bf96ef..ab4aa901 100755
 --- a/configure
 +++ b/configure
-@@ -26,7 +26,6 @@ BUILD=
+@@ -29,7 +29,6 @@ BUILD=
  HOST=
  HOSTCC=
  TARGET=
@@ -22,7 +22,7 @@ index e9c08f18..3f0770b7 100755
  DEBUG=
  FORK=
  STATIC=
-@@ -89,7 +88,6 @@ for x do
+@@ -93,7 +92,6 @@ for x do
  	--mandir) MANDIR=$var;;
  	--datadir) DATADIR=$var;;
  	--with-ccopts|CFLAGS) CFLAGS=$var;;
@@ -30,7 +30,7 @@ index e9c08f18..3f0770b7 100755
  	CC) CC=$var;;
  	CPPFLAGS) CPPFLAGS=$var;;
  	PKG_CONFIG) PKG_CONFIG=$var;;
-@@ -346,9 +344,6 @@ if [ -n "$CPPFLAGS" ]; then
+@@ -356,9 +354,6 @@ if [ -n "$CPPFLAGS" ]; then
  	echo "CPPFLAGS=" >>$CONFIG_MK
  	echo "CPPFLAGS+=	$CPPFLAGS" >>$CONFIG_MK
  fi
diff --git a/meta/recipes-connectivity/dhcpcd/files/CVE-2026-56113.patch b/meta/recipes-connectivity/dhcpcd/files/CVE-2026-56113.patch
deleted file mode 100644
index 14095685ed..0000000000
--- a/meta/recipes-connectivity/dhcpcd/files/CVE-2026-56113.patch
+++ /dev/null
@@ -1,92 +0,0 @@
-From f0e7f32646004a472f8322bcee4a38416f88a130 Mon Sep 17 00:00:00 2001
-From: Roy Marples <roy@marples.name>
-Date: Tue, 23 Jun 2026 02:17:10 +0100
-Subject: [PATCH] DHCPv6: When deprecating addresses, restart on prefix
- deletions
-
-As that might invalidate the next address to iterate on.
-
-Reported-by: CuB3y0nd <root@cubeyond.net>
-
-(cherry picked from commit 5733d3c59a5651f64357ac11c98b4f39895c8d25)
-
-CVE: CVE-2026-56113
-Upstream-Status: Backport [https://github.com/NetworkConfiguration/dhcpcd/commit/5733d3c59a5651f64357ac11c98b4f39895c8d25]
-Signed-off-by: Theo Gaige (Schneider Electric) <tgaige.opensource@witekio.com>
----
- src/dhcp6.c | 21 ++++++++++++++++++---
- 1 file changed, 18 insertions(+), 3 deletions(-)
-
-diff --git a/src/dhcp6.c b/src/dhcp6.c
-index 91341994..8a8a20a0 100644
---- a/src/dhcp6.c
-+++ b/src/dhcp6.c
-@@ -2593,12 +2593,13 @@ dhcp6_findia(struct interface *ifp, struct dhcp6_message *m, size_t l,
- }
- 
- #ifndef SMALL
--static void
-+static bool
- dhcp6_deprecatedele(struct ipv6_addr *ia)
- {
- 	struct ipv6_addr *da, *dan, *dda;
- 	struct timespec now;
- 	struct dhcp6_state *state;
-+	bool freed = false;
- 
- 	timespecclear(&now);
- 	TAILQ_FOREACH_SAFE(da, &ia->pd_pfxs, pd_next, dan) {
-@@ -2624,11 +2625,14 @@ dhcp6_deprecatedele(struct ipv6_addr *ia)
- 			if (IN6_ARE_ADDR_EQUAL(&dda->addr, &da->addr))
- 				break;
- 		}
--		if (dda != NULL) {
-+		if (dda != ia && dda != NULL) {
- 			TAILQ_REMOVE(&state->addrs, dda, next);
- 			ipv6_freeaddr(dda);
-+			freed = true;
- 		}
- 	}
-+
-+	return freed;
- }
- #endif
- 
-@@ -2636,7 +2640,11 @@ static void
- dhcp6_deprecateaddrs(struct ipv6_addrhead *addrs)
- {
- 	struct ipv6_addr *ia, *ian;
-+#ifndef SMALL
-+	bool again;
-+#endif
- 
-+again:
- 	TAILQ_FOREACH_SAFE(ia, addrs, next, ian) {
- 		if (ia->flags & IPV6_AF_EXTENDED)
- 			;
-@@ -2658,7 +2666,9 @@ dhcp6_deprecateaddrs(struct ipv6_addrhead *addrs)
- 		/* If we delegated from this prefix, deprecate or remove
- 		 * the delegations. */
- 		if (ia->flags & IPV6_AF_PFXDELEGATION)
--			dhcp6_deprecatedele(ia);
-+			again = dhcp6_deprecatedele(ia);
-+		else
-+			again = false;
- #endif
- 
- 		if (ia->flags & IPV6_AF_REQUEST) {
-@@ -2671,6 +2681,11 @@ dhcp6_deprecateaddrs(struct ipv6_addrhead *addrs)
- 		if (!(ia->flags & IPV6_AF_EXTENDED))
- 			ipv6_deleteaddr(ia);
- 		ipv6_freeaddr(ia);
-+#ifndef SMALL
-+		/* Deletion may invalidate the next pointer so restart */
-+		if (again)
-+			goto again;
-+#endif
- 	}
- }
- 
--- 
-2.43.0
-
diff --git a/meta/recipes-connectivity/dhcpcd/files/CVE-2026-56114.patch b/meta/recipes-connectivity/dhcpcd/files/CVE-2026-56114.patch
deleted file mode 100644
index a6b8a44515..0000000000
--- a/meta/recipes-connectivity/dhcpcd/files/CVE-2026-56114.patch
+++ /dev/null
@@ -1,34 +0,0 @@
-From 2e27969699676e664898c8f82e2c047762fc426f Mon Sep 17 00:00:00 2001
-From: Roy Marples <roy@marples.name>
-Date: Tue, 23 Jun 2026 02:06:55 +0100
-Subject: [PATCH] DHCPv6: Prefix exclude option can be 17 octets (#671)
-
-Well that's a simple off by one error
-
-Reported-by: CuB3y0nd <root@cubeyond.net>
-
-(cherry picked from commit 2f00c7bfc408b6582d331932dfa47829c4819029)
-
-CVE: CVE-2026-56114
-Upstream-Status: Backport [https://github.com/NetworkConfiguration/dhcpcd/commit/2f00c7bfc408b6582d331932dfa47829c4819029]
-Signed-off-by: Theo Gaige (Schneider Electric) <tgaige.opensource@witekio.com>
----
- src/dhcp6.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
-
-diff --git a/src/dhcp6.c b/src/dhcp6.c
-index 8a8a20a0..5e497cfd 100644
---- a/src/dhcp6.c
-+++ b/src/dhcp6.c
-@@ -1093,7 +1093,7 @@ dhcp6_makemessage(struct interface *ifp)
- 
- 				/* RFC6603 Section 4.2 */
- 				if (ap->prefix_exclude_len) {
--					uint8_t exb[16], *ep, u8;
-+					uint8_t exb[17], *ep, u8;
- 					const uint8_t *pp;
- 
- 					n = (size_t)((ap->prefix_exclude_len -
--- 
-2.43.0
-
diff --git a/meta/recipes-connectivity/dhcpcd/files/CVE-2026-56116.patch b/meta/recipes-connectivity/dhcpcd/files/CVE-2026-56116.patch
deleted file mode 100644
index 2d8345cf18..0000000000
--- a/meta/recipes-connectivity/dhcpcd/files/CVE-2026-56116.patch
+++ /dev/null
@@ -1,31 +0,0 @@
-From ae33c2d8fc7319a2957acd6e8efad99116b68dc6 Mon Sep 17 00:00:00 2001
-From: Roy Marples <roy@marples.name>
-Date: Tue, 23 Jun 2026 00:34:58 +0100
-Subject: [PATCH] IPv6ND: Free routeinfo when it expires (#670)
-
-Reported-by: CuB3y0nd <root@cubeyond.net>
-
-(cherry picked from commit 708b4a56bae080a5b18c2e0c4c6fbe103131a2b0)
-
-CVE: CVE-2026-56116
-Upstream-Status: Backport [https://github.com/NetworkConfiguration/dhcpcd/commit/708b4a56bae080a5b18c2e0c4c6fbe103131a2b0]
-Signed-off-by: Theo Gaige (Schneider Electric) <tgaige.opensource@witekio.com>
----
- src/ipv6nd.c | 1 +
- 1 file changed, 1 insertion(+)
-
-diff --git a/src/ipv6nd.c b/src/ipv6nd.c
-index ccf71241..557ff50e 100644
---- a/src/ipv6nd.c
-+++ b/src/ipv6nd.c
-@@ -1789,6 +1789,7 @@ ipv6nd_expirera(void *arg)
- 				logwarnx("%s: expired route %s",
- 				    rap->iface->name, rinfo->sprefix);
- 				TAILQ_REMOVE(&rap->rinfos, rinfo, next);
-+				free(rinfo);
- 			}
- 		}
- 
--- 
-2.43.0
-
diff --git a/meta/recipes-connectivity/dhcpcd/files/CVE-2026-56117.patch b/meta/recipes-connectivity/dhcpcd/files/CVE-2026-56117.patch
deleted file mode 100644
index 6ef86204f2..0000000000
--- a/meta/recipes-connectivity/dhcpcd/files/CVE-2026-56117.patch
+++ /dev/null
@@ -1,167 +0,0 @@
-From b7bf047e30217e144235a6b00d4c81afbcc5d6ab Mon Sep 17 00:00:00 2001
-From: Roy Marples <roy@marples.name>
-Date: Mon, 22 Jun 2026 23:41:53 +0100
-Subject: [PATCH] control: Avoid hangup in the recvdata path
-
-Instead return an error and bubble it up where it can be
-hangup / freed more cleanly.
-
-Reported-by: CuB3y0nd <root@cubeyond.net>
-
-(cherry picked from commit 78ea09ed1633a583dbcde6e7bab9df4639ec8a34)
-
-CVE: CVE-2026-56117
-Upstream-Status: Backport [https://github.com/NetworkConfiguration/dhcpcd/commit/78ea09ed1633a583dbcde6e7bab9df4639ec8a34]
-Signed-off-by: Theo Gaige (Schneider Electric) <tgaige.opensource@witekio.com>
----
- src/control.c         | 47 ++++++++++++++++++++++++-------------------
- src/control.h         |  2 +-
- src/privsep-control.c |  7 ++++++-
- 3 files changed, 33 insertions(+), 23 deletions(-)
-
-diff --git a/src/control.c b/src/control.c
-index ec1c633c..e6115f66 100644
---- a/src/control.c
-+++ b/src/control.c
-@@ -115,10 +115,8 @@ control_handle_read(struct fd_list *fd)
- 	bytes = read(fd->fd, buffer, sizeof(buffer) - 1);
- 	if (bytes == -1)
- 		logerr(__func__);
--	if (bytes == -1 || bytes == 0) {
--		control_hangup(fd);
--		return -1;
--	}
-+	if (bytes == -1 || bytes == 0)
-+		return (int)bytes;
- 
- #ifdef PRIVSEP
- 	if (IN_PRIVSEP(fd->ctx)) {
-@@ -134,15 +132,13 @@ control_handle_read(struct fd_list *fd)
- 		if (err == 1 &&
- 		    ps_ctl_sendargs(fd, buffer, (size_t)bytes) == -1) {
- 			logerr(__func__);
--			control_free(fd);
- 			return -1;
- 		}
--		return 0;
-+		return 1;
- 	}
- #endif
- 
--	control_recvdata(fd, buffer, (size_t)bytes);
--	return 0;
-+	return control_recvdata(fd, buffer, (size_t)bytes);
- }
- 
- static int
-@@ -205,23 +201,31 @@ static void
- control_handle_data(void *arg, unsigned short events)
- {
- 	struct fd_list *fd = arg;
-+	int err;
- 
- 	if (!(events & (ELE_READ | ELE_WRITE | ELE_HANGUP)))
- 		logerrx("%s: unexpected event 0x%04x", __func__, events);
- 
- 	if (events & ELE_WRITE && !(events & ELE_HANGUP)) {
--		if (control_handle_write(fd) == -1)
--			return;
-+		err = control_handle_write(fd);
-+		if (err == -1)
-+			goto hangup;
- 	}
- 	if (events & ELE_READ) {
--		if (control_handle_read(fd) == -1)
--			return;
-+		err = control_handle_read(fd);
-+		if (err == -1 || err == 0)
-+			goto hangup;
- 	}
- 	if (events & ELE_HANGUP)
--		control_hangup(fd);
-+		goto hangup;
-+
-+	return;
-+
-+hangup:
-+	control_hangup(fd);
- }
- 
--void
-+int
- control_recvdata(struct fd_list *fd, char *data, size_t len)
- {
- 	char *p = data, *e;
-@@ -243,12 +247,13 @@ control_recvdata(struct fd_list *fd, char *data, size_t len)
- 			if (e == NULL) {
- 				errno = EINVAL;
- 				logerrx("%s: no terminator", __func__);
--				return;
-+				return -1;
- 			}
--			if ((size_t)argc >= sizeof(argvp) / sizeof(argvp[0])) {
-+			if ((size_t)argc + 1 >=
-+			    sizeof(argvp) / sizeof(argvp[0])) {
- 				errno = ENOBUFS;
- 				logerrx("%s: no arg buffer", __func__);
--				return;
-+				return -1;
- 			}
- 			*ap++ = p;
- 			argc++;
-@@ -268,12 +273,12 @@ control_recvdata(struct fd_list *fd, char *data, size_t len)
- 		*ap = NULL;
- 		if (dhcpcd_handleargs(fd->ctx, fd, argc, argvp) == -1) {
- 			logerr(__func__);
--			if (errno != EINTR && errno != EAGAIN) {
--				control_free(fd);
--				return;
--			}
-+			if (errno != EINTR && errno != EAGAIN)
-+				return -1;
- 		}
- 	}
-+
-+	return 1;
- }
- 
- struct fd_list *
-diff --git a/src/control.h b/src/control.h
-index ef592268..1f09fc8f 100644
---- a/src/control.h
-+++ b/src/control.h
-@@ -76,5 +76,5 @@ struct fd_list *control_new(struct dhcpcd_ctx *, int, unsigned int);
- void control_free(struct fd_list *);
- void control_delete(struct fd_list *);
- int control_queue(struct fd_list *, void *, size_t);
--void control_recvdata(struct fd_list *fd, char *, size_t);
-+int control_recvdata(struct fd_list *fd, char *, size_t);
- #endif
-diff --git a/src/privsep-control.c b/src/privsep-control.c
-index b9ea7f9c..3cdeedea 100644
---- a/src/privsep-control.c
-+++ b/src/privsep-control.c
-@@ -110,6 +110,7 @@ ps_ctl_dispatch(void *arg, struct ps_msghdr *psm, struct msghdr *msg)
- 	struct iovec *iov = msg->msg_iov;
- 	struct fd_list *fd;
- 	unsigned int fd_flags = FD_SENDLEN;
-+	int err;
- 
- 	switch (psm->ps_flags) {
- 	case PS_CTL_PRIV:
-@@ -133,7 +134,11 @@ ps_ctl_dispatch(void *arg, struct ps_msghdr *psm, struct msghdr *msg)
- 		if (fd == NULL)
- 			return -1;
- 		ctx->ps_control_client = fd;
--		control_recvdata(fd, iov->iov_base, iov->iov_len);
-+		err = control_recvdata(fd, iov->iov_base, iov->iov_len);
-+		if (err == -1 || err == 0) {
-+			control_free(fd);
-+			ctx->ps_control_client = NULL;
-+		}
- 		break;
- 	case PS_CTL_EOF:
- 		ctx->ps_control_client = NULL;
--- 
-2.43.0
-
-- 
2.47.1

