You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Android Bionic: replace getdtablesize() with #ifdef guard in php_fopen_wrapper.c #11
Android Bionic has <unistd.h> (so HAVE_UNISTD_H is defined), but does not expose getdtablesize() — it's a glibc/macOS extension, not in POSIX and not in Bionic.
This causes a compile error when cross-compiling PHP for Android:
ext/standard/php_fopen_wrapper.c:319:16: error: call to undeclared function 'getdtablesize';
ISO C99 and later do not support implicit function declarations
Current workaround
The true-async/releases Android build script applies a sed patch after git clone:
sed -i 's/dtablesize = getdtablesize();/dtablesize = (int)sysconf(_SC_OPEN_MAX);/' \
ext/standard/php_fopen_wrapper.c
Proper fix
Replace the single call site with an #ifdef guard:
configure already checks for getdtablesize in some form, or a dedicated AC_CHECK_FUNC(getdtablesize) can be added to ext/standard/config.m4 to set HAVE_GETDTABLESIZE.
sysconf(_SC_OPEN_MAX) is the standard POSIX replacement and works on Android Bionic, Linux, macOS, and all other targets.
Context
File: ext/standard/php_fopen_wrapper.c (the php://fd/<N> stream handler)
Affects: Android cross-compilation (NDK r27, API 29+)
Activity
Fix NULL deref when enabling TLS fails and the peer name needs to be …