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:
dfe67d266c

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)
v1.34
Brad House 1 month ago
parent 6d44c3d156
commit 67e9520d0c
  1. 6
      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

Loading…
Cancel
Save