Skip to content

Commit e553c0d

Browse files
committed
ext/gettext/{config.m4,gettext.c}: don't assume secure_getenv exists
This is killing the Windows and macOS builds. We now check for secure_getenv() in ./configure and fall back to the regular getenv() if it is not available. This should not actually matter in the one case we need it, namely on musl, because musl provides secure_getenv().
1 parent 8bb9a8c commit e553c0d

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

ext/gettext/config.m4

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ if test "$PHP_GETTEXT" != "no"; then
1111
AS_VAR_IF([GETTEXT_DIR],,
1212
[AC_MSG_ERROR([Cannot locate header file libintl.h])])
1313

14+
dnl POSIX 2024, but missing on Windows and macOS at least
15+
AC_CHECK_FUNCS([secure_getenv])
16+
1417
GETTEXT_LIBDIR=$GETTEXT_DIR/$PHP_LIBDIR
1518
GETTEXT_INCDIR=$GETTEXT_DIR/include
1619

ext/gettext/gettext.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,12 +202,16 @@ PHP_FUNCTION(bindtextdomain)
202202
* provide one (or more) via the MUSL_LOCPATH
203203
* environment variable. For lack of a better
204204
* idea, we return MUSL_LOCPATH if it is set,
205-
* even though it may contain multiple paths.
206-
* We use secure_getenv() because the musl docs
205+
* even though it may contain multiple paths. */
206+
#if HAVE_SECURE_GETENV
207+
/* We prefer secure_getenv() because the musl docs
207208
* say that MUSL_LOCPATH will be ignored in the
208209
* scenarios where secure_getenv() will return
209210
* NULL rather than the value of the variable. */
210211
musl_locpath = secure_getenv("MUSL_LOCPATH");
212+
#else
213+
musl_locpath = getenv("MUSL_LOCPATH");
214+
#endif
211215
if (musl_locpath == NULL) {
212216
RETURN_FALSE;
213217
}

0 commit comments

Comments
 (0)