From 25806878c9975dd769e2e193eae22f470ef4c71a Mon Sep 17 00:00:00 2001 From: Brett Holman Date: Fri, 19 Jan 2024 18:43:26 -0700 Subject: [PATCH] Force dumplease to parse stdin Checking if data exists in the stdin buffer via an ioctl is unreliable. Allow a user to pass '-' to force stdin parsing. This provides a fix that will allow "no interfaces" to still mean "dump all interfaces". Fixes #285 --- src/dhcpcd.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/dhcpcd.c b/src/dhcpcd.c index a94dbdac..84b4d8f1 100644 --- a/src/dhcpcd.c +++ b/src/dhcpcd.c @@ -29,7 +29,6 @@ static const char dhcpcd_copyright[] = "Copyright (c) 2006-2023 Roy Marples"; #include -#include #include #include #include @@ -2278,8 +2277,10 @@ printpidfile: #ifndef SMALL if (ctx.options & DHCPCD_DUMPLEASE && - ioctl(fileno(stdin), FIONREAD, &i, sizeof(i)) == 0 && - i > 0) + i > 0 && + ctx.ifc == 1 && + strlen(ctx.ifv[0]) == 1 && + ctx.ifv[0][0] == '-') { ctx.options |= DHCPCD_FORKED; /* pretend child process */ #ifdef PRIVSEP -- 2.47.2