From 96885bc04f04b7e43c0a5daa2e392647fd0d1353 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Sat, 5 Aug 2023 18:03:46 +0200 Subject: [PATCH] fix: handle the GNU specific version of strerror_r Close GH-11882 --- NEWS | 3 +++ Zend/zend.c | 12 +++++++++--- configure.ac | 4 +++- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index d6be4635337..122e709a9a9 100644 --- a/NEWS +++ b/NEWS @@ -8,6 +8,9 @@ PHP NEWS . Fixed bug GH-10964 (Improve man page about the built-in server). (Alexandre Daubois) +- Core: + . Fixed strerror_r detection at configuration time. (Kévin Dunglas) + - DOM: . Fix DOMEntity field getter bugs. (nielsdos) . Fix incorrect attribute existence check in DOMElement::setAttributeNodeNS. diff --git a/Zend/zend.c b/Zend/zend.c index a1b4e3ee397..351e9ac5eea 100644 --- a/Zend/zend.c +++ b/Zend/zend.c @@ -1649,9 +1649,15 @@ ZEND_API ZEND_COLD ZEND_NORETURN void zend_error_noreturn(int type, const char * ZEND_API ZEND_COLD ZEND_NORETURN void zend_strerror_noreturn(int type, int errn, const char *message) { -#ifdef HAVE_STR_ERROR_R - char buf[1024]; - strerror_r(errn, buf, sizeof(buf)); +#ifdef HAVE_STRERROR_R + char b[1024]; + +# ifdef STRERROR_R_CHAR_P + char *buf = strerror_r(errn, b, sizeof(b)); +# else + strerror_r(errn, b, sizeof(b)); + char *buf = b; +# endif #else char *buf = strerror(errn); #endif diff --git a/configure.ac b/configure.ac index 6cf6370fca3..6d6d44e0597 100644 --- a/configure.ac +++ b/configure.ac @@ -621,9 +621,11 @@ vasprintf \ asprintf \ nanosleep \ memmem \ -strerror_r \ ) +dnl Check for strerror_r, and if its a POSIX-compatible or a GNU specific version. +AC_FUNC_STRERROR_R + AX_FUNC_WHICH_GETHOSTBYNAME_R dnl Some systems (like OpenSolaris) do not have nanosleep in libc.