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.27
Brad House 1 month ago
parent c01fec1062
commit 49e438ee2c
  1. 6
      src/lib/ares_event_wake_pipe.c

@ -94,9 +94,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