Merge branch 'PHP-5.6' of https://github.com/php/php-src into gmp-random

This commit is contained in:
Leigh 2014-10-07 14:25:44 +01:00
commit aa679295e4
30 changed files with 1347 additions and 764 deletions

1
.gitignore vendored
View File

@ -19,6 +19,7 @@
*.tgz
*.tar.gz
*.tar.bz2
*.tar.xz
.FBCIndex
.FBCLockFolder
.deps

View File

@ -385,6 +385,12 @@ MAINTENANCE: Maintained
STATUS: Working
SINCE: 4.0.4
-------------------------------------------------------------------------------
EXTENSION: hash
PRIMARY MAINTAINER: Sara Golemon <pollita@php.net>, Mike Wallner <mike@php.net>, Anatol Belski <ab@php.net>
MAINTENANCE: Maintained
STATUS: Working
SINCE: 5.1.2
-------------------------------------------------------------------------------
EXTENSION: iconv
PRIMARY MAINTAINER: Moriyoshi Koizumi <moriyoshi@php.net>
MAINTENANCE: Maintained

22
NEWS
View File

@ -7,13 +7,24 @@ PHP NEWS
as 6.2 (instead of 6.3)). (Christian Wenz)
. Fixed bug #67633 (A foreach on an array returned from a function not doing
copy-on-write). (Nikita)
. Fixed bug #51800 (proc_open on Windows hangs forever). (Anatol)
. Fixed bug #68118 ($a->foo .= 'test'; can leave $a->foo undefined). (Nikita)
- FPM:
. Fixed bug #65641 (PHP-FPM incorrectly defines the SCRIPT_NAME variable
when using Apache, mod_proxy-fcgi and ProxyPass). (Remi)
. Implemented FR #55508 (listen and listen.allowed_clients should take IPv6
addresses). (Robin Gloster)
- Reflection:
. Fixed bug #68103 (Duplicate entry in Reflection for class alias). (Remi)
- OpenSSL:
. Fixed bug #68074 (Allow to use system cipher list instead of hardcoded
value). (Remi)
25 Sep 2014, PHP 5.6.1
02 Oct 2014, PHP 5.6.1
- Core:
. Implemented FR #38409 (parse_ini_file() looses the type of booleans). (Tjerk)
@ -24,6 +35,11 @@ PHP NEWS
(Nikita)
. Fixed bug #67985 (Incorrect last used array index copied to new array after
unset). (Tjerk)
. Fixed bug #68088 (New Posthandler Potential Illegal efree() vulnerability).
(Mike) (CVE-2014-3622)
- DOM:
. Made DOMNode::textContent writeable. (Tjerk)
- Fileinfo:
. Fixed bug #67731 (finfo::file() returns invalid mime type
@ -48,8 +64,8 @@ PHP NEWS
. Fixed bug #67850 (extension won't build if openssl compiled without SSLv3).
(Daniel Lowrey)
- DOM:
. Made DOMNode::textContent writeable. (Tjerk)
- phpdbg:
. Fixed issue krakjoe/phpdbg#111 (compile error without ZEND_SIGNALS). (Bob)
- SOAP:
. Fixed bug #67955 (SoapClient prepends 0-byte to cookie names). (Philip Hofstetter)

21
Zend/tests/bug68118.phpt Normal file
View File

@ -0,0 +1,21 @@
--TEST--
Bug #68118: $a->foo .= 'test'; can leave $a->foo undefined
--FILE--
<?php
set_error_handler(function() {
$obj = new stdClass;
$obj->test = 'meow';
return true;
});
$a = new stdClass;
$a->undefined .= 'test';
var_dump($a);
?>
--EXPECT--
object(stdClass)#2 (1) {
["undefined"]=>
string(4) "test"
}

View File

