From 67e9520d0cd165b78a6213699ace850e8bd0f167 Mon Sep 17 00:00:00 2001 From: Brad House Date: Mon, 14 Oct 2024 06:08:07 -0400 Subject: [PATCH] fcntl doesn't take O_CLOEXEC, it takes FD_CLOEXEC As reported on Android 14, which recently added a fortify check for fcntl F_SETFD to make sure only FD_CLOEXEC is ever passed: https://github.com/aosp-mirror/platform_bionic/commit/dfe67d266c9c5dfaedc2036d9d58e459169c77f0 We can't pass anything else to it. Even though on glibc, O_CLOEXEC and FD_CLOEXEC are the same value, this isn't defined to be portable in any way. Fixes #900 Reported-By: Yuki San (@RealYukiSan) Authored-By: Brad House (@bradh352) --- src/lib/event/ares_event_wake_pipe.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/event/ares_event_wake_pipe.c b/src/lib/event/ares_event_wake_pipe.c index 282d013d..d3b166a3 100644 --- a/src/lib/event/ares_event_wake_pipe.c +++ b/src/lib/event/ares_event_wake_pipe.c @@ -92,9 +92,9 @@ static ares_pipeevent_t *ares_pipeevent_init(void) } # endif -# ifdef O_CLOEXEC - fcntl(p->filedes[0], F_SETFD, O_CLOEXEC); - fcntl(p->filedes[1], F_SETFD, O_CLOEXEC); +# ifdef FD_CLOEXEC + fcntl(p->filedes[0], F_SETFD, FD_CLOEXEC); + fcntl(p->filedes[1], F_SETFD, FD_CLOEXEC); # endif # endif