From ca48129caefa15548fec9bd4779dd87bde75f453 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Fri, 19 Jun 2020 16:07:14 +0200 Subject: [PATCH 1/3] Return void from php_jpeg_emit_message() Instead of returning long and then casting to void. This fixes a build warning on Ubuntu 20.04. Closes GH-5742. --- ext/gd/libgd/gd_jpeg.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/ext/gd/libgd/gd_jpeg.c b/ext/gd/libgd/gd_jpeg.c index 3f0241a8e0376..e7c3d752919b2 100644 --- a/ext/gd/libgd/gd_jpeg.c +++ b/ext/gd/libgd/gd_jpeg.c @@ -47,7 +47,7 @@ typedef struct _jmpbuf_wrapper int ignore_warning; } jmpbuf_wrapper; -static long php_jpeg_emit_message(j_common_ptr jpeg_info, int level) +static void php_jpeg_emit_message(j_common_ptr jpeg_info, int level) { char message[JMSG_LENGTH_MAX]; jmpbuf_wrapper *jmpbufw; @@ -81,11 +81,9 @@ static long php_jpeg_emit_message(j_common_ptr jpeg_info, int level) } } } - return 1; } - /* Called by the IJG JPEG library upon encountering a fatal error */ static void fatal_jpeg_error (j_common_ptr cinfo) { @@ -356,8 +354,7 @@ gdImagePtr gdImageCreateFromJpegCtxEx (gdIOCtx * infile, int ignore_warning) cinfo.err = jpeg_std_error (&jerr); cinfo.client_data = &jmpbufw; - - cinfo.err->emit_message = (void (*)(j_common_ptr,int)) php_jpeg_emit_message; + cinfo.err->emit_message = php_jpeg_emit_message; if (setjmp (jmpbufw.jmpbuf) != 0) { /* we're here courtesy of longjmp */ From bb61346580242a175c6f771b79f9722405970da1 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Wed, 17 Jun 2020 21:16:29 +0000 Subject: [PATCH 2/3] Fix Haiku build getrusage supports only two fields. The network api sits in the network lib. Closes GH-5732. --- configure.ac | 3 +++ ext/opcache/jit/zend_jit_perf_dump.c | 5 +++-- ext/standard/microtime.c | 2 +- sapi/phpdbg/phpdbg.c | 3 +++ 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index ded516b01f095..e830acfb25582 100644 --- a/configure.ac +++ b/configure.ac @@ -601,6 +601,9 @@ AX_FUNC_WHICH_GETHOSTBYNAME_R dnl Some systems (like OpenSolaris) do not have nanosleep in libc. PHP_CHECK_FUNC_LIB(nanosleep, rt) +dnl Haiku does not have network api in libc. +PHP_CHECK_FUNC_LIB(setsockopt, network) + dnl Check for getaddrinfo, should be a better way, but... Also check for working dnl getaddrinfo. AC_CACHE_CHECK([for getaddrinfo], ac_cv_func_getaddrinfo, diff --git a/ext/opcache/jit/zend_jit_perf_dump.c b/ext/opcache/jit/zend_jit_perf_dump.c index 663f9ae1e05cc..e61c49289535e 100644 --- a/ext/opcache/jit/zend_jit_perf_dump.c +++ b/ext/opcache/jit/zend_jit_perf_dump.c @@ -22,9 +22,10 @@ #include #include #include -#include -#if defined(__darwin__) +#if defined(__linux__) +#include +#elif defined(__darwin__) # include #elif defined(__FreeBSD__) # include diff --git a/ext/standard/microtime.c b/ext/standard/microtime.c index b33face760ff7..fe18e9b92aa9f 100644 --- a/ext/standard/microtime.c +++ b/ext/standard/microtime.c @@ -128,7 +128,7 @@ PHP_FUNCTION(getrusage) #ifdef PHP_WIN32 /* Windows only implements a limited amount of fields from the rusage struct */ PHP_RUSAGE_PARA(ru_majflt); PHP_RUSAGE_PARA(ru_maxrss); -#elif !defined(_OSD_POSIX) +#elif !defined(_OSD_POSIX) && !defined(__HAIKU__) PHP_RUSAGE_PARA(ru_oublock); PHP_RUSAGE_PARA(ru_inblock); PHP_RUSAGE_PARA(ru_msgsnd); diff --git a/sapi/phpdbg/phpdbg.c b/sapi/phpdbg/phpdbg.c index ea0653fd25e2b..f978c21ea348d 100644 --- a/sapi/phpdbg/phpdbg.c +++ b/sapi/phpdbg/phpdbg.c @@ -1683,6 +1683,9 @@ int main(int argc, char **argv) /* {{{ */ } #ifndef _WIN32 +# ifndef SIGIO +# define SIGIO SIGPOLL +# endif zend_sigaction(SIGIO, &sigio_struct, NULL); #endif From 6aff9a50cae40582d2571e7aa6f336d5c6a99547 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=B6sz=C3=B6rm=C3=A9nyi=20Zolt=C3=A1n?= Date: Fri, 19 Jun 2020 14:31:28 +0200 Subject: [PATCH 3/3] Fixed bug #79570 Use the same logic for getgrgid_r, getpwnam_r and getpwuid_r as for getgrnam_r in #75696 Closes GH-5740. --- NEWS | 2 ++ ext/posix/posix.c | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/NEWS b/NEWS index 33fbff3a54f27..4568036a7b896 100644 --- a/NEWS +++ b/NEWS @@ -32,6 +32,8 @@ PHP NEWS - Standard: . Fixed bug #74267 (segfault with streams and invalid data). (cmb) + . Fixed bug #79579 (ZTS build of PHP 7.3.17 doesn't handle ERANGE for + posix_getgrgid and others). (Böszörményi Zoltán) 11 Jun 2020, PHP 7.3.19 diff --git a/ext/posix/posix.c b/ext/posix/posix.c index 5a2f352e41f43..2826eb0e8456d 100644 --- a/ext/posix/posix.c +++ b/ext/posix/posix.c @@ -1140,8 +1140,14 @@ PHP_FUNCTION(posix_getgrgid) grbuf = emalloc(grbuflen); +try_again: ret = getgrgid_r(gid, &_g, grbuf, grbuflen, &retgrptr); if (ret || retgrptr == NULL) { + if (errno == ERANGE) { + grbuflen *= 2; + grbuf = erealloc(grbuf, grbuflen); + goto try_again; + } POSIX_G(last_error) = ret; efree(grbuf); RETURN_FALSE; @@ -1209,7 +1215,13 @@ PHP_FUNCTION(posix_getpwnam) buf = emalloc(buflen); pw = &pwbuf; +try_again: if (getpwnam_r(name, pw, buf, buflen, &pw) || pw == NULL) { + if (errno == ERANGE) { + buflen *= 2; + buf = erealloc(buf, buflen); + goto try_again; + } efree(buf); POSIX_G(last_error) = errno; RETURN_FALSE; @@ -1258,8 +1270,14 @@ PHP_FUNCTION(posix_getpwuid) } pwbuf = emalloc(pwbuflen); +try_again: ret = getpwuid_r(uid, &_pw, pwbuf, pwbuflen, &retpwptr); if (ret || retpwptr == NULL) { + if (errno == ERANGE) { + pwbuflen *= 2; + pwbuf = erealloc(pwbuf, pwbuflen); + goto try_again; + } POSIX_G(last_error) = ret; efree(pwbuf); RETURN_FALSE;