@ -786,9 +786,6 @@ static zval **zend_std_get_property_ptr_ptr(zval *object, zval *member, int type
/* we don't have access controls - will just add it */
new_zval = &EG(uninitialized_zval);
if(UNEXPECTED(type == BP_VAR_RW || type == BP_VAR_R)) {
zend_error(E_NOTICE, "Undefined property: %s::$%s", zobj->ce->name, Z_STRVAL_P(member));
}
Z_ADDREF_P(new_zval);
if (EXPECTED((property_info->flags & ZEND_ACC_STATIC) == 0) &&
property_info->offset >= 0) {
@ -808,6 +805,12 @@ static zval **zend_std_get_property_ptr_ptr(zval *object, zval *member, int type
}
zend_hash_quick_update(zobj->properties, property_info->name, property_info->name_length+1, property_info->h, &new_zval, sizeof(zval *), (void **) &retval);
}
/* Notice is thrown after creation of the property, to avoid EG(std_property_info)
* being overwritten in an error handler. */
if (UNEXPECTED(type == BP_VAR_RW || type == BP_VAR_R)) {
zend_error(E_NOTICE, "Undefined property: %s::$%s", zobj->ce->name, Z_STRVAL_P(member));
}
} else {
/* we do have getter - fail and let it try again with usual get/set */
retval = NULL;

File diff suppressed because it is too large Load Diff

View File

@ -330,7 +330,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_timezone_offset_get, 0, 0, 2)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_timezone_method_offset_get, 0, 0, 1)
ZEND_ARG_INFO(0, datetime)
ZEND_ARG_INFO(0, object)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_timezone_transitions_get, 0, 0, 1)
@ -3848,7 +3848,7 @@ PHP_FUNCTION(timezone_name_from_abbr)
}
/* }}} */
/* {{{ proto long timezone_offset_get(DateTimeZone object, DateTime object)
/* {{{ proto long timezone_offset_get(DateTimeZone object, DateTimeInterface object)
Returns the timezone offset.
*/
PHP_FUNCTION(timezone_offset_get)
@ -3858,13 +3858,13 @@ PHP_FUNCTION(timezone_offset_get)
php_date_obj *dateobj;
timelib_time_offset *offset;
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "OO", &object, date_ce_timezone, &dateobject, date_ce_date) == FAILURE) {
if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "OO", &object, date_ce_timezone, &dateobject, date_ce_interface) == FAILURE) {
RETURN_FALSE;
}
tzobj = (php_timezone_obj *) zend_object_store_get_object(object TSRMLS_CC);
DATE_CHECK_INITIALIZED(tzobj->initialized, DateTimeZone);
dateobj = (php_date_obj *) zend_object_store_get_object(dateobject TSRMLS_CC);
DATE_CHECK_INITIALIZED(dateobj->time, DateTime);
DATE_CHECK_INITIALIZED(dateobj->time, DateTimeInterface);
switch (tzobj->type) {
case TIMELIB_ZONETYPE_ID:

13
ext/date/tests/68062.phpt Normal file
View File

@ -0,0 +1,13 @@
--TEST--
DateTimeZone::getOffset() accepts a DateTimeInterface object
--FILE--
<?php
$tz = new DateTimeZone('Europe/London');
$dt = new DateTimeImmutable('2014-09-20', $tz);
echo $tz->getOffset($dt);
echo $tz->getOffset(1);
--EXPECTF--
3600
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, integer given in %s

View File

@ -112,141 +112,141 @@ fclose( $file_handle );
-- int 0 --
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, integer given in %s on line %d
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, integer given in %s on line %d
bool(false)
-- int 1 --
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, integer given in %s on line %d
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, integer given in %s on line %d
bool(false)
-- int 12345 --
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, integer given in %s on line %d
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, integer given in %s on line %d
bool(false)
-- int -12345 --
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, integer given in %s on line %d
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, integer given in %s on line %d
bool(false)
-- float 10.5 --
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, double given in %s on line %d
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, double given in %s on line %d
bool(false)
-- float -10.5 --
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, double given in %s on line %d
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, double given in %s on line %d
bool(false)
-- float .5 --
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, double given in %s on line %d
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, double given in %s on line %d
bool(false)
-- empty array --
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, array given in %s on line %d
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, array given in %s on line %d
bool(false)
-- int indexed array --
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, array given in %s on line %d
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, array given in %s on line %d
bool(false)
-- associative array --
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, array given in %s on line %d
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, array given in %s on line %d
bool(false)
-- nested arrays --
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, array given in %s on line %d
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, array given in %s on line %d
bool(false)
-- uppercase NULL --
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, null given in %s on line %d
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, null given in %s on line %d
bool(false)
-- lowercase null --
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, null given in %s on line %d
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, null given in %s on line %d
bool(false)
-- lowercase true --
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, boolean given in %s on line %d
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, boolean given in %s on line %d
bool(false)
-- lowercase false --
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, boolean given in %s on line %d
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, boolean given in %s on line %d
bool(false)
-- uppercase TRUE --
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, boolean given in %s on line %d
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, boolean given in %s on line %d
bool(false)
-- uppercase FALSE --
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, boolean given in %s on line %d
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, boolean given in %s on line %d
bool(false)
-- empty string DQ --
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, string given in %s on line %d
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, string given in %s on line %d
bool(false)
-- empty string SQ --
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, string given in %s on line %d
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, string given in %s on line %d
bool(false)
-- string DQ --
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, string given in %s on line %d
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, string given in %s on line %d
bool(false)
-- string SQ --
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, string given in %s on line %d
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, string given in %s on line %d
bool(false)
-- mixed case string --
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, string given in %s on line %d
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, string given in %s on line %d
bool(false)
-- heredoc --
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, string given in %s on line %d
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, string given in %s on line %d
bool(false)
-- instance of classWithToString --
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, object given in %s on line %d
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, object given in %s on line %d
bool(false)
-- instance of classWithoutToString --
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, object given in %s on line %d
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, object given in %s on line %d
bool(false)
-- undefined var --
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, null given in %s on line %d
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, null given in %s on line %d
bool(false)
-- unset var --
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, null given in %s on line %d
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, null given in %s on line %d
bool(false)
-- resource --
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTime, resource given in %s on line %d
Warning: DateTimeZone::getOffset() expects parameter 1 to be DateTimeInterface, resource given in %s on line %d
bool(false)
===DONE===

View File

@ -73,12 +73,12 @@ bool(false)
-- Testing timezone_offset_get() function with an invalid values for $datetime argument --
Warning: timezone_offset_get() expects parameter 2 to be DateTime, object given in %s on line %d
Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, object given in %s on line %d
bool(false)
Warning: timezone_offset_get() expects parameter 2 to be DateTime, integer given in %s on line %d
Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, integer given in %s on line %d
bool(false)
Warning: timezone_offset_get() expects parameter 2 to be DateTime, null given in %s on line %d
Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, null given in %s on line %d
bool(false)
===DONE===

View File

@ -112,141 +112,141 @@ fclose( $file_handle );
-- int 0 --
Warning: timezone_offset_get() expects parameter 2 to be DateTime, integer given in %s on line %d
Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, integer given in %s on line %d
bool(false)
-- int 1 --
Warning: timezone_offset_get() expects parameter 2 to be DateTime, integer given in %s on line %d
Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, integer given in %s on line %d
bool(false)
-- int 12345 --
Warning: timezone_offset_get() expects parameter 2 to be DateTime, integer given in %s on line %d
Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, integer given in %s on line %d
bool(false)
-- int -12345 --
Warning: timezone_offset_get() expects parameter 2 to be DateTime, integer given in %s on line %d
Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, integer given in %s on line %d
bool(false)
-- float 10.5 --
Warning: timezone_offset_get() expects parameter 2 to be DateTime, double given in %s on line %d
Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, double given in %s on line %d
bool(false)
-- float -10.5 --
Warning: timezone_offset_get() expects parameter 2 to be DateTime, double given in %s on line %d
Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, double given in %s on line %d
bool(false)
-- float .5 --
Warning: timezone_offset_get() expects parameter 2 to be DateTime, double given in %s on line %d
Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, double given in %s on line %d
bool(false)
-- empty array --
Warning: timezone_offset_get() expects parameter 2 to be DateTime, array given in %s on line %d
Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, array given in %s on line %d
bool(false)
-- int indexed array --
Warning: timezone_offset_get() expects parameter 2 to be DateTime, array given in %s on line %d
Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, array given in %s on line %d
bool(false)
-- associative array --
Warning: timezone_offset_get() expects parameter 2 to be DateTime, array given in %s on line %d
Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, array given in %s on line %d
bool(false)
-- nested arrays --
Warning: timezone_offset_get() expects parameter 2 to be DateTime, array given in %s on line %d
Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, array given in %s on line %d
bool(false)
-- uppercase NULL --
Warning: timezone_offset_get() expects parameter 2 to be DateTime, null given in %s on line %d
Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, null given in %s on line %d
bool(false)
-- lowercase null --
Warning: timezone_offset_get() expects parameter 2 to be DateTime, null given in %s on line %d
Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, null given in %s on line %d
bool(false)
-- lowercase true --
Warning: timezone_offset_get() expects parameter 2 to be DateTime, boolean given in %s on line %d
Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, boolean given in %s on line %d
bool(false)
-- lowercase false --
Warning: timezone_offset_get() expects parameter 2 to be DateTime, boolean given in %s on line %d
Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, boolean given in %s on line %d
bool(false)
-- uppercase TRUE --
Warning: timezone_offset_get() expects parameter 2 to be DateTime, boolean given in %s on line %d
Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, boolean given in %s on line %d
bool(false)
-- uppercase FALSE --
Warning: timezone_offset_get() expects parameter 2 to be DateTime, boolean given in %s on line %d
Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, boolean given in %s on line %d
bool(false)
-- empty string DQ --
Warning: timezone_offset_get() expects parameter 2 to be DateTime, string given in %s on line %d
Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, string given in %s on line %d
bool(false)
-- empty string SQ --
Warning: timezone_offset_get() expects parameter 2 to be DateTime, string given in %s on line %d
Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, string given in %s on line %d
bool(false)
-- string DQ --
Warning: timezone_offset_get() expects parameter 2 to be DateTime, string given in %s on line %d
Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, string given in %s on line %d
bool(false)
-- string SQ --
Warning: timezone_offset_get() expects parameter 2 to be DateTime, string given in %s on line %d
Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, string given in %s on line %d
bool(false)
-- mixed case string --
Warning: timezone_offset_get() expects parameter 2 to be DateTime, string given in %s on line %d
Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, string given in %s on line %d
bool(false)
-- heredoc --
Warning: timezone_offset_get() expects parameter 2 to be DateTime, string given in %s on line %d
Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, string given in %s on line %d
bool(false)
-- instance of classWithToString --
Warning: timezone_offset_get() expects parameter 2 to be DateTime, object given in %s on line %d
Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, object given in %s on line %d
bool(false)
-- instance of classWithoutToString --
Warning: timezone_offset_get() expects parameter 2 to be DateTime, object given in %s on line %d
Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, object given in %s on line %d
bool(false)
-- undefined var --
Warning: timezone_offset_get() expects parameter 2 to be DateTime, null given in %s on line %d
Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, null given in %s on line %d
bool(false)
-- unset var --
Warning: timezone_offset_get() expects parameter 2 to be DateTime, null given in %s on line %d
Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, null given in %s on line %d
bool(false)
-- resource --
Warning: timezone_offset_get() expects parameter 2 to be DateTime, resource given in %s on line %d
Warning: timezone_offset_get() expects parameter 2 to be DateTimeInterface, resource given in %s on line %d
bool(false)
===DONE===

View File

@ -156,12 +156,12 @@ if test "\$PHP_$EXTNAME" != "no"; then
dnl PHP_CHECK_LIBRARY(\$LIBNAME,\$LIBSYMBOL,
dnl [
dnl PHP_ADD_LIBRARY_WITH_PATH(\$LIBNAME, \$${EXTNAME}_DIR/lib, ${EXTNAME}_SHARED_LIBADD)
dnl PHP_ADD_LIBRARY_WITH_PATH(\$LIBNAME, \$${EXTNAME}_DIR/\$PHP_LIBDIR, ${EXTNAME}_SHARED_LIBADD)
dnl AC_DEFINE(HAVE_${EXTNAME}LIB,1,[ ])
dnl ],[
dnl AC_MSG_ERROR([wrong $extname lib version or lib not found])
dnl ],[
dnl -L\$${EXTNAME}_DIR/lib -lm
dnl -L\$${EXTNAME}_DIR/\$PHP_LIBDIR -lm
dnl ])
dnl
dnl PHP_SUBST(${EXTNAME}_SHARED_LIBADD)

View File

@ -391,6 +391,23 @@ static int _get_lderrno(LDAP *ldap)
}
/* }}} */
/* {{{ _set_lderrno
*/
static void _set_lderrno(LDAP *ldap, int lderr)
{
#if !HAVE_NSLDAP
#if LDAP_API_VERSION > 2000 || HAVE_ORALDAP
/* New versions of OpenLDAP do it this way */
ldap_set_option(ldap, LDAP_OPT_ERROR_NUMBER, &lderr);
#else
ldap->ld_errno = lderr;
#endif
#else
ldap_set_lderrno(ldap, lderr, NULL, NULL);
#endif
}
/* }}} */
/* {{{ proto bool ldap_bind(resource link [, string dn [, string password]])
Bind to LDAP directory */
PHP_FUNCTION(ldap_bind)
@ -405,18 +422,20 @@ PHP_FUNCTION(ldap_bind)
RETURN_FALSE;
}
ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, &link, -1, "ldap link", le_link);
if (ldap_bind_dn != NULL && memchr(ldap_bind_dn, '\0', ldap_bind_dnlen) != NULL) {
_set_lderrno(ld->link, LDAP_INVALID_CREDENTIALS);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "DN contains a null byte");
RETURN_FALSE;
}
if (ldap_bind_pw != NULL && memchr(ldap_bind_pw, '\0', ldap_bind_pwlen) != NULL) {
_set_lderrno(ld->link, LDAP_INVALID_CREDENTIALS);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Password contains a null byte");
RETURN_FALSE;
}
ZEND_FETCH_RESOURCE(ld, ldap_linkdata *, &link, -1, "ldap link", le_link);
if ((rc = ldap_bind_s(ld->link, ldap_bind_dn, ldap_bind_pw, LDAP_AUTH_SIMPLE)) != LDAP_SUCCESS) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to bind to server: %s", ldap_err2string(rc));
RETURN_FALSE;

