From 0be13d2dc24f2802a231f92912ba5d089dad6676 Mon Sep 17 00:00:00 2001 From: Michael Maroszek Date: Thu, 7 Jul 2016 14:24:05 +0200 Subject: [PATCH 1/4] fix bug #72024 (microtime() leaks memory) --- ext/standard/string.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/ext/standard/string.c b/ext/standard/string.c index 39413c82117..1ecbdb97ce0 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -195,7 +195,6 @@ static char *php_hex2bin(const unsigned char *old, const size_t oldlen, size_t * * glibc's localeconv is not reentrant, so lets make it so ... sorta */ PHPAPI struct lconv *localeconv_r(struct lconv *out) { - struct lconv *res; # ifdef ZTS tsrm_mutex_lock( locale_mutex ); @@ -206,16 +205,14 @@ PHPAPI struct lconv *localeconv_r(struct lconv *out) /* Even with the enabled per thread locale, localeconv won't check any locale change in the master thread. */ _locale_t cur = _get_current_locale(); - - res = cur->locinfo->lconv; + *out = *cur->locinfo->lconv; + _free_locale(cur); } #else /* localeconv doesn't return an error condition */ - res = localeconv(); + *out = *localeconv(); #endif - *out = *res; - # ifdef ZTS tsrm_mutex_unlock( locale_mutex ); # endif From 78d5783b6259889dc97a060be611ba9aca26d87f Mon Sep 17 00:00:00 2001 From: Julien Pauli Date: Fri, 8 Jul 2016 14:58:56 +0200 Subject: [PATCH 2/4] Backported bug #71144 (Segmentation fault when using cURL with ZTS) --- ext/curl/interface.c | 9 +++++++++ ext/curl/tests/bug71144.phpt | 13 +++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 ext/curl/tests/bug71144.phpt diff --git a/ext/curl/interface.c b/ext/curl/interface.c index 19d8bb02b58..7e58c7f1e05 100644 --- a/ext/curl/interface.c +++ b/ext/curl/interface.c @@ -1925,7 +1925,9 @@ static void _php_curl_set_default_options(php_curl *ch) curl_easy_setopt(ch->cp, CURLOPT_INFILE, (void *) ch); curl_easy_setopt(ch->cp, CURLOPT_HEADERFUNCTION, curl_write_header); curl_easy_setopt(ch->cp, CURLOPT_WRITEHEADER, (void *) ch); +#if !defined(ZTS) curl_easy_setopt(ch->cp, CURLOPT_DNS_USE_GLOBAL_CACHE, 1); +#endif curl_easy_setopt(ch->cp, CURLOPT_DNS_CACHE_TIMEOUT, 120); curl_easy_setopt(ch->cp, CURLOPT_MAXREDIRS, 20); /* prevent infinite redirects */ @@ -2263,7 +2265,14 @@ static int _php_curl_setopt(php_curl *ch, long option, zval **zvalue TSRMLS_DC) return 1; } #endif +# if defined(ZTS) + if (option == CURLOPT_DNS_USE_GLOBAL_CACHE) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "CURLOPT_DNS_USE_GLOBAL_CACHE cannot be activated when thread safety is enabled"); + return 1; + } +# endif error = curl_easy_setopt(ch->cp, option, Z_LVAL_PP(zvalue)); + break; case CURLOPT_SAFE_UPLOAD: convert_to_long_ex(zvalue); diff --git a/ext/curl/tests/bug71144.phpt b/ext/curl/tests/bug71144.phpt new file mode 100644 index 00000000000..059cd63651f --- /dev/null +++ b/ext/curl/tests/bug71144.phpt @@ -0,0 +1,13 @@ +--TEST-- +Bug #71144 (Sementation fault when using cURL with ZTS) +--SKIPIF-- + + +--FILE-- + +--EXPECTF-- +Warning: curl_setopt(): CURLOPT_DNS_USE_GLOBAL_CACHE cannot be activated when thread safety is enabled in %sbug71144.php on line %d +bool(false) From 1071a2655f22912fda662a76467bd4bb7fd22faf Mon Sep 17 00:00:00 2001 From: Julien Pauli Date: Fri, 8 Jul 2016 14:59:16 +0200 Subject: [PATCH 3/4] Updated NEWS --- NEWS | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/NEWS b/NEWS index 75037ddec15..89c2681188c 100644 --- a/NEWS +++ b/NEWS @@ -1,18 +1,25 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| -?? ??? 2016, PHP 5.6.24 +?? ??? 2016, PHP 5.6.25 + +- Core: + . Fixed bug #72024 (microtime() leaks memory). (maroszek at gmx dot net) + +- Curl: + . Fixed bug #71144 (Segmentation fault when using cURL with ZTS). + (maroszek at gmx dot net) 21 Jul 2016, PHP 5.6.24 - Core: - . Fix bug #71936 (Segmentation fault destroying HTTP_RAW_POST_DATA). + . Fixed bug #71936 (Segmentation fault destroying HTTP_RAW_POST_DATA). (mike dot laspina at gmail dot com, Remi) - . Fix bug #72496 (Cannot declare public method with signature incompatible + . Fixed bug #72496 (Cannot declare public method with signature incompatible with parent private method). (Pedro Magalhães) - . Fix bug #72138 (Integer Overflow in Length of String-typed ZVAL). (Stas) + . Fixed bug #72138 (Integer Overflow in Length of String-typed ZVAL). (Stas) - bz2: - . Fix bug #72447 (Type Confusion in php_bz2_filter_create()). (gogil at + . Fixed bug #72447 (Type Confusion in php_bz2_filter_create()). (gogil at stealien dot com). - EXIF: From a8df121e18807d90fea2c0c4cdd1e17eed0f445a Mon Sep 17 00:00:00 2001 From: Julien Pauli Date: Fri, 8 Jul 2016 15:06:21 +0200 Subject: [PATCH 4/4] Updated NEWS --- NEWS | 1 + 1 file changed, 1 insertion(+) diff --git a/NEWS b/NEWS index 3f6b96911a3..95c2217447c 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,7 @@ PHP NEWS - Core: . Fixed bug #72496 (Cannot declare public method with signature incompatible with parent private method). (Pedro Magalhães) + . Fixed bug #72024 (microtime() leaks memory). (maroszek at gmx dot net) - SPL: . Fixed bug #55701 (GlobIterator throws LogicException). (Valentin VĂLCIU)