View File

@ -8,6 +8,9 @@ PHP_ARG_WITH(openssl, for OpenSSL support,
PHP_ARG_WITH(kerberos, for Kerberos support,
[ --with-kerberos[=DIR] OPENSSL: Include Kerberos support], no, no)
PHP_ARG_WITH(system-ciphers, whether to use system default cipher list instead of hardcoded value,
[ --with-system-ciphers OPENSSL: Use system default cipher list instead of hardcoded value], no, no)
if test "$PHP_OPENSSL" != "no"; then
PHP_NEW_EXTENSION(openssl, openssl.c xp_ssl.c, $ext_shared)
PHP_SUBST(OPENSSL_SHARED_LIBADD)
@ -25,4 +28,7 @@ if test "$PHP_OPENSSL" != "no"; then
], [
AC_MSG_ERROR([OpenSSL check failed. Please check config.log for more information.])
])
if test "$PHP_SYSTEM_CIPHERS" != "no"; then
AC_DEFINE(USE_OPENSSL_SYSTEM_CIPHERS,1,[ Use system default cipher list instead of hardcoded value ])
fi
fi

View File

@ -1,28 +1,28 @@
-----BEGIN CERTIFICATE-----
MIICCTCCAXICCQDNMI29sowT7TANBgkqhkiG9w0BAQUFADBJMQswCQYDVQQGEwJT
MIICCTCCAXICCQCx2JwIhbRefzANBgkqhkiG9w0BAQUFADBJMQswCQYDVQQGEwJT
RzESMBAGA1UECBMJVGVzdHZpbGxlMREwDwYDVQQKEwhkYXRpYmJhdzETMBEGA1UE
AxQKKi50ZXN0LmNvbTAeFw0xMzA5MjEwNzUyMjRaFw0xNDA5MjEwNzUyMjRaMEkx
AxQKKi50ZXN0LmNvbTAeFw0xNDA5MjQxMTMzNTRaFw0yNDA5MjExMTMzNTRaMEkx
CzAJBgNVBAYTAlNHMRIwEAYDVQQIEwlUZXN0dmlsbGUxETAPBgNVBAoTCGRhdGli
YmF3MRMwEQYDVQQDFAoqLnRlc3QuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCB
iQKBgQCdzVnic8K5W4SVbwVuqezcTjeqVLoQ91vVNZB0Jnsuz6q3DoK03oAd1jTe
Vd0k+MQDbXpHoc37lA4+8z/g5Bs0UXxNx+nkbFTE7Ba2/G24caI9/cOXZPG3UViD
rtqXKL6h5/umqRG9Dt5liF2MVP9XFAesVC7B8+Ca+PbPlQoYzwIDAQABMA0GCSqG
SIb3DQEBBQUAA4GBAAS07u/Ke+EhEHidz6CG3Qcr+zg483JKRgZFyGz+YUKyyKKy
fmLs7JieGJxYQjOmIpj/6X9Gnb2HjIPDnI6A+MV1emXDTnnmsgf2/lZGcthhpZn2
rMbj9bI0iH6HwOVGtp4ZJA5fB7nj3J+gWNTCQzDDOxwX36d2LL9ua+UMnk/g
iQKBgQDBnR8DYzsN90kISI87kBvw40TQknS7/fuymWCmSrtRQLED8p2QL8PiYCZ8
UdcFVsv+di7MJvUOzW6dRo2DCu8Rojx3ML8dAtPsQkDdaCXDnOvCTQCAqFmxa1A9
c5kp0hbzCrucKGckb355A4NumFgX1fjQ705MfjGPgQef1ZtozQIDAQABMA0GCSqG
SIb3DQEBBQUAA4GBAGP07nJo0pI4FdsXuAHWr97XxV4EhHopFMw6svOZ3UtsRzmW
ScmmMdgd3c8ciVxOsztgnzvFq/nrUkw/3n/Xz/gtE7kZt9aS18SnCyyHPJcXmmUE
NsbyZ/7srIqCSrxUkP+N//nToqHxg1pqA/A8RzOOQUAp+UIVF6Zl/kkFNgt8
-----END CERTIFICATE-----
-----BEGIN RSA PRIVATE KEY-----
MIICXQIBAAKBgQCdzVnic8K5W4SVbwVuqezcTjeqVLoQ91vVNZB0Jnsuz6q3DoK0
3oAd1jTeVd0k+MQDbXpHoc37lA4+8z/g5Bs0UXxNx+nkbFTE7Ba2/G24caI9/cOX
ZPG3UViDrtqXKL6h5/umqRG9Dt5liF2MVP9XFAesVC7B8+Ca+PbPlQoYzwIDAQAB
AoGAeyzTwKPDl5QMRejHQL57GOwlH1vLcXrjv+VzwHZZKQ0IoKM++5fCQYf29KXp
XPahaluGW2u9sWa8R/7wGcd0Q4RtquGzsgT3+AQsIc5KfIamyOyDaRVM/ymX3fWg
gHIU7OOzB+ihOU8sHyRIwfbk01/kmrBXLRj8E31sy3i3PIECQQDQQYE+aN7Acrdt
yN5CaqvbkiCGjRvASlemiTzPosgOtndyp21w1gakJwKYhYDk1N6A6Qb8REMZqM/U
wFypldV/AkEAwfq6NFuhpGL6hDA7MvlyY1KiZ0cHetPUX+PgdNqy2DA+1Sv4i7gm
Wd/uA651K7aPXuUaf9dKtPCmZwI4M6SEsQJBALW89HTqP7niYoDEEnITdPaghxHk
gptERUln6lGo1L1CLus3gSI/JHyMLo+7scgAnEwTD62GRKhX0Ubwt+ymfTECQAY5
fHYnppU20+EgBxZIqOIFCc8UmWnYmE0Ha/Fz/x8u1SVUBuK84wYpSGL32yyu7ATY
hzQo/W229zABAzqtAdECQQCUdB7IBFpPnsfv/EUBFX7X/7zAc9JpACmu9It5ju8C
KIsMuz/02D+TQoJNjdAngBM+4AJDIaGFgTMIfaDMh5L7
MIICXgIBAAKBgQDBnR8DYzsN90kISI87kBvw40TQknS7/fuymWCmSrtRQLED8p2Q
L8PiYCZ8UdcFVsv+di7MJvUOzW6dRo2DCu8Rojx3ML8dAtPsQkDdaCXDnOvCTQCA
qFmxa1A9c5kp0hbzCrucKGckb355A4NumFgX1fjQ705MfjGPgQef1ZtozQIDAQAB
AoGADAnkAsbpxh2JKf2xAkgcpKbNAZcJsSLCwsEstEpTSWMXXqJ4T53YtTu7SOGh
2BAkkQbyM/l8JVZ6uUbIx8wnPzqAuB2hEDQHKZVyftDyJh+54Uyz0xV0JdWGWrFh
A+uDt/Zncx2g+qlkQG5J5nHnrd9OAns89wJXpBWA6twlsuECQQD/HC4wxOJzh1XI
YSWHWQulOnlNgZ2zERfmJeRfJ0ncmDOV2ofxOFQ+dMJ36XghPaH52KdxqWI1yQaE
yesx8ygFAkEAwkoF4lBuYdsXucJNDYf8o9MlBvazoriH0y26B/YozJ7iAEFqVvcC
TN+iKDIyiRALwR6a3nzhyFYJ4xyzgSIAKQJBAMnw3seQMsnM6aTS8cgwPr2uifNG
lTT4ZPi0KhEAosFSYhNPh6j1NAq0lnQhhgyaIywJypJ4yNtWpChdRiamGpkCQQDB
iUExPpOmMLwCk7VzrCmS+6pftHIevpi2WU99zMy5f+969665MFb/QqniRpamh/Bd
kGIPDPFQQbyZmqaJFNh5AkEAzy0YVbUT3C/QvstPr5i7ztj7WiW/1zJMamFwY/ZS
1J7e7lqHgRICie5uv1Yvh3w/qmV/7lTLhmlQZd9SJMpXhg==
-----END RSA PRIVATE KEY-----

View File

@ -1476,13 +1476,16 @@ int php_openssl_setup_crypto(php_stream *stream,
}
GET_VER_OPT_STRING("ciphers", cipherlist);
#ifndef USE_OPENSSL_SYSTEM_CIPHERS
if (!cipherlist) {
cipherlist = OPENSSL_DEFAULT_STREAM_CIPHERS;
}
if (SSL_CTX_set_cipher_list(sslsock->ctx, cipherlist) != 1) {
return FAILURE;
#endif
if (cipherlist) {
if (SSL_CTX_set_cipher_list(sslsock->ctx, cipherlist) != 1) {
return FAILURE;
}
}
if (FAILURE == set_local_cert(sslsock->ctx, stream TSRMLS_CC)) {
return FAILURE;
}

View File

@ -1015,9 +1015,12 @@ static int _extension_class_string(zend_class_entry **pce TSRMLS_DC, int num_arg
int *num_classes = va_arg(args, int*);
if (((*pce)->type == ZEND_INTERNAL_CLASS) && (*pce)->info.internal.module && !strcasecmp((*pce)->info.internal.module->name, module->name)) {
string_printf(str, "\n");
_class_string(str, *pce, NULL, indent TSRMLS_CC);
(*num_classes)++;
/* dump class if it is not an alias */
if (!zend_binary_strcasecmp((*pce)->name, (*pce)->name_length, hash_key->arKey, hash_key->nKeyLength-1)) {
string_printf(str, "\n");
_class_string(str, *pce, NULL, indent TSRMLS_CC);
(*num_classes)++;
}
}
return ZEND_HASH_APPLY_KEEP;
}
@ -5395,12 +5398,24 @@ static int add_extension_class(zend_class_entry **pce TSRMLS_DC, int num_args, v
int add_reflection_class = va_arg(args, int);
if (((*pce)->type == ZEND_INTERNAL_CLASS) && (*pce)->info.internal.module && !strcasecmp((*pce)->info.internal.module->name, module->name)) {
const char *name;
int nlen;
if (zend_binary_strcasecmp((*pce)->name, (*pce)->name_length, hash_key->arKey, hash_key->nKeyLength-1)) {
/* This is an class alias, use alias name */
name = hash_key->arKey;
nlen = hash_key->nKeyLength-1;
} else {
/* Use class name */
name = (*pce)->name;
nlen = (*pce)->name_length;
}
if (add_reflection_class) {
ALLOC_ZVAL(zclass);
zend_reflection_class_factory(*pce, zclass TSRMLS_CC);
add_assoc_zval_ex(class_array, (*pce)->name, (*pce)->name_length + 1, zclass);
add_assoc_zval_ex(class_array, name, nlen+1, zclass);
} else {
add_next_index_stringl(class_array, (*pce)->name, (*pce)->name_length, 1);
add_next_index_stringl(class_array, name, nlen, 1);
}
}
return ZEND_HASH_APPLY_KEEP;
@ -6083,7 +6098,7 @@ ZEND_END_ARG_INFO()
static const zend_function_entry reflection_zend_extension_functions[] = {
ZEND_ME(reflection, __clone, arginfo_reflection__void, ZEND_ACC_PRIVATE|ZEND_ACC_FINAL)
ZEND_ME(reflection_zend_extension, export, arginfo_reflection_extension_export, ZEND_ACC_STATIC|ZEND_ACC_PUBLIC)
ZEND_ME(reflection_zend_extension, __construct, arginfo_reflection_extension___construct, 0)
ZEND_ME(reflection_zend_extension, __construct, arginfo_reflection_zend_extension___construct, 0)
ZEND_ME(reflection_zend_extension, __toString, arginfo_reflection__void, 0)
ZEND_ME(reflection_zend_extension, getName, arginfo_reflection__void, 0)
ZEND_ME(reflection_zend_extension, getVersion, arginfo_reflection__void, 0)

View File

@ -0,0 +1,95 @@
--TEST--
Bug #51800 proc_open on Windows hangs forever
--SKIPIF--
<?php
echo 'skip expected to fail or take too long';
if (getenv("SKIP_SLOW_TESTS")) {
die("skip slow test");
}
?>
--XFAIL--
pipes have to be read/written simultaneously
--FILE--
<?php
/* This is the wrong way to do it. The parent will block till it has read all the STDIN.
The smaller the pipe buffer is, the longer it will take. It might even pass at the end,
after taking inappropriately long. Pipes have to be read simultaneously in smaller chunks,
so then the pipe buffer is emptied more often and the child has chance to continue its
write. The behaviour might look some better if write/read in a separate thread, however
this is much more resource greedy and complexer to integrate into the user script. */
$callee = dirname(__FILE__) . "/process_proc_open_bug51800.php";
$php = PHP_BINARY;
$cmd = "$php $callee";
$status;
$stdout = "";
$stderr = "";
$pipes = array();
$descriptors = array(
0 => array("pipe", "rb"), // stdin
1 => array("pipe", "wb"), // stdout
2 => array("pipe", "wb") // stderr
);
/* create the proc file */
$r = file_put_contents($callee, '<?php
$how_much = 10000;
$data0 = str_repeat("a", $how_much);
$data1 = str_repeat("b", $how_much);
fwrite(STDOUT, $data0);
fwrite(STDERR, $data1);
exit(0);
');
if (!$r) {
die("couldn't create helper script '$callee'");
}
$process = proc_open($cmd, $descriptors, $pipes);
if (is_resource($process))
{
fclose($pipes[0]);
while (!feof($pipes[1]))
$stdout .= fread($pipes[1], 1024);
fclose($pipes[1]);
while (!feof($pipes[2]))
$stderr .= fread($pipes[2], 1024);
fclose($pipes[2]);
$status = proc_close($process);
}
var_dump(array(
"status" => $status,
"stdout" => $stdout,
"stderr" => $stderr,
), strlen($stdout), strlen($stderr));
?>
===DONE===
--CLEAN--
<?php
$callee = dirname(__FILE__) . "/process_proc_open_bug51800.php";
unlink($callee);
?>
--EXPECTF--
array(3) {
["status"]=>
int(0)
["stdout"]=>
string(10000) "a%s"
["stderr"]=>
string(10000) "b%s"
}
int(10000)
int(10000)
===DONE===

View File

@ -0,0 +1,78 @@
--TEST--
Bug #51800 proc_open on Windows hangs forever, the right way to do it
--FILE--
<?php
$callee = dirname(__FILE__) . "/process_proc_open_bug51800_right.php";
$php = PHP_BINARY;
$cmd = "$php $callee";
$status;
$stdout = "";
$stderr = "";
$pipes = array();
$descriptors = array(
0 => array("pipe", "rb"), // stdin
1 => array("pipe", "wb"), // stdout
2 => array("pipe", "wb") // stderr
);
/* create the proc file */
$r = file_put_contents($callee, '<?php
$how_much = 10000;
$data0 = str_repeat("a", $how_much);
$data1 = str_repeat("b", $how_much);
fwrite(STDOUT, $data0);
fwrite(STDERR, $data1);
exit(0);
');
if (!$r) {
die("couldn't create helper script '$callee'");
}
$process = proc_open($cmd, $descriptors, $pipes);
if (is_resource($process))
{
fclose($pipes[0]);
while (!feof($pipes[1]) || !feof($pipes[2])) {
$stdout .= fread($pipes[1], 1024);
$stderr .= fread($pipes[2], 1024);
}
fclose($pipes[1]);
fclose($pipes[2]);
$status = proc_close($process);
}
var_dump(array(
"status" => $status,
"stdout" => $stdout,
"stderr" => $stderr,
), strlen($stdout), strlen($stderr));
?>
===DONE===
--CLEAN--
<?php
$callee = dirname(__FILE__) . "/process_proc_open_bug51800_right.php";
unlink($callee);
?>
--EXPECTF--
array(3) {
["status"]=>
int(0)
["stdout"]=>
string(10000) "a%s"
["stderr"]=>
string(10000) "b%s"
}
int(10000)
int(10000)
===DONE===

View File

@ -0,0 +1,84 @@
--TEST--
Bug #51800 proc_open on Windows hangs forever, the right way to do it with more data
--FILE--
<?php
$callee = dirname(__FILE__) . "/process_proc_open_bug51800_right2.php";
$php = PHP_BINARY;
$cmd = "$php $callee";
$status;
$stdout = "";
$stderr = "";
$pipes = array();
$descriptors = array(
0 => array("pipe", "rb"), // stdin
1 => array("pipe", "wb"), // stdout
2 => array("pipe", "wb") // stderr
);
/* create the proc file */
$r = file_put_contents($callee, '<?php
$how_much = 1000000;
$data0 = str_repeat("a", $how_much);
$data1 = str_repeat("b", $how_much);
$i0 = $i1 = 0;
$step = 1024;
while ($i0 < strlen($data0) && $i1 < strlen($data1)) {
fwrite(STDOUT, substr($data0, $i0, $step));
fwrite(STDERR, substr($data1, $i1, $step));
$i0 += $step;
$i1 += $step;
}
exit(0);
');
if (!$r) {
die("couldn't create helper script '$callee'");
}
$process = proc_open($cmd, $descriptors, $pipes);
if (is_resource($process))
{
fclose($pipes[0]);
while (!feof($pipes[1]) || !feof($pipes[2])) {
$stdout .= fread($pipes[1], 1024);
$stderr .= fread($pipes[2], 1024);
}
fclose($pipes[1]);
fclose($pipes[2]);
$status = proc_close($process);
}
var_dump(array(
"status" => $status,
"stdout" => $stdout,
"stderr" => $stderr,
), strlen($stdout), strlen($stderr));
?>
===DONE===
--CLEAN--
<?php
$callee = dirname(__FILE__) . "/process_proc_open_bug51800_right2.php";
unlink($callee);
?>
--EXPECTF--
array(3) {
["status"]=>
int(0)
["stdout"]=>
string(1000000) "a%s"
["stderr"]=>
string(1000000) "b%s"
}
int(1000000)
int(1000000)
===DONE===

View File

@ -0,0 +1,71 @@
--TEST--
Bug #60120 proc_open hangs with stdin/out with 2048+ bytes
--FILE--
<?php
error_reporting(E_ALL);
if (substr(PHP_OS, 0, 3) == 'WIN') {
$cmd = PHP_BINARY . ' -n -r "fwrite(STDOUT, $in = file_get_contents(\'php://stdin\')); fwrite(STDERR, $in);"';
} else {
$cmd = PHP_BINARY . ' -n -r \'fwrite(STDOUT, $in = file_get_contents("php://stdin")); fwrite(STDERR, $in);\'';
}
$descriptors = array(array('pipe', 'r'), array('pipe', 'w'), array('pipe', 'w'));
$stdin = str_repeat('*', 1024 * 16) . '!';
$stdin = str_repeat('*', 2049 );
$options = array_merge(array('suppress_errors' => true, 'binary_pipes' => true, 'bypass_shell' => false));
$process = proc_open($cmd, $descriptors, $pipes, getcwd(), array(), $options);
foreach ($pipes as $pipe) {
stream_set_blocking($pipe, false);
}
$writePipes = array($pipes[0]);
$stdinLen = strlen($stdin);
$stdinOffset = 0;
unset($pipes[0]);
while ($pipes || $writePipes) {
$r = $pipes;
$w = $writePipes;
$e = null;
$n = stream_select($r, $w, $e, 60);
if (false === $n) {
break;
} elseif ($n === 0) {
proc_terminate($process);
}
if ($w) {
$written = fwrite($writePipes[0], (binary)substr($stdin, $stdinOffset), 8192);
if (false !== $written) {
$stdinOffset += $written;
}
if ($stdinOffset >= $stdinLen) {
fclose($writePipes[0]);
$writePipes = null;
}
}
foreach ($r as $pipe) {
$type = array_search($pipe, $pipes);
$data = fread($pipe, 8192);
var_dump($data);
if (false === $data || feof($pipe)) {
fclose($pipe);
unset($pipes[$type]);
}
}
}
?>
===DONE===
--EXPECTF--
string(2049) "%s"
string(2049) "%s"
string(0) ""
string(0) ""
===DONE===

View File

@ -0,0 +1,70 @@
--TEST--
Bug #64438 proc_open hangs with stdin/out with 4097+ bytes
--FILE--
<?php
error_reporting(E_ALL);
if (substr(PHP_OS, 0, 3) == 'WIN') {
$cmd = PHP_BINARY . ' -n -r "fwrite(STDOUT, $in = file_get_contents(\'php://stdin\')); fwrite(STDERR, $in);"';
} else {
$cmd = PHP_BINARY . ' -n -r \'fwrite(STDOUT, $in = file_get_contents("php://stdin")); fwrite(STDERR, $in);\'';
}
$descriptors = array(array('pipe', 'r'), array('pipe', 'w'), array('pipe', 'w'));
$stdin = str_repeat('*', 4097);
$options = array_merge(array('suppress_errors' => true, 'binary_pipes' => true, 'bypass_shell' => false));
$process = proc_open($cmd, $descriptors, $pipes, getcwd(), array(), $options);
foreach ($pipes as $pipe) {
stream_set_blocking($pipe, false);
}
$writePipes = array($pipes[0]);
$stdinLen = strlen($stdin);
$stdinOffset = 0;
unset($pipes[0]);
while ($pipes || $writePipes) {
$r = $pipes;
$w = $writePipes;
$e = null;
$n = stream_select($r, $w, $e, 60);
if (false === $n) {
break;
} elseif ($n === 0) {
proc_terminate($process);
}
if ($w) {
$written = fwrite($writePipes[0], (binary)substr($stdin, $stdinOffset), 8192);
if (false !== $written) {
$stdinOffset += $written;
}
if ($stdinOffset >= $stdinLen) {
fclose($writePipes[0]);
$writePipes = null;
}
}
foreach ($r as $pipe) {
$type = array_search($pipe, $pipes);
$data = fread($pipe, 8192);
var_dump($data);
if (false === $data || feof($pipe)) {
fclose($pipe);
unset($pipes[$type]);
}
}
}
?>
===DONE===
--EXPECTF--
string(4097) "%s"
string(4097) "%s"
string(0) ""
string(0) ""
===DONE===

View File

@ -18,8 +18,11 @@ if (substr(PHP_OS, 0, 3) == 'WIN') {
/* setlocale() to set all available locales in the system and check the success count */
echo "*** Testing setlocale() : usage variations ***\n";
function good_locale($locale) {
return $locale !== 'tt_RU@iqtelif.UTF-8';
function good_locale($locale) {
/**
* Note: no_NO is a bogus locale and should not be used, see https://bugzilla.redhat.com/971416
**/
return $locale !== 'tt_RU@iqtelif.UTF-8' && $locale !== 'no_NO.ISO-8859-1';
}
/* Prototype : array list_system_locales( void )

View File

@ -342,6 +342,34 @@ static size_t php_stdiop_read(php_stream *stream, char *buf, size_t count TSRMLS
assert(data != NULL);
if (data->fd >= 0) {
#ifdef PHP_WIN32
php_stdio_stream_data *self = (php_stdio_stream_data*)stream->abstract;
if (self->is_pipe || self->is_process_pipe) {
HANDLE ph = (HANDLE)_get_osfhandle(data->fd);
int retry = 0;
DWORD avail_read = 0;
do {
/* Look ahead to get the available data amount to read. Do the same
as read() does, however not blocking forever. In case it failed,
no data will be read (better than block). */
if (!PeekNamedPipe(ph, NULL, 0, NULL, &avail_read, NULL)) {
break;
}
/* If there's nothing to read, wait in 100ms periods. */
if (0 == avail_read) {
usleep(100000);
}
} while (0 == avail_read && retry++ < 320);
/* Reduce the required data amount to what is available, otherwise read()
will block.*/
if (avail_read < count) {
count = avail_read;
}
}
#endif
ret = read(data->fd, buf, count);
if (ret == (size_t)-1 && errno == EINTR) {

View File

@ -59,8 +59,6 @@ foreach ($codes as $key => $code) {
echo "\nDone\n";
?>
--XFAIL--
https://bugs.php.net/bug.php?id=55496
--EXPECTF--
--------------
Snippet no. 1:

View File

@ -39,29 +39,6 @@ struct listening_socket_s {
static struct fpm_array_s sockets_list;
static int fpm_sockets_resolve_af_inet(char *node, char *service, struct sockaddr_in *addr) /* {{{ */
{
struct addrinfo *res;
struct addrinfo hints;
int ret;
memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_INET;
ret = getaddrinfo(node, service, &hints, &res);
if (ret != 0) {
zlog(ZLOG_ERROR, "can't resolve hostname '%s%s%s': getaddrinfo said: %s%s%s\n",
node, service ? ":" : "", service ? service : "",
gai_strerror(ret), ret == EAI_SYSTEM ? ", system error: " : "", ret == EAI_SYSTEM ? strerror(errno) : "");
return -1;
}
*addr = *(struct sockaddr_in *) res->ai_addr;
freeaddrinfo(res);
return 0;
}
/* }}} */
enum { FPM_GET_USE_SOCKET = 1, FPM_STORE_SOCKET = 2, FPM_STORE_USE_SOCKET = 3 };
static void fpm_sockets_cleanup(int which, void *arg) /* {{{ */
@ -98,14 +75,23 @@ static void fpm_sockets_cleanup(int which, void *arg) /* {{{ */
}
/* }}} */
static void *fpm_get_in_addr(struct sockaddr *sa) /* {{{ */
{
if (sa->sa_family == AF_INET) {
return &(((struct sockaddr_in*)sa)->sin_addr);
}
return &(((struct sockaddr_in6*)sa)->sin6_addr);
}
/* }}} */
static int fpm_sockets_hash_op(int sock, struct sockaddr *sa, char *key, int type, int op) /* {{{ */
{
if (key == NULL) {
switch (type) {
case FPM_AF_INET : {
struct sockaddr_in *sa_in = (struct sockaddr_in *) sa;
key = alloca(sizeof("xxx.xxx.xxx.xxx:ppppp"));
sprintf(key, "%u.%u.%u.%u:%u", IPQUAD(&sa_in->sin_addr), (unsigned int) ntohs(sa_in->sin_port));
key = alloca(INET6_ADDRSTRLEN);
inet_ntop(sa->sa_family, fpm_get_in_addr(sa), key, sizeof key);
break;
}
@ -254,11 +240,14 @@ enum fpm_address_domain fpm_sockets_domain_from_address(char *address) /* {{{ */
static int fpm_socket_af_inet_listening_socket(struct fpm_worker_pool_s *wp) /* {{{ */
{
struct sockaddr_in sa_in;
struct addrinfo hints, *servinfo, *p;
char *dup_address = strdup(wp->config->listen_address);
char *port_str = strchr(dup_address, ':');
char *port_str = strrchr(dup_address, ':');
char *addr = NULL;
int addr_len;
int port = 0;
int sock;
int status;
if (port_str) { /* this is host:port pair */
*port_str++ = '\0';
@ -274,23 +263,35 @@ static int fpm_socket_af_inet_listening_socket(struct fpm_worker_pool_s *wp) /*
return -1;
}
memset(&sa_in, 0, sizeof(sa_in));
if (addr) {
sa_in.sin_addr.s_addr = inet_addr(addr);
if (sa_in.sin_addr.s_addr == INADDR_NONE) { /* do resolve */
if (0 > fpm_sockets_resolve_af_inet(addr, NULL, &sa_in)) {
return -1;
}
zlog(ZLOG_NOTICE, "address '%s' resolved as %u.%u.%u.%u", addr, IPQUAD(&sa_in.sin_addr));
// strip brackets from address for getaddrinfo
if (addr != NULL) {
addr_len = strlen(addr);
if (addr[0] == '[' && addr[addr_len - 1] == ']') {
addr[addr_len - 1] = '\0';
addr++;
}
} else {
sa_in.sin_addr.s_addr = htonl(INADDR_ANY);
}
sa_in.sin_family = AF_INET;
sa_in.sin_port = htons(port);
memset(&hints, 0, sizeof hints);
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
if ((status = getaddrinfo(addr, port_str, &hints, &servinfo)) != 0) {
zlog(ZLOG_ERROR, "getaddrinfo: %s\n", gai_strerror(status));
return -1;
}
free(dup_address);
return fpm_sockets_get_listening_socket(wp, (struct sockaddr *) &sa_in, sizeof(struct sockaddr_in));
for (p = servinfo; p != NULL; p = p->ai_next) {
if ((sock = fpm_sockets_get_listening_socket(wp, p->ai_addr, p->ai_addrlen)) != -1) {
break;
}
}
freeaddrinfo(servinfo);
return sock;
}
/* }}} */

View File

@ -45,10 +45,4 @@ static inline int fd_set_blocked(int fd, int blocked) /* {{{ */
}
/* }}} */
#define IPQUAD(sin_addr) \
(unsigned int) ((unsigned char *) &(sin_addr)->s_addr)[0], \
(unsigned int) ((unsigned char *) &(sin_addr)->s_addr)[1], \
(unsigned int) ((unsigned char *) &(sin_addr)->s_addr)[2], \
(unsigned int) ((unsigned char *) &(sin_addr)->s_addr)[3]
#endif

View File

@ -152,6 +152,8 @@ group = @php_fpm_group@
; Valid syntaxes are:
; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific address on
; a specific port;
; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on
; a specific port;
; 'port' - to listen on a TCP socket to all addresses on a
; specific port;
; '/path/to/unix/socket' - to listen on a unix socket.

53
sapi/fpm/tests/003.phpt Normal file
View File

@ -0,0 +1,53 @@
--TEST--
FPM: Test IPv6 support
--SKIPIF--
<?php include "skipif.inc"; ?>
--FILE--
<?php
include "include.inc";
$logfile = dirname(__FILE__).'/php-fpm.log.tmp';
$cfg = <<<EOT
[global]
error_log = $logfile
[unconfined]
listen = [::1]:9000
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
EOT;
$fpm = run_fpm($cfg, $tail);
if (is_resource($fpm)) {
var_dump(fgets($tail));
var_dump(fgets($tail));
$i = 0;
while (($i++ < 30) && !($fp = fsockopen('[::1]', 9000))) {
usleep(10000);
}
if ($fp) {
echo "Done\n";
fclose($fp);
}
proc_terminate($fpm);
stream_get_contents($tail);
fclose($tail);
proc_close($fpm);
}
?>
--EXPECTF--
string(%d) "[%d-%s-%d %d:%d:%d] NOTICE: fpm is running, pid %d
"
string(%d) "[%d-%s-%d %d:%d:%d] NOTICE: ready to handle connections
"
Done
--CLEAN--
<?php
$logfile = dirname(__FILE__).'/php-fpm.log.tmp';
@unlink($logfile);
?>

View File

@ -69,7 +69,7 @@
#define SAPI_LSAPI_MAX_HEADER_LENGTH 2048
static int lsapi_mode = 1;
static int lsapi_mode = 0;
static char *php_self = "";
static char *script_filename = "";
static int source_highlight = 0;
@ -1053,6 +1053,7 @@ int main( int argc, char * argv[] )
LSAPI_Init();
LSAPI_Init_Env_Parameters( NULL );
lsapi_mode = 1;
slow_script_msec = LSAPI_Get_Slow_Req_Msecs();