diff options
74 files changed, 1088 insertions, 198 deletions
diff --git a/.gitattributes b/.gitattributes index 79b218fcba..091043a35b 100644 --- a/.gitattributes +++ b/.gitattributes @@ -22,6 +22,10 @@ sapi/nsapi/nsapi.c ident sapi/continuity/capi.c ident Zend/RFCs/002.txt ident Zend/RFCs/003.txt ident +ext/exif/exif.c ident +ext/ldap/ldap.c ident +ext/pdo_pgsql/pdo_pgsql.c ident +ext/tidy/tidy.c ident NEWS merge=NEWS UPGRADING merge=NEWS UPGRADING.INTERNALS merge=NEWS diff --git a/.travis.yml b/.travis.yml index 8c72df9180..2125e8d3d6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,9 @@ notifications: email: on_failure: change +cache: + - apt + env: global: - MYSQL_TEST_HOST=127.0.0.1 @@ -21,6 +24,12 @@ env: - ENABLE_MAINTAINER_ZTS=0 ENABLE_DEBUG=0 - ENABLE_MAINTAINER_ZTS=1 ENABLE_DEBUG=1 +before_install: + - sudo apt-get update -qq + - sudo apt-get install -y libenchant-dev libaspell-dev libpspell-dev librecode-dev + - sudo cp ./travis/de /var/lib/locales/supported.d/de + - sudo dpkg-reconfigure locales + before_script: # Compile PHP - ./travis/compile.sh @@ -2,17 +2,74 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? ??? 2014, PHP 5.6.0 Release Candidate 3 +- Core: + . Fixed bug #67497 (eval with parse error causes segmentation fault in + generator). (Nikita) + . Fixed bug #67151 (strtr with empty array crashes). (Nikita) + . Fixed bug #67407 (Windows 8.1/Server 2012 R2 reported as Windows 8/Server + 2012). (Christian Wenz) + . Fixed bug #66608 (Incorrect behavior with nested "finally" blocks). + (Laruence, Dmitry) + . Implemented FR #34407 (ucwords and Title Case). (Tjerk) + +- CLI server: + . Fixed bug #66830 (Empty header causes PHP built-in web server to hang). + (Adam) + . Fixed bug #67594 (Unable to access to apache_request_headers() elements). + (Tjerk) + +- FPM: + . Fixed bug #67530 (error_log=syslog ignored). (Remi) + . Fixed bug #67635 (php links to systemd libraries without using pkg-config). + (pacho@gentoo.org, Remi) + +- Intl: + . Fixed bug #66921 (Wrong argument type hint for function + intltz_from_date_time_zone). (Stas) + . Fixed bug #67052 (NumberFormatter::parse() resets LC_NUMERIC setting). + (Stas) + +- pgsql: + . Fixed bug #67555 (Cannot build against libpq 7.3). (Adam) + +- OpenSSL: + . Fixed bug #67609 (TLS connections fail behind HTTP proxy). (Daniel Lowrey) + . Fixed broken build against OpenSSL older than 0.9.8 where ECDH unavailable. + (Lior Kaplan) + +- Phar: + . Fixed bug #67587 (Redirection loop on nginx with FPM). (Christian Weiske) + +- SPL: + . Fixed bug #67539 (ArrayIterator use-after-free due to object change during + sorting). (research at insighti dot org, Laruence) + . Fixed bug #67538 (SPL Iterators use-after-free). (CVE-2014-4670) (Laruence) + +- Session: + . Fixed bug #66827 (Session raises E_NOTICE when session name variable is array). + (Yasuo) + +- OPCache: + . Fixed bug #67215 (php-cgi work with opcache, may be segmentation fault + happen) (Dmitry, Laruence) + +- phpdbg + . Fixed bug #67575 (Compilation fails for phpdbg when the + build directory != src directory). (Andy Thompson) + 03 Jul 2014, PHP 5.6.0 Release Candidate 2 - Core: + . Fixed bug #67091 (make install fails to install libphp5.so on FreeBSD 10.0). + (Ferenc) . Fixed bug #67368 (Memory leak with immediately dereferenced array in class constant). (Laruence) . Fixed bug #67468 (Segfault in highlight_file()/highlight_string()). (Andreas Ferber) - . Fixed bug #67091 (make install fails to install libphp5.so on FreeBSD 10.0). - (Ferenc) . Fixed bug #67498 (phpinfo() Type Confusion Information Leak Vulnerability). (Stefan Esser) + . Fixed bug #67551 (php://input temp file will be located in sys_temp_dir + instead of upload_tmp_dir). (Mike) - FPM: . Fix bug #67531 (syslog cannot be set in pool configuration). (Remi) diff --git a/Zend/tests/bug66608.phpt b/Zend/tests/bug66608.phpt new file mode 100644 index 0000000000..5a499a1dab --- /dev/null +++ b/Zend/tests/bug66608.phpt @@ -0,0 +1,73 @@ +--TEST-- +Bug #66608 (Incorrect behavior with nested "finally" blocks) +--FILE-- +<?php +function bar() { + try { + echo "1\n"; + try { + } finally { + try { + } finally { + } + echo "2\n"; + } + } finally { + try { + throw new Exception (""); + } catch (Exception $ab) { + echo "3\n"; + } finally { + try { + } finally { + echo "4\n"; + try { + } finally { + } + echo "5\n"; + } + } + echo "6\n"; + try { + } finally { + while (1) { + try { + echo "7\n"; + break; + } finally { + echo "8\n"; + } + echo "bad"; + } + echo "9\n"; + while (1) { + try { + throw new Exception(""); + } catch(Exception $e) { + echo "10\n"; + break; + } finally { + echo "11\n"; + } + echo "bak\n"; + } + } + echo "12\n"; + } + echo "13\n"; +} +bar(); +--EXPECT-- +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 diff --git a/Zend/tests/constant_expressions_arrays.phpt b/Zend/tests/constant_expressions_arrays.phpt new file mode 100644 index 0000000000..061fcc6a92 --- /dev/null +++ b/Zend/tests/constant_expressions_arrays.phpt @@ -0,0 +1,35 @@ +--TEST-- +Constant expressions with arrays +--FILE-- +<?php +const a = [1,2,[3,[4]]]; +const b = a[0]; +const c = a[2][0]; +const d = a[2]; +const e = ["string" => [1]]["string"][0]; + +var_dump(b, c, e); + +function test ($a = d[1][0]) { + var_dump($a); +} + +test(); + +class foo { + const bar = [1][0]; +} + +var_dump(foo::bar); + +var_dump(a); // Eventually allow that later with array dereferencing of constants + +?> +--EXPECTF-- +int(1) +int(3) +int(1) +int(4) +int(1) + +Fatal error: Arrays are not allowed in constants at run-time in %s on line %d diff --git a/Zend/tests/constant_expressions_self_referencing_array.phpt b/Zend/tests/constant_expressions_self_referencing_array.phpt new file mode 100644 index 0000000000..09f862e048 --- /dev/null +++ b/Zend/tests/constant_expressions_self_referencing_array.phpt @@ -0,0 +1,15 @@ +--TEST-- +Self-referencing constant expression (part of a constant AST) +--XFAIL-- +Not yet fixed, to be fixed for PHP 5.6 +--FILE-- +<?php +class A { + const FOO = [self::BAR]; + const BAR = [self::FOO]; +} +var_dump(A::FOO); +?> +--EXPECTF-- +Fatal error: Cannot declare self-referencing constant 'self::FOO' in %s on line %d + diff --git a/Zend/tests/generators/bug67497.phpt b/Zend/tests/generators/bug67497.phpt new file mode 100644 index 0000000000..483857b96c --- /dev/null +++ b/Zend/tests/generators/bug67497.phpt @@ -0,0 +1,19 @@ +--TEST-- +Bug #67467: eval with parse error causes segmentation fault in generator +--FILE-- +<?php + +function gen() { + $a = 1; + yield $a; +} + +@eval('abc'); + +$values = gen(); +$values->next(); + +?> +===DONE=== +--EXPECT-- +===DONE=== diff --git a/Zend/tests/try_finally_011.phpt b/Zend/tests/try_finally_011.phpt new file mode 100644 index 0000000000..7aa3f35fee --- /dev/null +++ b/Zend/tests/try_finally_011.phpt @@ -0,0 +1,15 @@ +--TEST-- +Try finally (segfault with empty break) +--FILE-- +<?php +function foo () { + try { + break; + } finally { + } +} + +foo(); +?> +--EXPECTF-- +Fatal error: Cannot break/continue 1 level in %stry_finally_011.php on line %d diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h index c130acc35a..ab823828cf 100644 --- a/Zend/zend_compile.h +++ b/Zend/zend_compile.h @@ -868,6 +868,9 @@ int zend_add_literal(zend_op_array *op_array, const zval *zv TSRMLS_DC); #define ZEND_FAST_RET_TO_CATCH 1 #define ZEND_FAST_RET_TO_FINALLY 2 +#define ZEND_FAST_CALL_FROM_CATCH 1 +#define ZEND_FAST_CALL_FROM_FINALLY 2 + END_EXTERN_C() #define ZEND_CLONE_FUNC_NAME "__clone" diff --git a/Zend/zend_generators.c b/Zend/zend_generators.c index 7d7c330710..2b4a8c9a16 100644 --- a/Zend/zend_generators.c +++ b/Zend/zend_generators.c @@ -125,6 +125,7 @@ ZEND_API void zend_generator_close(zend_generator *generator, zend_bool finished /* A fatal error / die occurred during the generator execution. Trying to clean * up the stack may not be safe in this case. */ if (CG(unclean_shutdown)) { + generator->execute_data = NULL; return; } diff --git a/Zend/zend_opcode.c b/Zend/zend_opcode.c index ee2258f9f5..12e604598b 100644 --- a/Zend/zend_opcode.c +++ b/Zend/zend_opcode.c @@ -509,6 +509,49 @@ static void zend_check_finally_breakout(zend_op_array *op_array, zend_uint op_nu } } +static void zend_adjust_fast_call(zend_op_array *op_array, zend_uint fast_call, zend_uint start, zend_uint end TSRMLS_DC) +{ + int i; + zend_uint op_num = 0; + + for (i = 0; i < op_array->last_try_catch; i++) { + if (op_array->try_catch_array[i].finally_op > start + && op_array->try_catch_array[i].finally_end < end) { + op_num = op_array->try_catch_array[i].finally_op; + start = op_array->try_catch_array[i].finally_end; + } + } + + if (op_num) { + /* Must be ZEND_FAST_CALL */ + ZEND_ASSERT(op_array->opcodes[op_num - 2].opcode == ZEND_FAST_CALL); + op_array->opcodes[op_num - 2].extended_value = ZEND_FAST_CALL_FROM_FINALLY; + op_array->opcodes[op_num - 2].op2.opline_num = fast_call; + } +} + +static void zend_resolve_fast_call(zend_op_array *op_array, zend_uint fast_call, zend_uint op_num TSRMLS_DC) +{ + int i; + zend_uint finally_op_num = 0; + + for (i = 0; i < op_array->last_try_catch; i++) { + if (op_num >= op_array->try_catch_array[i].finally_op + && op_num < op_array->try_catch_array[i].finally_end) { + finally_op_num = op_array->try_catch_array[i].finally_op; + } + } + + if (finally_op_num) { + /* Must be ZEND_FAST_CALL */ + ZEND_ASSERT(op_array->opcodes[finally_op_num - 2].opcode == ZEND_FAST_CALL); + if (op_array->opcodes[fast_call].extended_value == 0) { + op_array->opcodes[fast_call].extended_value = ZEND_FAST_CALL_FROM_FINALLY; + op_array->opcodes[fast_call].op2.opline_num = finally_op_num - 2; + } + } +} + static void zend_resolve_finally_call(zend_op_array *op_array, zend_uint op_num, zend_uint dst_num TSRMLS_DC) { zend_uint start_op; @@ -536,11 +579,23 @@ static void zend_resolve_finally_call(zend_op_array *op_array, zend_uint op_num, opline->opcode = ZEND_FAST_CALL; SET_UNUSED(opline->op1); SET_UNUSED(opline->op2); - opline->op1.opline_num = op_array->try_catch_array[i].finally_op; + zend_adjust_fast_call(op_array, start_op, + op_array->try_catch_array[i].finally_op, + op_array->try_catch_array[i].finally_end TSRMLS_CC); if (op_array->try_catch_array[i].catch_op) { - opline->extended_value = 1; + opline->extended_value = ZEND_FAST_CALL_FROM_CATCH; opline->op2.opline_num = op_array->try_catch_array[i].catch_op; + opline->op1.opline_num = get_next_op_number(op_array); + /* generate a FAST_CALL to hole CALL_FROM_FINALLY */ + opline = get_next_op(op_array TSRMLS_CC); + opline->opcode = ZEND_FAST_CALL; + SET_UNUSED(opline->op1); + SET_UNUSED(opline->op2); + zend_resolve_fast_call(op_array, start_op + 1, op_array->try_catch_array[i].finally_op - 2 TSRMLS_CC); + } else { + zend_resolve_fast_call(op_array, start_op, op_array->try_catch_array[i].finally_op - 2 TSRMLS_CC); } + opline->op1.opline_num = op_array->try_catch_array[i].finally_op; /* generate a sequence of FAST_CALL to upward finally block */ while (i > 0) { @@ -605,10 +660,10 @@ static void zend_resolve_finally_ret(zend_op_array *op_array, zend_uint op_num T static void zend_resolve_finally_calls(zend_op_array *op_array TSRMLS_DC) { - zend_uint i; + zend_uint i, j; zend_op *opline; - for (i = 0; i < op_array->last; i++) { + for (i = 0, j = op_array->last; i < j; i++) { opline = op_array->opcodes + i; switch (opline->opcode) { case ZEND_RETURN: @@ -623,15 +678,16 @@ static void zend_resolve_finally_calls(zend_op_array *op_array TSRMLS_DC) zend_brk_cont_element *jmp_to; nest_levels = Z_IVAL(op_array->literals[opline->op2.constant].constant); - array_offset = opline->op1.opline_num; - do { - jmp_to = &op_array->brk_cont_array[array_offset]; - if (nest_levels > 1) { - array_offset = jmp_to->parent; - } - } while (--nest_levels > 0); - zend_resolve_finally_call(op_array, i, opline->opcode == ZEND_BRK ? jmp_to->brk : jmp_to->cont TSRMLS_CC); - break; + if ((array_offset = opline->op1.opline_num) != -1) { + do { + jmp_to = &op_array->brk_cont_array[array_offset]; + if (nest_levels > 1) { + array_offset = jmp_to->parent; + } + } while (--nest_levels > 0); + zend_resolve_finally_call(op_array, i, opline->opcode == ZEND_BRK ? jmp_to->brk : jmp_to->cont TSRMLS_CC); + break; + } } case ZEND_GOTO: if (Z_TYPE(op_array->literals[opline->op2.constant].constant) != IS_INT) { @@ -644,6 +700,9 @@ static void zend_resolve_finally_calls(zend_op_array *op_array TSRMLS_DC) case ZEND_JMP: zend_resolve_finally_call(op_array, i, opline->op1.opline_num TSRMLS_CC); break; + case ZEND_FAST_CALL: + zend_resolve_fast_call(op_array, i, i TSRMLS_CC); + break; case ZEND_FAST_RET: zend_resolve_finally_ret(op_array, i TSRMLS_CC); break; diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index 4cf9dd1536..7886e989e0 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -5625,13 +5625,13 @@ ZEND_VM_HANDLER(162, ZEND_FAST_CALL, ANY, ANY) { USE_OPLINE - if (opline->extended_value && + if ((opline->extended_value & ZEND_FAST_CALL_FROM_CATCH) && UNEXPECTED(EG(prev_exception) != NULL)) { /* in case of unhandled exception jump to catch block instead of finally */ ZEND_VM_SET_OPCODE(&EX(op_array)->opcodes[opline->op2.opline_num]); ZEND_VM_CONTINUE(); } - EX(fast_ret) = opline + 1; + EX(fast_ret) = opline; EX(delayed_exception) = NULL; ZEND_VM_SET_OPCODE(opline->op1.jmp_addr); ZEND_VM_CONTINUE(); @@ -5640,7 +5640,10 @@ ZEND_VM_HANDLER(162, ZEND_FAST_CALL, ANY, ANY) ZEND_VM_HANDLER(163, ZEND_FAST_RET, ANY, ANY) { if (EX(fast_ret)) { - ZEND_VM_SET_OPCODE(EX(fast_ret)); + ZEND_VM_SET_OPCODE(EX(fast_ret) + 1); + if ((EX(fast_ret)->extended_value & ZEND_FAST_CALL_FROM_FINALLY)) { + EX(fast_ret) = &EX(op_array)->opcodes[EX(fast_ret)->op2.opline_num]; + } ZEND_VM_CONTINUE(); } else { /* special case for unhandled exceptions */ diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index 22d400720f..b4eb0c47e8 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -1344,13 +1344,13 @@ static int ZEND_FASTCALL ZEND_FAST_CALL_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS) { USE_OPLINE - if (opline->extended_value && + if ((opline->extended_value & ZEND_FAST_CALL_FROM_CATCH) && UNEXPECTED(EG(prev_exception) != NULL)) { /* in case of unhandled exception jump to catch block instead of finally */ ZEND_VM_SET_OPCODE(&EX(op_array)->opcodes[opline->op2.opline_num]); ZEND_VM_CONTINUE(); } - EX(fast_ret) = opline + 1; + EX(fast_ret) = opline; EX(delayed_exception) = NULL; ZEND_VM_SET_OPCODE(opline->op1.jmp_addr); ZEND_VM_CONTINUE(); @@ -1359,7 +1359,10 @@ static int ZEND_FASTCALL ZEND_FAST_CALL_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS) static int ZEND_FASTCALL ZEND_FAST_RET_SPEC_HANDLER(ZEND_OPCODE_HANDLER_ARGS) { if (EX(fast_ret)) { - ZEND_VM_SET_OPCODE(EX(fast_ret)); + ZEND_VM_SET_OPCODE(EX(fast_ret) + 1); + if ((EX(fast_ret)->extended_value & ZEND_FAST_CALL_FROM_FINALLY)) { + EX(fast_ret) = &EX(op_array)->opcodes[EX(fast_ret)->op2.opline_num]; + } ZEND_VM_CONTINUE(); } else { /* special case for unhandled exceptions */ diff --git a/ext/filter/tests/bug49184.phpt b/ext/filter/tests/bug49184.phpt new file mode 100644 index 0000000000..86d35db0d5 --- /dev/null +++ b/ext/filter/tests/bug49184.phpt @@ -0,0 +1,22 @@ +--TEST-- +Bug #67296 (filter_input doesn't validate variables) +--XFAIL-- +See Bug #49184 +--SKIPIF-- +<?php if (!extension_loaded("filter")) die("skip needs filter ext"); ?> +--ENV-- +return <<<END +HTTP_X_FORWARDED_FOR=example.com +END; +--FILE-- +<?php + var_dump(filter_input(INPUT_SERVER, "HTTP_X_FORWARDED_FOR", FILTER_UNSAFE_RAW)); + var_dump($_SERVER["HTTP_X_FORWARDED_FOR"]); + var_dump(getenv("HTTP_X_FORWARDED_FOR")); + var_dump("done"); +?> +--EXPECT-- +string(11) "example.com" +string(11) "example.com" +string(11) "example.com" +string(4) "done" diff --git a/ext/ftp/tests/bug37799.phpt b/ext/ftp/tests/bug37799.phpt index bc9ce002a8..7636081a4e 100644 --- a/ext/ftp/tests/bug37799.phpt +++ b/ext/ftp/tests/bug37799.phpt @@ -18,5 +18,5 @@ var_dump(ftp_login($ftp, 'user', 'pass')); ftp_close($ftp); ?> --EXPECTF-- -Warning: ftp_login(): bogus msg in %sbug37799.php on line 8 +Warning: ftp_login(): %rdummy|bogus msg%r in %sbug37799.php on line 8 bool(false) diff --git a/ext/intl/formatter/formatter_parse.c b/ext/intl/formatter/formatter_parse.c index 699feef18a..4aa6eabf6f 100644 --- a/ext/intl/formatter/formatter_parse.c +++ b/ext/intl/formatter/formatter_parse.c @@ -73,7 +73,9 @@ PHP_FUNCTION( numfmt_parse ) } #if ICU_LOCALE_BUG && defined(LC_NUMERIC) - oldlocale = setlocale(LC_NUMERIC, "C"); + /* need to copy here since setlocale may change it later */ + oldlocale = estrdup(setlocale(LC_NUMERIC, NULL)); + setlocale(LC_NUMERIC, "C"); #endif switch(type) { @@ -100,6 +102,7 @@ PHP_FUNCTION( numfmt_parse ) } #if ICU_LOCALE_BUG && defined(LC_NUMERIC) setlocale(LC_NUMERIC, oldlocale); + efree(oldlocale); #endif if(zposition) { zval_dtor(zposition); diff --git a/ext/intl/php_intl.c b/ext/intl/php_intl.c index 219172707f..c01d3b220d 100644 --- a/ext/intl/php_intl.c +++ b/ext/intl/php_intl.c @@ -445,7 +445,7 @@ ZEND_BEGIN_ARG_INFO_EX( arginfo_tz_idarg_static, 0, 0, 1 ) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX( arginfo_tz_from_date_time_zone, 0, 0, 1 ) - ZEND_ARG_OBJ_INFO( 0, dateTimeZone, IntlDateTimeZone, 0 ) + ZEND_ARG_OBJ_INFO( 0, dateTimeZone, DateTimeZone, 0 ) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX( arginfo_tz_create_enumeration, 0, 0, 0 ) diff --git a/ext/intl/tests/bug14562.phpt b/ext/intl/tests/bug14562.phpt index 3256268405..7cf927f7e7 100644 --- a/ext/intl/tests/bug14562.phpt +++ b/ext/intl/tests/bug14562.phpt @@ -15,6 +15,7 @@ function ut_main() setlocale(LC_ALL, $de_locale); $fmt = new NumberFormatter("de", NumberFormatter::DECIMAL ); $numeric = $fmt->parse("1234,56"); + setlocale(LC_ALL, "C"); // reset for printing $res_str .= "$numeric\n"; return $res_str; } diff --git a/ext/intl/tests/bug66921.phpt b/ext/intl/tests/bug66921.phpt new file mode 100644 index 0000000000..58ae9c0f82 --- /dev/null +++ b/ext/intl/tests/bug66921.phpt @@ -0,0 +1,15 @@ +--TEST-- +Bug #66921 - Wrong argument type hint for function intltz_from_date_time_zone +--SKIPIF-- +<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?> +--FILE-- +<?php +$f = new ReflectionFunction('intltz_from_date_time_zone'); +var_dump($f->getParameters()[0]->getClass()); + +?> +--EXPECTF-- +object(ReflectionClass)#%d (1) { + ["name"]=> + string(12) "DateTimeZone" +} diff --git a/ext/intl/tests/bug67052.phpt b/ext/intl/tests/bug67052.phpt new file mode 100644 index 0000000000..c8363b9c7a --- /dev/null +++ b/ext/intl/tests/bug67052.phpt @@ -0,0 +1,25 @@ +--TEST-- +Bug #67052 - NumberFormatter::parse() resets LC_NUMERIC setting +--SKIPIF-- +<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?> +--FILE-- +<?php + +function ut_main() +{ + setlocale(LC_ALL, 'de_DE'); + $fmt = new NumberFormatter( 'sl_SI.UTF-8', NumberFormatter::DECIMAL); + $num = "1.234.567,891"; + $res_str = $fmt->parse($num)."\n"; + $res_str .= setlocale(LC_NUMERIC, 0); + return $res_str; +} + +include_once( 'ut_common.inc' ); +ut_run(); + +?> +--EXPECT-- +1234567,891 +de_DE + diff --git a/ext/intl/tests/collator_get_locale.phpt b/ext/intl/tests/collator_get_locale.phpt index 68440f3ee7..e71a020b4b 100644 --- a/ext/intl/tests/collator_get_locale.phpt +++ b/ext/intl/tests/collator_get_locale.phpt @@ -3,6 +3,8 @@ get_locale() icu <= 4.2 --SKIPIF-- <?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?> <?php if(version_compare(INTL_ICU_VERSION, '4.3', '<') != 1) print 'skip'; ?> +--INI-- +precision=6 --FILE-- <?php diff --git a/ext/mysqli/mysqli.c b/ext/mysqli/mysqli.c index a475e78468..05f39f5cc5 100644 --- a/ext/mysqli/mysqli.c +++ b/ext/mysqli/mysqli.c @@ -715,6 +715,10 @@ PHP_MINIT_FUNCTION(mysqli) REGISTER_INT_CONSTANT("MYSQLI_CLIENT_IGNORE_SPACE", CLIENT_IGNORE_SPACE, CONST_CS | CONST_PERSISTENT); REGISTER_INT_CONSTANT("MYSQLI_CLIENT_NO_SCHEMA", CLIENT_NO_SCHEMA, CONST_CS | CONST_PERSISTENT); REGISTER_INT_CONSTANT("MYSQLI_CLIENT_FOUND_ROWS", CLIENT_FOUND_ROWS, CONST_CS | CONST_PERSISTENT); +#if (MYSQL_VERSION_ID >= 50611 && defined(CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS)) || defined(MYSQLI_USE_MYSQLND) + REGISTER_INT_CONSTANT("MYSQLI_CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS", CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS, CONST_CS | CONST_PERSISTENT); + REGISTER_INT_CONSTANT("MYSQLI_OPT_CAN_HANDLE_EXPIRED_PASSWORDS", MYSQL_OPT_CAN_HANDLE_EXPIRED_PASSWORDS, CONST_CS | CONST_PERSISTENT); +#endif /* for mysqli_query */ REGISTER_INT_CONSTANT("MYSQLI_STORE_RESULT", MYSQLI_STORE_RESULT, CONST_CS | CONST_PERSISTENT); @@ -848,10 +852,6 @@ PHP_MINIT_FUNCTION(mysqli) REGISTER_INT_CONSTANT("MYSQLI_REFRESH_BACKUP_LOG", REFRESH_BACKUP_LOG, CONST_CS | CONST_PERSISTENT); #endif -#if (MYSQL_VERSION_ID >= 50611 && defined(CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS)) || defined(MYSQLI_USE_MYSQLND) - REGISTER_INT_CONSTANT("MYSQLI_OPT_CAN_HANDLE_EXPIRED_PASSWORDS", MYSQL_OPT_CAN_HANDLE_EXPIRED_PASSWORDS, CONST_CS | CONST_PERSISTENT); -#endif - REGISTER_INT_CONSTANT("MYSQLI_TRANS_START_WITH_CONSISTENT_SNAPSHOT", TRANS_START_WITH_CONSISTENT_SNAPSHOT, CONST_CS | CONST_PERSISTENT); REGISTER_INT_CONSTANT("MYSQLI_TRANS_START_READ_WRITE", TRANS_START_READ_WRITE, CONST_CS | CONST_PERSISTENT); REGISTER_INT_CONSTANT("MYSQLI_TRANS_START_READ_ONLY", TRANS_START_READ_ONLY, CONST_CS | CONST_PERSISTENT); diff --git a/ext/mysqli/tests/mysqli_constants.phpt b/ext/mysqli/tests/mysqli_constants.phpt index bed9d53419..9bbc8bb4b7 100644 --- a/ext/mysqli/tests/mysqli_constants.phpt +++ b/ext/mysqli/tests/mysqli_constants.phpt @@ -196,6 +196,7 @@ require_once('skipifconnectfailure.inc'); if (($IS_MYSQLND && version_compare(PHP_VERSION, ' 5.4.12-dev', '>=')) || (!$IS_MYSQLND && ($version > 50610))) { /* could be that MySQL/libmysql 5.6.9 had the flag already but it was no stable release */ $expected_constants["MYSQLI_OPT_CAN_HANDLE_EXPIRED_PASSWORDS"] = true; + $expected_constants["MYSQLI_CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS"] = true; } $unexpected_constants = array(); diff --git a/ext/mysqlnd/mysqlnd.c b/ext/mysqlnd/mysqlnd.c index 625d1112b4..6a35b90509 100644 --- a/ext/mysqlnd/mysqlnd.c +++ b/ext/mysqlnd/mysqlnd.c @@ -321,6 +321,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, simple_command_send_request)(MYSQLND_CONN_DATA DBG_ENTER("mysqlnd_conn_data::simple_command_send_request"); DBG_INF_FMT("command=%s silent=%u", mysqlnd_command_to_text[command], silent); DBG_INF_FMT("conn->server_status=%u", conn->upsert_status->server_status); + DBG_INF_FMT("sending %u bytes", arg_len + 1); /* + 1 is for the command */ switch (CONN_GET_STATE(conn)) { case CONN_READY: @@ -448,6 +449,31 @@ mysqlnd_switch_to_ssl_if_needed( const MYSQLND_CHARSET * charset; MYSQLND_PACKET_AUTH * auth_packet; DBG_ENTER("mysqlnd_switch_to_ssl_if_needed"); + DBG_INF_FMT("client_capability_flags=%lu", mysql_flags); + DBG_INF_FMT("CLIENT_LONG_PASSWORD= %d", mysql_flags & CLIENT_LONG_PASSWORD? 1:0); + DBG_INF_FMT("CLIENT_FOUND_ROWS= %d", mysql_flags & CLIENT_FOUND_ROWS? 1:0); + DBG_INF_FMT("CLIENT_LONG_FLAG= %d", mysql_flags & CLIENT_LONG_FLAG? 1:0); + DBG_INF_FMT("CLIENT_NO_SCHEMA= %d", mysql_flags & CLIENT_NO_SCHEMA? 1:0); + DBG_INF_FMT("CLIENT_COMPRESS= %d", mysql_flags & CLIENT_COMPRESS? 1:0); + DBG_INF_FMT("CLIENT_ODBC= %d", mysql_flags & CLIENT_ODBC? 1:0); + DBG_INF_FMT("CLIENT_LOCAL_FILES= %d", mysql_flags & CLIENT_LOCAL_FILES? 1:0); + DBG_INF_FMT("CLIENT_IGNORE_SPACE= %d", mysql_flags & CLIENT_IGNORE_SPACE? 1:0); + DBG_INF_FMT("CLIENT_PROTOCOL_41= %d", mysql_flags & CLIENT_PROTOCOL_41? 1:0); + DBG_INF_FMT("CLIENT_INTERACTIVE= %d", mysql_flags & CLIENT_INTERACTIVE? 1:0); + DBG_INF_FMT("CLIENT_SSL= %d", mysql_flags & CLIENT_SSL? 1:0); + DBG_INF_FMT("CLIENT_IGNORE_SIGPIPE= %d", mysql_flags & CLIENT_IGNORE_SIGPIPE? 1:0); + DBG_INF_FMT("CLIENT_TRANSACTIONS= %d", mysql_flags & CLIENT_TRANSACTIONS? 1:0); + DBG_INF_FMT("CLIENT_RESERVED= %d", mysql_flags & CLIENT_RESERVED? 1:0); + DBG_INF_FMT("CLIENT_SECURE_CONNECTION=%d", mysql_flags & CLIENT_SECURE_CONNECTION? 1:0); + DBG_INF_FMT("CLIENT_MULTI_STATEMENTS=%d", mysql_flags & CLIENT_MULTI_STATEMENTS? 1:0); + DBG_INF_FMT("CLIENT_MULTI_RESULTS= %d", mysql_flags & CLIENT_MULTI_RESULTS? 1:0); + DBG_INF_FMT("CLIENT_PS_MULTI_RESULTS=%d", mysql_flags & CLIENT_PS_MULTI_RESULTS? 1:0); + DBG_INF_FMT("CLIENT_CONNECT_ATTRS= %d", mysql_flags & CLIENT_PLUGIN_AUTH? 1:0); + DBG_INF_FMT("CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA= %d", mysql_flags & CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA? 1:0); + DBG_INF_FMT("CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS= %d", mysql_flags & CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS? 1:0); + DBG_INF_FMT("CLIENT_SESSION_TRACK= %d", mysql_flags & CLIENT_SESSION_TRACK? 1:0); + DBG_INF_FMT("CLIENT_SSL_VERIFY_SERVER_CERT= %d", mysql_flags & CLIENT_SSL_VERIFY_SERVER_CERT? 1:0); + DBG_INF_FMT("CLIENT_REMEMBER_OPTIONS= %d", mysql_flags & CLIENT_REMEMBER_OPTIONS? 1:0); auth_packet = conn->protocol->m.get_auth_packet(conn->protocol, FALSE TSRMLS_CC); if (!auth_packet) { @@ -1863,6 +1889,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, send_close)(MYSQLND_CONN_DATA * const conn TSR enum_func_status ret = PASS; MYSQLND_NET * net = conn->net; php_stream * net_stream = net->data->m.get_stream(net TSRMLS_CC); + enum mysqlnd_connection_state state; DBG_ENTER("mysqlnd_send_close"); DBG_INF_FMT("conn=%llu net->data->stream->abstract=%p", conn->thread_id, net_stream? net_stream->abstract:NULL); @@ -1873,7 +1900,9 @@ MYSQLND_METHOD(mysqlnd_conn_data, send_close)(MYSQLND_CONN_DATA * const conn TSR MYSQLND_DEC_CONN_STATISTIC(conn->stats, STAT_OPENED_PERSISTENT_CONNECTIONS); } } - switch (CONN_GET_STATE(conn)) { + state = CONN_GET_STATE(conn); + DBG_INF_FMT("state=%u", state); + switch (state) { case CONN_READY: DBG_INF("Connection clean, sending COM_QUIT"); if (net_stream) { diff --git a/ext/mysqlnd/mysqlnd_enum_n_def.h b/ext/mysqlnd/mysqlnd_enum_n_def.h index e1fc5f8f01..3212c778a8 100644 --- a/ext/mysqlnd/mysqlnd_enum_n_def.h +++ b/ext/mysqlnd/mysqlnd_enum_n_def.h @@ -100,7 +100,9 @@ #define CLIENT_CONNECT_ATTRS (1UL << 20) /* Client supports connection attributes */ #define CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA (1UL << 21) /* Enable authentication response packet to be larger than 255 bytes. */ #define CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS (1UL << 22) /* Don't close the connection for a connection with expired password. */ -#define CLIENT_SSL_VERIFY_SERVER_CERT (1UL << 30) +#define CLIENT_SESSION_TRACK (1UL << 23) /* Extended OK */ +#define CLIENT_SSL_VERIFY_SERVER_CERT (1UL << 30) +#define CLIENT_REMEMBER_OPTIONS (1UL << 31) #define MYSQLND_CAPABILITIES (CLIENT_LONG_PASSWORD | CLIENT_LONG_FLAG | CLIENT_TRANSACTIONS | \ CLIENT_PROTOCOL_41 | CLIENT_SECURE_CONNECTION | \ @@ -214,23 +216,23 @@ typedef enum mysqlnd_protocol_type typedef enum mysqlnd_field_types { - MYSQL_TYPE_DECIMAL, - MYSQL_TYPE_TINY, - MYSQL_TYPE_SHORT, - MYSQL_TYPE_LONG, - MYSQL_TYPE_FLOAT, - MYSQL_TYPE_DOUBLE, - MYSQL_TYPE_NULL, - MYSQL_TYPE_TIMESTAMP, - MYSQL_TYPE_LONGLONG, - MYSQL_TYPE_INT24, - MYSQL_TYPE_DATE, - MYSQL_TYPE_TIME, - MYSQL_TYPE_DATETIME, - MYSQL_TYPE_YEAR, - MYSQL_TYPE_NEWDATE, - MYSQL_TYPE_VARCHAR, - MYSQL_TYPE_BIT, + MYSQL_TYPE_DECIMAL = 0, + MYSQL_TYPE_TINY = 1, + MYSQL_TYPE_SHORT = 2, + MYSQL_TYPE_LONG = 3, + MYSQL_TYPE_FLOAT = 4, + MYSQL_TYPE_DOUBLE = 5, + MYSQL_TYPE_NULL = 6, + MYSQL_TYPE_TIMESTAMP= 7, + MYSQL_TYPE_LONGLONG = 8, + MYSQL_TYPE_INT24 = 9, + MYSQL_TYPE_DATE = 10, + MYSQL_TYPE_TIME = 11, + MYSQL_TYPE_DATETIME = 12, + MYSQL_TYPE_YEAR = 13, + MYSQL_TYPE_NEWDATE = 14, + MYSQL_TYPE_VARCHAR = 15, + MYSQL_TYPE_BIT = 16, MYSQL_TYPE_NEWDECIMAL=246, MYSQL_TYPE_ENUM=247, MYSQL_TYPE_SET=248, @@ -322,23 +324,23 @@ typedef enum mysqlnd_server_option typedef enum mysqlnd_connection_state { CONN_ALLOCED = 0, - CONN_READY, - CONN_QUERY_SENT, - CONN_SENDING_LOAD_DATA, - CONN_FETCHING_DATA, - CONN_NEXT_RESULT_PENDING, - CONN_QUIT_SENT /* object is "destroyed" at this stage */ + CONN_READY = 1, + CONN_QUERY_SENT = 2, + CONN_SENDING_LOAD_DATA = 3, + CONN_FETCHING_DATA = 4, + CONN_NEXT_RESULT_PENDING = 5, + CONN_QUIT_SENT = 6 /* object is "destroyed" at this stage */ } enum_mysqlnd_connection_state; typedef enum mysqlnd_stmt_state { MYSQLND_STMT_INITTED = 0, - MYSQLND_STMT_PREPARED, - MYSQLND_STMT_EXECUTED, - MYSQLND_STMT_WAITING_USE_OR_STORE, - MYSQLND_STMT_USE_OR_STORE_CALLED, - MYSQLND_STMT_USER_FETCHING /* fetch_row_buff or fetch_row_unbuf */ + MYSQLND_STMT_PREPARED = 1, + MYSQLND_STMT_EXECUTED = 2, + MYSQLND_STMT_WAITING_USE_OR_STORE = 3, + MYSQLND_STMT_USE_OR_STORE_CALLED = 4, + MYSQLND_STMT_USER_FETCHING = 5/* fetch_row_buff or fetch_row_unbuf */ } enum_mysqlnd_stmt_state; @@ -596,9 +598,10 @@ enum php_mysqlnd_server_command COM_STMT_RESET = 26, COM_SET_OPTION = 27, COM_STMT_FETCH = 28, - COM_DAEMON, - COM_BINLOG_DUMP_GTID, - COM_RESET_CONNECTION, + COM_DAEMON = 29, + COM_BINLOG_DUMP_GTID = 30, + COM_RESET_CONNECTION = 31, + COM_STMT_EXECUTE_BATCH = 32, COM_END }; diff --git a/ext/mysqlnd/mysqlnd_net.c b/ext/mysqlnd/mysqlnd_net.c index e85c2ed661..dc4e659c44 100644 --- a/ext/mysqlnd/mysqlnd_net.c +++ b/ext/mysqlnd/mysqlnd_net.c @@ -99,6 +99,7 @@ MYSQLND_METHOD(mysqlnd_net, network_write_ex)(MYSQLND_NET * const net, const zen { size_t ret; DBG_ENTER("mysqlnd_net::network_write_ex"); + DBG_INF_FMT("sending %u bytes", count); ret = php_stream_write(net->data->m.get_stream(net TSRMLS_CC), (char *)buffer, count); DBG_RETURN(ret); } @@ -357,6 +358,10 @@ MYSQLND_METHOD(mysqlnd_net, send_ex)(MYSQLND_NET * const net, zend_uchar * const do { to_be_sent = MIN(left, MYSQLND_MAX_PACKET_SIZE); + DBG_INF_FMT("to_be_sent=%u", to_be_sent); + DBG_INF_FMT("packets_sent=%u", packets_sent); + DBG_INF_FMT("compressed_envelope_packet_no=%u", net->compressed_envelope_packet_no); + DBG_INF_FMT("packet_no=%u", net->packet_no); #ifdef MYSQLND_COMPRESSION_ENABLED if (net->data->compressed == TRUE) { /* here we need to compress the data and then write it, first comes the compressed header */ diff --git a/ext/opcache/tests/bug67215.phpt b/ext/opcache/tests/bug67215.phpt new file mode 100644 index 0000000000..e9919d1001 --- /dev/null +++ b/ext/opcache/tests/bug67215.phpt @@ -0,0 +1,28 @@ +--TEST-- +Bug #67215 (php-cgi work with opcache, may be segmentation fault happen) +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +opcache.file_update_protection=0 +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php + +$file_c = __DIR__ . "/bug67215.c.php"; +$file_p = __DIR__ . "/bug67215.p.php"; +file_put_contents($file_c, "<?php require \"$file_p\"; class c extends p {} ?>"); +file_put_contents($file_p, '<?php class p { protected $var = ""; } ?>'); +require $file_c; +$a = new c(); +require $file_c; +?> +--CLEAN-- +<?php +$file_c = __DIR__ . "/bug67215.c.php"; +$file_p = __DIR__ . "/bug67215.p.php"; +unlink($file_c); +unlink($file_p); +?> +--EXPECTF-- +Fatal error: Cannot redeclare class c in %sbug67215.c.php on line %d diff --git a/ext/opcache/zend_accelerator_util_funcs.c b/ext/opcache/zend_accelerator_util_funcs.c index d17bc99dd0..5d505b76ba 100644 --- a/ext/opcache/zend_accelerator_util_funcs.c +++ b/ext/opcache/zend_accelerator_util_funcs.c @@ -899,16 +899,11 @@ static int zend_hash_unique_copy(HashTable *target, HashTable *source, unique_co if (p->nKeyLength > 0 && p->arKey[0] == 0) { /* Mangled key */ #if ZEND_EXTENSION_API_NO >= PHP_5_3_X_API_NO - if (((zend_function*)p->pData)->common.fn_flags & ZEND_ACC_CLOSURE) { - /* update closure */ - if (zend_hash_quick_update(target, p->arKey, p->nKeyLength, p->h, p->pData, size, &t) == SUCCESS) { - if (pCopyConstructor) { - pCopyConstructor(t); - } + if (zend_hash_quick_update(target, p->arKey, p->nKeyLength, p->h, p->pData, size, &t) == SUCCESS) { + if (pCopyConstructor) { + pCopyConstructor(t); } - } else { - /* ignore and wait for runtime */ - } + } #endif } else if (!ignore_dups && zend_hash_quick_find(target, p->arKey, p->nKeyLength, p->h, &t) == SUCCESS) { *fail_data = p->pData; diff --git a/ext/openssl/xp_ssl.c b/ext/openssl/xp_ssl.c index 421c2fac5e..e6d05ce8a5 100644 --- a/ext/openssl/xp_ssl.c +++ b/ext/openssl/xp_ssl.c @@ -1164,12 +1164,14 @@ static int set_server_specific_opts(php_stream *stream, SSL_CTX *ctx TSRMLS_DC) ssl_ctx_options |= SSL_OP_SINGLE_DH_USE; } +#ifdef HAVE_ECDH if (SUCCESS == php_stream_context_get_option( stream->context, "ssl", "single_ecdh_use", &val) && zend_is_true(*val) ) { ssl_ctx_options |= SSL_OP_SINGLE_ECDH_USE; } +#endif SSL_CTX_set_options(ctx, ssl_ctx_options); diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c index 106e39135a..718dc5619c 100644 --- a/ext/pgsql/pgsql.c +++ b/ext/pgsql/pgsql.c @@ -1131,7 +1131,9 @@ PHP_MINIT_FUNCTION(pgsql) REGISTER_INT_CONSTANT("PGSQL_CONNECTION_MADE", CONNECTION_MADE, CONST_CS | CONST_PERSISTENT); REGISTER_INT_CONSTANT("PGSQL_CONNECTION_AWAITING_RESPONSE", CONNECTION_AWAITING_RESPONSE, CONST_CS | CONST_PERSISTENT); REGISTER_INT_CONSTANT("PGSQL_CONNECTION_AUTH_OK", CONNECTION_AUTH_OK, CONST_CS | CONST_PERSISTENT); +#ifdef CONNECTION_SSL_STARTUP REGISTER_INT_CONSTANT("PGSQL_CONNECTION_SSL_STARTUP", CONNECTION_SSL_STARTUP, CONST_CS | CONST_PERSISTENT); +#endif REGISTER_INT_CONSTANT("PGSQL_CONNECTION_SETENV", CONNECTION_SETENV, CONST_CS | CONST_PERSISTENT); /* For pg_connect_poll() */ REGISTER_INT_CONSTANT("PGSQL_POLLING_FAILED", PGRES_POLLING_FAILED, CONST_CS | CONST_PERSISTENT); diff --git a/ext/phar/phar_object.c b/ext/phar/phar_object.c index 5a006d7ab8..37d0fa6753 100644 --- a/ext/phar/phar_object.c +++ b/ext/phar/phar_object.c @@ -609,6 +609,7 @@ PHP_METHOD(Phar, webPhar) } if ((strlen(sapi_module.name) == sizeof("cgi-fcgi")-1 && !strncmp(sapi_module.name, "cgi-fcgi", sizeof("cgi-fcgi")-1)) + || (strlen(sapi_module.name) == sizeof("fpm-fcgi")-1 && !strncmp(sapi_module.name, "fpm-fcgi", sizeof("fpm-fcgi")-1)) || (strlen(sapi_module.name) == sizeof("cgi")-1 && !strncmp(sapi_module.name, "cgi", sizeof("cgi")-1))) { if (PG(http_globals)[TRACK_VARS_SERVER]) { diff --git a/ext/session/session.c b/ext/session/session.c index 1e1a56d84a..bb93c59793 100644 --- a/ext/session/session.c +++ b/ext/session/session.c @@ -1444,9 +1444,16 @@ PHPAPI const ps_serializer *_php_find_ps_serializer(char *name TSRMLS_DC) /* {{{ } /* }}} */ -#define PPID2SID \ - convert_to_string((*ppid)); \ - PS(id) = estrndup(Z_STRVAL_PP(ppid), Z_STRSIZE_PP(ppid)) +static void ppid2sid(zval **ppid TSRMLS_DC) { + if (Z_TYPE_PP(ppid) != IS_STRING) { + PS(id) = NULL; + PS(send_cookie) = 1; + } else { + convert_to_string((*ppid)); + PS(id) = estrndup(Z_STRVAL_PP(ppid), Z_STRSIZE_PP(ppid)); + PS(send_cookie) = 0; + } +} PHPAPI void php_session_reset_id(TSRMLS_D) /* {{{ */ { @@ -1540,9 +1547,8 @@ PHPAPI void php_session_start(TSRMLS_D) /* {{{ */ Z_TYPE_PP(data) == IS_ARRAY && zend_hash_find(Z_ARRVAL_PP(data), PS(session_name), lensess + 1, (void **) &ppid) == SUCCESS ) { - PPID2SID; + ppid2sid(ppid TSRMLS_CC); PS(apply_trans_sid) = 0; - PS(send_cookie) = 0; PS(define_sid) = 0; } @@ -1551,8 +1557,7 @@ PHPAPI void php_session_start(TSRMLS_D) /* {{{ */ Z_TYPE_PP(data) == IS_ARRAY && zend_hash_find(Z_ARRVAL_PP(data), PS(session_name), lensess + 1, (void **) &ppid) == SUCCESS ) { - PPID2SID; - PS(send_cookie) = 0; + ppid2sid(ppid TSRMLS_CC); } if (!PS(use_only_cookies) && !PS(id) && @@ -1560,8 +1565,7 @@ PHPAPI void php_session_start(TSRMLS_D) /* {{{ */ Z_TYPE_PP(data) == IS_ARRAY && zend_hash_find(Z_ARRVAL_PP(data), PS(session_name), lensess + 1, (void **) &ppid) == SUCCESS ) { - PPID2SID; - PS(send_cookie) = 0; + ppid2sid(ppid TSRMLS_CC); } } diff --git a/ext/session/tests/bug66827.phpt b/ext/session/tests/bug66827.phpt new file mode 100644 index 0000000000..4e1a4f7aea --- /dev/null +++ b/ext/session/tests/bug66827.phpt @@ -0,0 +1,12 @@ +--TEST-- +Bug #66827: Session raises E_NOTICE when session name variable is array. +--INI-- +--SKIPIF-- +<?php include('skipif.inc'); ?> +--FILE-- +<?php +$_COOKIE[session_name()] = array(); +session_start(); +echo 'OK'; +--EXPECTF-- +OK diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c index 055932b094..d62f73b55c 100644 --- a/ext/spl/spl_array.c +++ b/ext/spl/spl_array.c @@ -1742,6 +1742,7 @@ SPL_METHOD(Array, unserialize) const unsigned char *p, *s; php_unserialize_data_t var_hash; zval *pmembers, *pflags = NULL; + HashTable *aht; php_int_t flags; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S", &buf, &buf_len) == FAILURE) { @@ -1752,6 +1753,12 @@ SPL_METHOD(Array, unserialize) return; } + aht = spl_array_get_hash_table(intern, 0 TSRMLS_CC); + if (aht->nApplyCount > 0) { + zend_error(E_WARNING, "Modification of ArrayObject during sorting is prohibited"); + return; + } + /* storage */ s = p = (const unsigned char*)buf; PHP_VAR_UNSERIALIZE_INIT(var_hash); diff --git a/ext/spl/spl_dllist.c b/ext/spl/spl_dllist.c index 9b757ec7bc..5732a4213e 100644 --- a/ext/spl/spl_dllist.c +++ b/ext/spl/spl_dllist.c @@ -43,12 +43,10 @@ PHPAPI zend_class_entry *spl_ce_SplStack; #define SPL_LLIST_DELREF(elem) if(!--(elem)->rc) { \ efree(elem); \ - elem = NULL; \ } #define SPL_LLIST_CHECK_DELREF(elem) if((elem) && !--(elem)->rc) { \ efree(elem); \ - elem = NULL; \ } #define SPL_LLIST_ADDREF(elem) (elem)->rc++ @@ -916,6 +914,11 @@ SPL_METHOD(SplDoublyLinkedList, offsetUnset) llist->dtor(element TSRMLS_CC); } + if (intern->traverse_pointer == element) { + SPL_LLIST_DELREF(element); + intern->traverse_pointer = NULL; + } + zval_ptr_dtor((zval **)&element->data); element->data = NULL; diff --git a/ext/spl/tests/bug67538.phpt b/ext/spl/tests/bug67538.phpt new file mode 100644 index 0000000000..b6f3848c36 --- /dev/null +++ b/ext/spl/tests/bug67538.phpt @@ -0,0 +1,17 @@ +--TEST-- +Bug #67538 (SPL Iterators use-after-free) +--FILE-- +<?php +$list = new SplDoublyLinkedList(); +$list->push('a'); +$list->push('b'); + +$list->rewind(); +$list->offsetUnset(0); +$list->push('b'); +$list->offsetUnset(0); +$list->next(); +echo "okey"; +?> +--EXPECTF-- +okey diff --git a/ext/spl/tests/bug67539.phpt b/ext/spl/tests/bug67539.phpt new file mode 100644 index 0000000000..8bab2a8c21 --- /dev/null +++ b/ext/spl/tests/bug67539.phpt @@ -0,0 +1,15 @@ +--TEST-- +Bug #67539 (ArrayIterator use-after-free due to object change during sorting) +--FILE-- +<?php + +$it = new ArrayIterator(array_fill(0,2,'X'), 1 ); + +function badsort($a, $b) { + $GLOBALS['it']->unserialize($GLOBALS['it']->serialize()); + return TRUE; +} + +$it->uksort('badsort'); +--EXPECTF-- +Warning: Modification of ArrayObject during sorting is prohibited in %sbug67539.php on line %d diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c index b9d216a2d5..3397ae72f7 100644 --- a/ext/standard/basic_functions.c +++ b/ext/standard/basic_functions.c @@ -2296,8 +2296,9 @@ ZEND_BEGIN_ARG_INFO(arginfo_lcfirst, 0) ZEND_ARG_INFO(0, str) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO(arginfo_ucwords, 0) +ZEND_BEGIN_ARG_INFO_EX(arginfo_ucwords, 0, 0, 1) ZEND_ARG_INFO(0, str) + ZEND_ARG_INFO(0, delimiters) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_strtr, 0, 0, 2) diff --git a/ext/standard/credits.c b/ext/standard/credits.c index 433baf0c3d..6df81ca029 100644 --- a/ext/standard/credits.c +++ b/ext/standard/credits.c @@ -61,10 +61,10 @@ PHPAPI void php_print_credits(int flag TSRMLS_DC) /* {{{ */ php_info_print_table_start(); php_info_print_table_colspan_header(2, "PHP Authors"); php_info_print_table_header(2, "Contribution", "Authors"); - CREDIT_LINE("Zend Scripting Language Engine", "Andi Gutmans, Zeev Suraski, Stanislav Malyshev, Marcus Boerger, Dmitry Stogov"); + CREDIT_LINE("Zend Scripting Language Engine", "Andi Gutmans, Zeev Suraski, Stanislav Malyshev, Marcus Boerger, Dmitry Stogov, Xinchen Hui, Nikita Popov"); CREDIT_LINE("Extension Module API", "Andi Gutmans, Zeev Suraski, Andrei Zmievski"); CREDIT_LINE("UNIX Build and Modularization", "Stig Bakken, Sascha Schumann, Jani Taskinen"); - CREDIT_LINE("Windows Port", "Shane Caraveo, Zeev Suraski, Wez Furlong, Pierre-Alain Joye"); + CREDIT_LINE("Windows Port", "Shane Caraveo, Zeev Suraski, Wez Furlong, Pierre-Alain Joye, Anatol Belski"); CREDIT_LINE("Server API (SAPI) Abstraction Layer", "Andi Gutmans, Shane Caraveo, Zeev Suraski"); CREDIT_LINE("Streams Abstraction Layer", "Wez Furlong, Sara Golemon"); CREDIT_LINE("PHP Data Objects Layer", "Wez Furlong, Marcus Boerger, Sterling Hughes, George Schlossnagle, Ilia Alshanetsky"); @@ -96,7 +96,7 @@ PHPAPI void php_print_credits(int flag TSRMLS_DC) /* {{{ */ if (flag & PHP_CREDITS_DOCS) { php_info_print_table_start(); php_info_print_table_colspan_header(2, "PHP Documentation"); - CREDIT_LINE("Authors", "Mehdi Achour, Friedhelm Betz, Antony Dovgal, Nuno Lopes, Hannes Magnusson, Georg Richter, Damien Seguy, Jakub Vrana"); + CREDIT_LINE("Authors", "Mehdi Achour, Friedhelm Betz, Antony Dovgal, Nuno Lopes, Hannes Magnusson, Georg Richter, Damien Seguy, Jakub Vrana, Adam Harvey, Peter Cowburn"); CREDIT_LINE("Editor", "Philip Olson"); CREDIT_LINE("User Note Maintainers", "Daniel P. Brown, Thiago Henrique Pojda"); CREDIT_LINE("Other Contributors", "Previously active authors, editors and other contributors are listed in the manual."); @@ -106,7 +106,7 @@ PHPAPI void php_print_credits(int flag TSRMLS_DC) /* {{{ */ if (flag & PHP_CREDITS_QA) { php_info_print_table_start(); php_info_print_table_header(1, "PHP Quality Assurance Team"); - php_info_print_table_row(1, "Ilia Alshanetsky, Joerg Behrens, Antony Dovgal, Stefan Esser, Moriyoshi Koizumi, Magnus Maatta, Sebastian Nohn, Derick Rethans, Melvyn Sopacua, Jani Taskinen, Pierre-Alain Joye, Dmitry Stogov, Felipe Pena, David Soria Parra"); + php_info_print_table_row(1, "Ilia Alshanetsky, Joerg Behrens, Antony Dovgal, Stefan Esser, Moriyoshi Koizumi, Magnus Maatta, Sebastian Nohn, Derick Rethans, Melvyn Sopacua, Jani Taskinen, Pierre-Alain Joye, Dmitry Stogov, Felipe Pena, David Soria Parra, Stanislav Malyshev, Julien Pauli, Stephen Zarkos, Anatol Belski, Remi Collet, Ferenc Kovacs"); php_info_print_table_end(); } @@ -116,7 +116,7 @@ PHPAPI void php_print_credits(int flag TSRMLS_DC) /* {{{ */ php_info_print_table_start(); php_info_print_table_colspan_header(2, "Websites and Infrastructure team"); /* www., wiki., windows., master., and others, I guess pecl. too? */ - CREDIT_LINE("PHP Websites Team", "Rasmus Lerdorf, Hannes Magnusson, Philip Olson, Lukas Kahwe Smith, Pierre-Alain Joye, Kalle Sommer Nielsen"); + CREDIT_LINE("PHP Websites Team", "Rasmus Lerdorf, Hannes Magnusson, Philip Olson, Lukas Kahwe Smith, Pierre-Alain Joye, Kalle Sommer Nielsen, Peter Cowburn, Adam Harvey, Ferenc Kovacs, Levi Morrison"); CREDIT_LINE("Event Maintainers", "Damien Seguy, Daniel P. Brown"); /* Mirroring */ CREDIT_LINE("Network Infrastructure", "Daniel P. Brown"); diff --git a/ext/standard/http_fopen_wrapper.c b/ext/standard/http_fopen_wrapper.c index 9d07eba9ae..9011e0468d 100644 --- a/ext/standard/http_fopen_wrapper.c +++ b/ext/standard/http_fopen_wrapper.c @@ -120,7 +120,7 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, char *scratch = NULL; char *tmp = NULL; char *ua_str = NULL; - zval **ua_zval = NULL, **tmpzval = NULL; + zval **ua_zval = NULL, **tmpzval = NULL, *ssl_proxy_peer_name = NULL; php_size_t scratch_len = 0; int body = 0; char location[HTTP_HEADER_BLOCK_SIZE]; @@ -226,6 +226,13 @@ php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, if (stream && use_proxy && use_ssl) { smart_str header = {0}; + /* Set peer_name or name verification will try to use the proxy server name */ + if (!context || php_stream_context_get_option(context, "ssl", "peer_name", &tmpzval) == FAILURE) { + MAKE_STD_ZVAL(ssl_proxy_peer_name); + ZVAL_STRING(ssl_proxy_peer_name, resource->host, 1); + php_stream_context_set_option(stream->context, "ssl", "peer_name", ssl_proxy_peer_name); + } + smart_str_appendl(&header, "CONNECT ", sizeof("CONNECT ")-1); smart_str_appends(&header, resource->host); smart_str_appendc(&header, ':'); @@ -316,7 +323,7 @@ finish: /* enable SSL transport layer */ if (stream) { - if (php_stream_xport_crypto_setup(stream, STREAM_CRYPTO_METHOD_SSLv23_CLIENT, NULL TSRMLS_CC) < 0 || + if (php_stream_xport_crypto_setup(stream, STREAM_CRYPTO_METHOD_ANY_CLIENT, NULL TSRMLS_CC) < 0 || php_stream_xport_crypto_enable(stream, 1 TSRMLS_CC) < 0) { php_stream_wrapper_log_error(wrapper, options TSRMLS_CC, "Cannot connect to HTTPS server through proxy"); php_stream_close(stream); diff --git a/ext/standard/info.c b/ext/standard/info.c index 0f96fc9f71..adc3e267be 100644 --- a/ext/standard/info.c +++ b/ext/standard/info.c @@ -335,11 +335,37 @@ char* php_get_windows_name() major = "Windows Server 2008 R2"; } } else if ( osvi.dwMinorVersion == 2 ) { - if( osvi.wProductType == VER_NT_WORKSTATION ) { - major = "Windows 8"; + /* could be Windows 8/Windows Server 2012, could be Windows 8.1/Windows Server 2012 R2 */ + OSVERSIONINFOEX osvi81; + DWORDLONG dwlConditionMask = 0; + int op = VER_GREATER_EQUAL; + + ZeroMemory(&osvi81, sizeof(OSVERSIONINFOEX)); + osvi81.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); + osvi81.dwMajorVersion = 6; + osvi81.dwMinorVersion = 3; + osvi81.wServicePackMajor = 0; + + VER_SET_CONDITION(dwlConditionMask, VER_MAJORVERSION, op); + VER_SET_CONDITION(dwlConditionMask, VER_MINORVERSION, op); + VER_SET_CONDITION(dwlConditionMask, VER_SERVICEPACKMAJOR, op); + + if (VerifyVersionInfo(&osvi81, + VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR, + dwlConditionMask)) { + osvi.dwMinorVersion = 3; /* Windows 8.1/Windows Server 2012 R2 */ + if( osvi.wProductType == VER_NT_WORKSTATION ) { + major = "Windows 8.1"; + } else { + major = "Windows Server 2012 R2"; + } } else { - major = "Windows Server 2012"; - } + if( osvi.wProductType == VER_NT_WORKSTATION ) { + major = "Windows 8"; + } else { + major = "Windows Server 2012"; + } + } } else { major = "Unknown Windows version"; } diff --git a/ext/standard/php_fopen_wrapper.c b/ext/standard/php_fopen_wrapper.c index 9d6b4eafe7..bf4a62ff2b 100644 --- a/ext/standard/php_fopen_wrapper.c +++ b/ext/standard/php_fopen_wrapper.c @@ -231,7 +231,7 @@ php_stream * php_stream_url_wrap_php(php_stream_wrapper *wrapper, const char *pa if ((input->body = SG(request_info).request_body)) { php_stream_rewind(input->body); } else { - input->body = php_stream_temp_create(TEMP_STREAM_DEFAULT, SAPI_POST_BLOCK_SIZE); + input->body = php_stream_temp_create_ex(TEMP_STREAM_DEFAULT, SAPI_POST_BLOCK_SIZE, PG(upload_tmp_dir)); SG(request_info).request_body = input->body; } diff --git a/ext/standard/string.c b/ext/standard/string.c index c47b144119..60ab8e44a8 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -2737,11 +2737,12 @@ PHP_FUNCTION(lcfirst) Uppercase the first character of every word in a string */ PHP_FUNCTION(ucwords) { - char *str; + char *str, *delims = " \t\r\n\f\v"; register char *r, *r_end; - php_size_t str_len; + php_size_t str_len, delims_len = 6; + char mask[256]; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S", &str, &str_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S|S", &str, &str_len, &delims, &delims_len) == FAILURE) { return; } @@ -2749,12 +2750,14 @@ PHP_FUNCTION(ucwords) RETURN_EMPTY_STRING(); } + php_charmask((unsigned char *)delims, delims_len, mask TSRMLS_CC); + ZVAL_STRINGL(return_value, str, str_len, 1); r = Z_STRVAL_P(return_value); *r = toupper((unsigned char) *r); for (r_end = r + Z_STRSIZE_P(return_value) - 1; r < r_end; ) { - if (isspace((int) *(unsigned char *)r++)) { + if (mask[(unsigned char)*r++]) { *r = toupper((unsigned char) *r); } } @@ -3099,6 +3102,10 @@ static void php_strtr_array(zval *return_value, char *str, php_size_t slen, Hash php_size_t patterns_len; zend_llist *allocs; + if (zend_hash_num_elements(pats) == 0) { + RETURN_STRINGL(str, slen, 1); + } + S(&text) = str; L(&text) = slen; diff --git a/ext/standard/tests/strings/bug67151.phpt b/ext/standard/tests/strings/bug67151.phpt new file mode 100644 index 0000000000..1d0c02a52d --- /dev/null +++ b/ext/standard/tests/strings/bug67151.phpt @@ -0,0 +1,8 @@ +--TEST-- +Buf #67151: strtr with empty array crashes +--FILE-- +<?php +var_dump(strtr("foo", [])); +?> +--EXPECT-- +string(3) "foo" diff --git a/ext/standard/tests/strings/ucwords_error.phpt b/ext/standard/tests/strings/ucwords_error.phpt index d79e569cc7..a01c688c4a 100644 --- a/ext/standard/tests/strings/ucwords_error.phpt +++ b/ext/standard/tests/strings/ucwords_error.phpt @@ -18,7 +18,7 @@ echo "\n-- Testing ucwords() function with more than expected no. of arguments - $str = 'string_val'; $extra_arg = 10; -var_dump( ucwords($str, $extra_arg) ); +var_dump( ucwords($str, $extra_arg, $extra_arg) ); // check if there were any changes made to $str var_dump($str); @@ -30,12 +30,12 @@ echo "Done\n"; -- Testing ucwords() function with Zero arguments -- -Warning: ucwords() expects exactly 1 parameter, 0 given in %s on line %d +Warning: ucwords() expects at least 1 parameter, 0 given in %s on line %d NULL -- Testing ucwords() function with more than expected no. of arguments -- -Warning: ucwords() expects exactly 1 parameter, 2 given in %s on line %d +Warning: ucwords() expects at most 2 parameters, 3 given in %s on line %d NULL string(10) "string_val" Done diff --git a/ext/standard/tests/strings/ucwords_variation5.phpt b/ext/standard/tests/strings/ucwords_variation5.phpt new file mode 100644 index 0000000000..985df47c4a --- /dev/null +++ b/ext/standard/tests/strings/ucwords_variation5.phpt @@ -0,0 +1,25 @@ +--TEST-- +Test ucwords() function : usage variations - custom delimiters +--FILE-- +<?php +/* Prototype : string ucwords ( string $str ) + * Description: Uppercase the first character of each word in a string + * Source code: ext/standard/string.c +*/ + +echo "*** Testing ucwords() : usage variations ***\n"; + +var_dump(ucwords('testing-dashed-words', '-')); +var_dump(ucwords('test(braced)words', '()')); +var_dump(ucwords('testing empty delimiters', '')); +var_dump(ucwords('testing ranges', 'a..e')); + +echo "Done\n"; +?> +--EXPECTF-- +*** Testing ucwords() : usage variations *** +string(%d) "Testing-Dashed-Words" +string(%d) "Test(Braced)Words" +string(%d) "Testing empty delimiters" +string(%d) "TeSting raNgeS" +Done diff --git a/ext/zlib/tests/bug65391.phpt b/ext/zlib/tests/bug65391.phpt index 439473fc5d..9d9fd164f6 100644 --- a/ext/zlib/tests/bug65391.phpt +++ b/ext/zlib/tests/bug65391.phpt @@ -6,6 +6,8 @@ extension_loaded("zlib") or die("skip need zlib"); ?> --GET-- dummy=1 +--INI-- +expose_php=On --FILE-- <?php header("Vary: Cookie"); diff --git a/main/SAPI.c b/main/SAPI.c index f286560ffb..5fc11fd8b7 100644 --- a/main/SAPI.c +++ b/main/SAPI.c @@ -279,7 +279,7 @@ SAPI_API SAPI_POST_READER_FUNC(sapi_read_standard_form_data) } - SG(request_info).request_body = php_stream_temp_create(TEMP_STREAM_DEFAULT, SAPI_POST_BLOCK_SIZE); + SG(request_info).request_body = php_stream_temp_create_ex(TEMP_STREAM_DEFAULT, SAPI_POST_BLOCK_SIZE, PG(upload_tmp_dir)); if (sapi_module.read_post) { int read_bytes; diff --git a/main/php_content_types.c b/main/php_content_types.c index bc42c8094b..ca47e15285 100644 --- a/main/php_content_types.c +++ b/main/php_content_types.c @@ -64,6 +64,12 @@ SAPI_API SAPI_POST_READER_FUNC(php_default_post_reader) length = php_stream_copy_to_mem(SG(request_info).request_body, &data, PHP_STREAM_COPY_ALL, 0); php_stream_rewind(SG(request_info).request_body); + if (length > INT_MAX) { + sapi_module.sapi_error(E_WARNING, + "HTTP_RAW_POST_DATA truncated from %lu to %d bytes", + (unsigned long) length, INT_MAX); + length = INT_MAX; + } SET_VAR_STRINGL("HTTP_RAW_POST_DATA", data, length); sapi_module.sapi_error(E_DEPRECATED, diff --git a/main/php_memory_streams.h b/main/php_memory_streams.h index 3c4c3280eb..229ed1902e 100644 --- a/main/php_memory_streams.h +++ b/main/php_memory_streams.h @@ -36,6 +36,7 @@ #define php_stream_temp_new() php_stream_temp_create(TEMP_STREAM_DEFAULT, PHP_STREAM_MAX_MEM) #define php_stream_temp_create(mode, max_memory_usage) _php_stream_temp_create((mode), (max_memory_usage) STREAMS_CC TSRMLS_CC) +#define php_stream_temp_create_ex(mode, max_memory_usage, tmpdir) _php_stream_temp_create_ex((mode), (max_memory_usage), (tmpdir) STREAMS_CC TSRMLS_CC) #define php_stream_temp_create_rel(mode, max_memory_usage) _php_stream_temp_create((mode), (max_memory_usage) STREAMS_REL_CC TSRMLS_CC) #define php_stream_temp_open(mode, max_memory_usage, buf, length) _php_stream_temp_open((mode), (max_memory_usage), (buf), (length) STREAMS_CC TSRMLS_CC) @@ -45,6 +46,7 @@ PHPAPI php_stream *_php_stream_memory_open(int mode, char *buf, size_t length ST PHPAPI char *_php_stream_memory_get_buffer(php_stream *stream, size_t *length STREAMS_DC TSRMLS_DC); PHPAPI php_stream *_php_stream_temp_create(int mode, size_t max_memory_usage STREAMS_DC TSRMLS_DC); +PHPAPI php_stream *_php_stream_temp_create_ex(int mode, size_t max_memory_usage, const char *tmpdir STREAMS_DC TSRMLS_DC); PHPAPI php_stream *_php_stream_temp_open(int mode, size_t max_memory_usage, char *buf, size_t length STREAMS_DC TSRMLS_DC); END_EXTERN_C() diff --git a/main/rfc1867.c b/main/rfc1867.c index 5fbeb32fea..512ce61199 100644 --- a/main/rfc1867.c +++ b/main/rfc1867.c @@ -904,7 +904,11 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler) /* {{{ */ } if (!strcasecmp(param, "MAX_FILE_SIZE")) { +#ifdef HAVE_ATOLL max_file_size = atoll(value); +#else + max_file_size = strtoll(value, NULL, 10); +#endif } efree(param); diff --git a/main/streams/memory.c b/main/streams/memory.c index d64054e999..b779ef34c8 100644 --- a/main/streams/memory.c +++ b/main/streams/memory.c @@ -352,6 +352,7 @@ typedef struct { size_t smax; int mode; zval* meta; + char* tmpdir; } php_stream_temp_data; @@ -369,7 +370,7 @@ static size_t php_stream_temp_write(php_stream *stream, const char *buf, size_t char *membuf = php_stream_memory_get_buffer(ts->innerstream, &memsize); if (memsize + count >= ts->smax) { - php_stream *file = php_stream_fopen_tmpfile(); + php_stream *file = php_stream_fopen_temporary_file(ts->tmpdir, "php", NULL); php_stream_write(file, membuf, memsize); php_stream_free_enclosed(ts->innerstream, PHP_STREAM_FREE_CLOSE); ts->innerstream = file; @@ -420,6 +421,10 @@ static int php_stream_temp_close(php_stream *stream, int close_handle TSRMLS_DC) zval_ptr_dtor(&ts->meta); } + if (ts->tmpdir) { + efree(ts->tmpdir); + } + efree(ts); return ret; @@ -547,8 +552,8 @@ PHPAPI php_stream_ops php_stream_temp_ops = { /* }}} */ -/* {{{ _php_stream_temp_create */ -PHPAPI php_stream *_php_stream_temp_create(int mode, size_t max_memory_usage STREAMS_DC TSRMLS_DC) +/* {{{ _php_stream_temp_create_ex */ +PHPAPI php_stream *_php_stream_temp_create_ex(int mode, size_t max_memory_usage, const char *tmpdir STREAMS_DC TSRMLS_DC) { php_stream_temp_data *self; php_stream *stream; @@ -556,7 +561,9 @@ PHPAPI php_stream *_php_stream_temp_create(int mode, size_t max_memory_usage STR self = ecalloc(1, sizeof(*self)); self->smax = max_memory_usage; self->mode = mode; - self->meta = NULL; + if (tmpdir) { + self->tmpdir = estrdup(tmpdir); + } stream = php_stream_alloc_rel(&php_stream_temp_ops, self, 0, mode & TEMP_STREAM_READONLY ? "rb" : "w+b"); stream->flags |= PHP_STREAM_FLAG_NO_BUFFER; self->innerstream = php_stream_memory_create_rel(mode); @@ -566,6 +573,12 @@ PHPAPI php_stream *_php_stream_temp_create(int mode, size_t max_memory_usage STR } /* }}} */ +/* {{{ _php_stream_temp_create */ +PHPAPI php_stream *_php_stream_temp_create(int mode, size_t max_memory_usage STREAMS_DC TSRMLS_DC) +{ + return php_stream_temp_create_ex(mode, max_memory_usage, NULL); +} +/* }}} */ /* {{{ _php_stream_temp_open */ PHPAPI php_stream *_php_stream_temp_open(int mode, size_t max_memory_usage, char *buf, size_t length STREAMS_DC TSRMLS_DC) diff --git a/main/streams/plain_wrapper.c b/main/streams/plain_wrapper.c index 521b800e16..9e0d245ad3 100644 --- a/main/streams/plain_wrapper.c +++ b/main/streams/plain_wrapper.c @@ -189,31 +189,20 @@ static php_stream *_php_stream_fopen_from_file_int(FILE *file, const char *mode return php_stream_alloc_rel(&php_stream_stdio_ops, self, 0, mode); } -PHPAPI php_stream *_php_stream_fopen_temporary_file(const char *dir, const char *pfx, char **opened_path STREAMS_DC TSRMLS_DC) +PHPAPI php_stream *_php_stream_fopen_temporary_file(const char *dir, const char *pfx, char **opened_path_ptr STREAMS_DC TSRMLS_DC) { - int fd = php_open_temporary_fd(dir, pfx, opened_path TSRMLS_CC); + char *opened_path = NULL; + int fd; + fd = php_open_temporary_fd(dir, pfx, &opened_path TSRMLS_CC); if (fd != -1) { - php_stream *stream = php_stream_fopen_from_fd_int_rel(fd, "r+b", NULL); - if (stream) { - return stream; - } - close(fd); - - php_error_docref(NULL TSRMLS_CC, E_WARNING, "unable to allocate stream"); - - return NULL; - } - return NULL; -} + php_stream *stream; -PHPAPI php_stream *_php_stream_fopen_tmpfile(int dummy STREAMS_DC TSRMLS_DC) -{ - char *opened_path = NULL; - int fd = php_open_temporary_fd(NULL, "php", &opened_path TSRMLS_CC); + if (opened_path_ptr) { + *opened_path_ptr = opened_path; + } - if (fd != -1) { - php_stream *stream = php_stream_fopen_from_fd_int_rel(fd, "r+b", NULL); + stream = php_stream_fopen_from_fd_int_rel(fd, "r+b", NULL); if (stream) { php_stdio_stream_data *self = (php_stdio_stream_data*)stream->abstract; stream->wrapper = &php_plain_files_wrapper; @@ -233,6 +222,11 @@ PHPAPI php_stream *_php_stream_fopen_tmpfile(int dummy STREAMS_DC TSRMLS_DC) return NULL; } +PHPAPI php_stream *_php_stream_fopen_tmpfile(int dummy STREAMS_DC TSRMLS_DC) +{ + return php_stream_fopen_temporary_file(NULL, "php", NULL); +} + PHPAPI php_stream *_php_stream_fopen_from_fd(int fd, const char *mode, const char *persistent_id STREAMS_DC TSRMLS_DC) { php_stream *stream = php_stream_fopen_from_fd_int_rel(fd, mode, persistent_id); diff --git a/sapi/cgi/tests/bug61605.phpt b/sapi/cgi/tests/bug61605.phpt index c6e4cf20ca..9c29e6dda2 100644 --- a/sapi/cgi/tests/bug61605.phpt +++ b/sapi/cgi/tests/bug61605.phpt @@ -4,6 +4,8 @@ Bug #61605 (header_remove() does not remove all headers) <?php include "skipif.inc"; ?> --GET-- foo=bar +--INI-- +expose_php=On --FILE-- <?php header("A: first"); diff --git a/sapi/cli/php_cli_server.c b/sapi/cli/php_cli_server.c index 5087b68a98..b6fcf37ee0 100644 --- a/sapi/cli/php_cli_server.c +++ b/sapi/cli/php_cli_server.c @@ -666,11 +666,10 @@ static int sapi_cli_server_send_headers(sapi_headers_struct *sapi_headers TSRMLS h = (sapi_header_struct*)zend_llist_get_first_ex(&sapi_headers->headers, &pos); while (h) { - if (!h->header_len) { - continue; + if (h->header_len) { + smart_str_appendl(&buffer, h->header, h->header_len); + smart_str_appendl(&buffer, "\r\n", 2); } - smart_str_appendl(&buffer, h->header, h->header_len); - smart_str_appendl(&buffer, "\r\n", 2); h = (sapi_header_struct*)zend_llist_get_next_ex(&sapi_headers->headers, &pos); } smart_str_appendl(&buffer, "\r\n", 2); @@ -1686,10 +1685,14 @@ static int php_cli_server_client_read_request_on_header_value(php_http_parser *p return 1; } { - char *header_name = zend_str_tolower_dup(client->current_header_name, client->current_header_name_len); - zend_hash_add(&client->request.headers, header_name, client->current_header_name_len + 1, &value, sizeof(char *), NULL); - zend_hash_add(&client->request.headers_original_case, client->current_header_name, client->current_header_name_len + 1, &value, sizeof(char *), NULL); - efree(header_name); + /* strip off the colon */ + char *orig_header_name = estrndup(client->current_header_name, client->current_header_name_len); + char *lc_header_name = zend_str_tolower_dup(client->current_header_name, client->current_header_name_len); + + zend_hash_add(&client->request.headers, lc_header_name, client->current_header_name_len + 1, &value, sizeof(char *), NULL); + zend_hash_add(&client->request.headers_original_case, orig_header_name, client->current_header_name_len + 1, &value, sizeof(char *), NULL); + efree(lc_header_name); + efree(orig_header_name); } if (client->current_header_name_allocated) { diff --git a/sapi/cli/tests/bug66830.phpt b/sapi/cli/tests/bug66830.phpt new file mode 100644 index 0000000000..58c07e031a --- /dev/null +++ b/sapi/cli/tests/bug66830.phpt @@ -0,0 +1,43 @@ +--TEST-- +Bug #66830 (Empty header causes PHP built-in web server to hang) +--SKIPIF-- +<?php +include "skipif.inc"; +?> +--FILE-- +<?php +include "php_cli_server.inc"; +php_cli_server_start(<<<'PHP' +header(' '); +PHP +); + +list($host, $port) = explode(':', PHP_CLI_SERVER_ADDRESS); +$port = intval($port)?:80; + +$fp = fsockopen($host, $port, $errno, $errstr, 0.5); +if (!$fp) { + die("connect failed"); +} + +if(fwrite($fp, <<<HEADER +GET / HTTP/1.1 +Host: {$host} + + +HEADER +)) { + while (!feof($fp)) { + echo fgets($fp); + } +} + +fclose($fp); +?> +--EXPECTF-- +HTTP/1.1 200 OK +Host: %s +Connection: close +X-Powered-By: %s +Content-type: text/html; charset=UTF-8 + diff --git a/sapi/fpm/config.m4 b/sapi/fpm/config.m4 index 40cd69c719..9c10aa6be2 100644 --- a/sapi/fpm/config.m4 +++ b/sapi/fpm/config.m4 @@ -584,14 +584,41 @@ if test "$PHP_FPM" != "no"; then [ --with-fpm-systemd Activate systemd integration], no, no) if test "$PHP_FPM_SYSTEMD" != "no" ; then - AC_CHECK_LIB(systemd-daemon, sd_notify, SYSTEMD_LIBS="-lsystemd-daemon") + if test -z "$PKG_CONFIG"; then + AC_PATH_PROG(PKG_CONFIG, pkg-config, no) + fi + unset SYSTEMD_LIBS + unset SYSTEMD_INCS + + if test -x "$PKG_CONFIG" && $PKG_CONFIG --exists libsystemd; then + dnl systemd version >= 209 provides libsystemd + AC_MSG_CHECKING([for libsystemd]) + SYSTEMD_LIBS=`$PKG_CONFIG --libs libsystemd` + SYSTEMD_INCS=`$PKG_CONFIG --cflags-only-I libsystemd` + SYSTEMD_VERS=`$PKG_CONFIG --modversion libsystemd` + AC_MSG_RESULT([version $SYSTEMD_VERS]) + + elif test -x "$PKG_CONFIG" && $PKG_CONFIG --exists libsystemd-daemon; then + dnl systemd version < 209 provides libsystemd-daemon + AC_MSG_CHECKING([for libsystemd-daemon]) + SYSTEMD_LIBS=`$PKG_CONFIG --libs libsystemd-daemon` + SYSTEMD_INCS=`$PKG_CONFIG --cflags-only-I libsystemd-daemon` + SYSTEMD_VERS=`$PKG_CONFIG --modversion libsystemd-daemon` + AC_MSG_RESULT([version $SYSTEMD_VERS]) + + else + dnl failback when no pkg-config + AC_CHECK_LIB(systemd-daemon, sd_notify, SYSTEMD_LIBS="-lsystemd-daemon") + fi + AC_CHECK_HEADERS(systemd/sd-daemon.h, [HAVE_SD_DAEMON_H="yes"], [HAVE_SD_DAEMON_H="no"]) if test $HAVE_SD_DAEMON_H = "no" || test -z "${SYSTEMD_LIBS}"; then AC_MSG_ERROR([Your system does not support systemd.]) else AC_DEFINE(HAVE_SYSTEMD, 1, [FPM use systemd integration]) PHP_FPM_SD_FILES="fpm/fpm_systemd.c" - PHP_ADD_LIBRARY(systemd-daemon) + PHP_EVAL_LIBLINE($SYSTEMD_LIBS) + PHP_EVAL_INCLINE($SYSTEMD_INCS) php_fpm_systemd=notify fi else diff --git a/sapi/fpm/fpm/fpm_stdio.c b/sapi/fpm/fpm/fpm_stdio.c index 33b0e01c87..fcec78435b 100644 --- a/sapi/fpm/fpm/fpm_stdio.c +++ b/sapi/fpm/fpm/fpm_stdio.c @@ -268,7 +268,11 @@ int fpm_stdio_open_error_log(int reopen) /* {{{ */ if (!strcasecmp(fpm_global_config.error_log, "syslog")) { openlog(fpm_global_config.syslog_ident, LOG_PID | LOG_CONS, fpm_global_config.syslog_facility); fpm_globals.error_log_fd = ZLOG_SYSLOG; +#if HAVE_UNISTD_H + if (fpm_global_config.daemonize || (!isatty(STDERR_FILENO) && !fpm_globals.force_stderr)) { +#else if (fpm_global_config.daemonize) { +#endif zlog_set_fd(fpm_globals.error_log_fd); } return 0; diff --git a/sapi/litespeed/lsapi_main.c b/sapi/litespeed/lsapi_main.c index 63051c1645..2405e2419e 100644 --- a/sapi/litespeed/lsapi_main.c +++ b/sapi/litespeed/lsapi_main.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2007 The PHP Group | + | Copyright (c) 1997-2014 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -16,8 +16,6 @@ +----------------------------------------------------------------------+ */ -/* $Id: lsapi_main.c,v 1.59 2013/11/18 21:14:38 gwang Exp $ */ - #include "php.h" #include "SAPI.h" #include "php_main.h" @@ -737,9 +735,9 @@ static int cli_main( int argc, char * argv[] ) case 'v': if (php_request_startup(TSRMLS_C) != FAILURE) { #if ZEND_DEBUG - php_printf("PHP %s (%s) (built: %s %s) (DEBUG)\nCopyright (c) 1997-2004 The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version()); + php_printf("PHP %s (%s) (built: %s %s) (DEBUG)\nCopyright (c) 1997-2014 The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version()); #else - php_printf("PHP %s (%s) (built: %s %s)\nCopyright (c) 1997-2004 The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version()); + php_printf("PHP %s (%s) (built: %s %s)\nCopyright (c) 1997-2014 The PHP Group\n%s", PHP_VERSION, sapi_module.name, __DATE__, __TIME__, get_zend_version()); #endif #ifdef PHP_OUTPUT_NEWAPI php_output_end_all(TSRMLS_C); diff --git a/sapi/litespeed/lsapidef.h b/sapi/litespeed/lsapidef.h index 5d5b4c1687..fb75d01a17 100644 --- a/sapi/litespeed/lsapidef.h +++ b/sapi/litespeed/lsapidef.h @@ -1,5 +1,23 @@ /* -Copyright (c) 2005, Lite Speed Technologies Inc. + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2014 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt. | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: George Wang <gwang@litespeedtech.com> | + +----------------------------------------------------------------------+ +*/ + +/* +Copyright (c) 2002-2014, Lite Speed Technologies Inc. All rights reserved. Redistribution and use in source and binary forms, with or without @@ -30,13 +48,6 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/*************************************************************************** - $Id: lsapidef.h,v 1.17 2012/12/01 19:23:31 gwang Exp $ - ------------------- - begin : Thu Feb 10 2005 - author : George Wang - email : gwang@litespeedtech.com - ***************************************************************************/ #ifndef _LSAPIDEF_H_ #define _LSAPIDEF_H_ diff --git a/sapi/litespeed/lsapilib.c b/sapi/litespeed/lsapilib.c index cdd60763db..786a3bd20b 100644 --- a/sapi/litespeed/lsapilib.c +++ b/sapi/litespeed/lsapilib.c @@ -1,5 +1,23 @@ /* -Copyright (c) 2013, Lite Speed Technologies Inc. + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2014 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt. | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: George Wang <gwang@litespeedtech.com> | + +----------------------------------------------------------------------+ +*/ + +/* +Copyright (c) 2002-2014, Lite Speed Technologies Inc. All rights reserved. Redistribution and use in source and binary forms, with or without @@ -30,14 +48,6 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/*************************************************************************** - lsapilib.c - description - ------------------- - begin : Mon Feb 21 2005 - copyright : (C) 2005 by George Wang - email : gwang@litespeedtech.com - ***************************************************************************/ - #include <ctype.h> #include <dlfcn.h> @@ -1935,6 +1945,7 @@ int LSAPI_ForeachOrgHeader_r( LSAPI_Request * pReq, { pKey = pReq->m_pHttpHeader + pCur->nameOff; keyLen = pCur->nameLen; + *(pKey + keyLen ) = 0; pValue = pReq->m_pHttpHeader + pCur->valueOff; *(pValue + pCur->valueLen ) = 0; @@ -2846,8 +2857,8 @@ static int lsapi_prefork_server_accept( lsapi_prefork_server * pServer, LSAPI_Re } } sigaction( SIGUSR1, &old_usr1, 0 ); - kill( -getpgrp(), SIGUSR1 ); - lsapi_all_children_must_die(); /* Sorry, children ;-) */ + //kill( -getpgrp(), SIGUSR1 ); + //lsapi_all_children_must_die(); /* Sorry, children ;-) */ return -1; } diff --git a/sapi/litespeed/lsapilib.h b/sapi/litespeed/lsapilib.h index b0638fd436..cae1863c79 100644 --- a/sapi/litespeed/lsapilib.h +++ b/sapi/litespeed/lsapilib.h @@ -1,5 +1,23 @@ /* -Copyright (c) 2013, Lite Speed Technologies Inc. + +----------------------------------------------------------------------+ + | PHP Version 5 | + +----------------------------------------------------------------------+ + | Copyright (c) 1997-2014 The PHP Group | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt. | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ + | Author: George Wang <gwang@litespeedtech.com> | + +----------------------------------------------------------------------+ +*/ + +/* +Copyright (c) 2002-2014, Lite Speed Technologies Inc. All rights reserved. Redistribution and use in source and binary forms, with or without @@ -30,14 +48,6 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -/*************************************************************************** - lsapilib.h - description - ------------------- - begin : Mon Feb 21 2005 - copyright : (C) 2005 by George Wang - email : gwang@litespeedtech.com - ***************************************************************************/ - #ifndef _LSAPILIB_H_ #define _LSAPILIB_H_ diff --git a/sapi/phpdbg/Makefile.frag b/sapi/phpdbg/Makefile.frag index b276aaaa53..36c7512d69 100644 --- a/sapi/phpdbg/Makefile.frag +++ b/sapi/phpdbg/Makefile.frag @@ -28,7 +28,7 @@ install-phpdbg: $(BUILD_BINARY) @$(INSTALL) -m 0755 $(BUILD_BINARY) $(INSTALL_ROOT)$(bindir)/$(program_prefix)phpdbg$(program_suffix)$(EXEEXT) @echo "Installing phpdbg man page: $(INSTALL_ROOT)$(mandir)/man1/" @$(mkinstalldirs) $(INSTALL_ROOT)$(mandir)/man1 - @$(INSTALL_DATA) sapi/phpdbg/phpdbg.1 $(INSTALL_ROOT)$(mandir)/man1/$(program_prefix)phpdbg$(program_suffix).1 + @$(INSTALL_DATA) $(srcdir)/phpdbg.1 $(INSTALL_ROOT)$(mandir)/man1/$(program_prefix)phpdbg$(program_suffix).1 clean-phpdbg: @echo "Cleaning phpdbg object files ..." diff --git a/sapi/phpdbg/phpdbg.c b/sapi/phpdbg/phpdbg.c index fe2b624594..871fd07e29 100644 --- a/sapi/phpdbg/phpdbg.c +++ b/sapi/phpdbg/phpdbg.c @@ -856,7 +856,8 @@ int phpdbg_open_sockets(char *address, int port[2], int (*listen)[2], int (*sock return SUCCESS; } /* }}} */ -void phpdbg_signal_handler(int sig, siginfo_t *info, void *context) { +void phpdbg_signal_handler(int sig, siginfo_t *info, void *context) /* {{{ */ +{ int is_handled = FAILURE; TSRMLS_FETCH(); @@ -874,10 +875,11 @@ void phpdbg_signal_handler(int sig, siginfo_t *info, void *context) { break; } -} +} /* }}} */ #endif -static inline zend_mm_heap *phpdbg_mm_get_heap() { +static inline zend_mm_heap *phpdbg_mm_get_heap() /* {{{ */ +{ zend_mm_heap *mm_heap; TSRMLS_FETCH(); @@ -886,22 +888,22 @@ static inline zend_mm_heap *phpdbg_mm_get_heap() { zend_mm_set_heap(mm_heap TSRMLS_CC); return mm_heap; -} +} /* }}} */ -void *phpdbg_malloc_wrapper(size_t size) +void *phpdbg_malloc_wrapper(size_t size) /* {{{ */ { return zend_mm_alloc(phpdbg_mm_get_heap(), size); -} +} /* }}} */ -void phpdbg_free_wrapper(void *p) +void phpdbg_free_wrapper(void *p) /* {{{ */ { zend_mm_free(phpdbg_mm_get_heap(), p); -} +} /* }}} */ -void *phpdbg_realloc_wrapper(void *ptr, size_t size) +void *phpdbg_realloc_wrapper(void *ptr, size_t size) /* {{{ */ { return zend_mm_realloc(phpdbg_mm_get_heap(), ptr, size); -} +} /* }}} */ int main(int argc, char **argv) /* {{{ */ { diff --git a/tests/basic/025.phpt b/tests/basic/025.phpt index 58191bcd61..37561a2a2e 100644 --- a/tests/basic/025.phpt +++ b/tests/basic/025.phpt @@ -3,6 +3,7 @@ Test HTTP_RAW_POST_DATA with excessive post length --INI-- always_populate_raw_post_data=1 post_max_size=1K +expose_php=On --POST-- a=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa --FILE-- diff --git a/travis/compile.sh b/travis/compile.sh index babb945a04..52748c6db5 100755 --- a/travis/compile.sh +++ b/travis/compile.sh @@ -49,5 +49,12 @@ $TS \ --with-openssl \ --with-gmp \ --enable-bcmath \ ---enable-phpdbg +--enable-phpdbg \ +--enable-calendar \ +--enable-ftp \ +--with-pspell=/usr \ +--with-recode=/usr \ +--with-enchant=/usr \ +--enable-wddx \ +--enable-sysvmsg make --quiet diff --git a/travis/de b/travis/de new file mode 100644 index 0000000000..ae49d969ee --- /dev/null +++ b/travis/de @@ -0,0 +1,2 @@ +de_DE.UTF-8 UTF-8 +de_DE ISO-8859-1 diff --git a/win32/build/Makefile b/win32/build/Makefile index 057b584549..7a3be93e87 100644 --- a/win32/build/Makefile +++ b/win32/build/Makefile @@ -183,7 +183,7 @@ msi-installer: dist # need to redirect, since INSTALL is a file in the root... install: really-install install-sdk -build-lib: +build-lib: build-ext-libs @if not exist $(BUILD_DIR_DEV)\lib mkdir $(BUILD_DIR_DEV)\lib >nul @copy $(BUILD_DIR)\$(PHPLIB) $(BUILD_DIR_DEV)\lib /y >nul diff --git a/win32/build/Makefile.phpize b/win32/build/Makefile.phpize index 17cfc90fbd..1f92f7716c 100644 --- a/win32/build/Makefile.phpize +++ b/win32/build/Makefile.phpize @@ -5,10 +5,8 @@ MT="$(MT)" PHPSDK_DIR=$(PHP_DIR)
PHPLIB=$(PHPSDK_DIR)\lib\$(PHPLIB)
-LDFLAGS=/libpath:"$(PHPSDK_DIR)\lib\;$(PHPSDK_DIR)"
-
-CFLAGS=/nologo /FD $(BASE_INCLUDES) /D _WINDOWS /D ZEND_WIN32=1 /D PHP_WIN32=1 /D WIN32 /D_USE_32BIT_TIME_T=1 /D ZEND_WIN32_FORCE_INLINE /GF /D ZEND_DEBUG=0 /D ZTS=1 /D FD_SETSIZE=256
-CFLAGS_PHP=/D _USRDLL /D PHP5DLLTS_EXPORTS /D PHP_EXPORTS /D TSRM_EXPORTS /D SAPI_EXPORTS /D WINVER=0x500 /D COMPILE_DL_AJAXMIN
+LDFLAGS=$(LDFLAGS) /libpath:"$(PHPSDK_DIR)\lib\;$(PHPSDK_DIR)"
+BUILD_DIR_DEV=$(PHPSDK_DIR)
all: $(EXT_TARGETS) $(PECL_TARGETS)
@@ -36,3 +34,5 @@ _VC_MANIFEST_EMBED_EXE= if exist $@.manifest $(MT) -nologo -manifest $@.manifest _VC_MANIFEST_EMBED_DLL= if exist $@.manifest $(MT) -nologo -manifest $@.manifest -outputresource:$@;2
!endif
+install: build-headers build-bins
+
diff --git a/win32/build/config.w32 b/win32/build/config.w32 index 23ce566462..6fd7057010 100644 --- a/win32/build/config.w32 +++ b/win32/build/config.w32 @@ -474,5 +474,7 @@ if (PHP_ANALYZER == "vs") { pvscfg.WriteLine("preprocessor = visualcpp"); pvscfg.WriteLine("language = C"); } +} else { + PHP_ANALYZER = "no" } diff --git a/win32/build/config.w32.phpize.in b/win32/build/config.w32.phpize.in index 10cdb82175..adffac1fc9 100644 --- a/win32/build/config.w32.phpize.in +++ b/win32/build/config.w32.phpize.in @@ -105,6 +105,11 @@ if (PHP_DEBUG == "yes" && PHP_DEBUG_PACK == "yes") { ERROR("Use of both --enable-debug and --enable-debug-pack not allowed.");
}
+if (PHP_PREFIX == '') {
+ PHP_PREFIX = "C:\\php";
+ if (PHP_DEBUG == "yes")
+ PHP_PREFIX += "\\debug";
+}
DEFINE('PHP_PREFIX', PHP_PREFIX);
DEFINE("BASE_INCLUDES", "/I " + PHP_DIR + "/include /I " + PHP_DIR + "/include/main /I " + PHP_DIR + "/include/Zend /I " + PHP_DIR + "/include/TSRM /I " + PHP_DIR + "/include/ext ");
diff --git a/win32/build/confutils.js b/win32/build/confutils.js index 1dbc75b280..203013e2f0 100644 --- a/win32/build/confutils.js +++ b/win32/build/confutils.js @@ -1024,6 +1024,11 @@ function is_pgo_desired(mod) {
var varname = "PHP_" + mod.toUpperCase() + "_PGO";
+ /* XXX enable PGO in phpize mode */
+ if (MODE_PHPIZE) {
+ return false;
+ }
+
/* don't disable if there's no mention of the varname */
if (eval("typeof " + varname + " == 'undefined'")) {
return true;
@@ -1165,11 +1170,6 @@ function ADD_EXTENSION_DEP(extname, dependson, optional) var dep_present = false;
var dep_shared = false;
- if (MODE_PHPIZE) {
- ext_deps_js = file_get_contents(PHP_DIR + "\\script\\ext_deps.js");
- eval(ext_deps_js);
- }
-
try {
dep_present = eval("PHP_" + DEP);
@@ -1203,9 +1203,14 @@ function ADD_EXTENSION_DEP(extname, dependson, optional) ERROR("static " + extname + " cannot depend on shared " + dependson);
}
- ADD_FLAG("LDFLAGS_" + EXT, "/libpath:$(BUILD_DIR)");
ADD_FLAG("LIBS_" + EXT, "php_" + dependson + ".lib");
- ADD_FLAG("DEPS_" + EXT, "$(BUILD_DIR)\\php_" + dependson + ".lib");
+ if (MODE_PHPIZE) {
+ ADD_FLAG("LDFLAGS_" + EXT, "/libpath:$(BUILD_DIR_DEV)\\lib");
+ ADD_FLAG("DEPS_" + EXT, "$(BUILD_DIR_DEV)\\lib\\php_" + dependson + ".lib");
+ } else {
+ ADD_FLAG("LDFLAGS_" + EXT, "/libpath:$(BUILD_DIR)");
+ ADD_FLAG("DEPS_" + EXT, "$(BUILD_DIR)\\php_" + dependson + ".lib");
+ }
} else {
@@ -1356,6 +1361,9 @@ function EXTENSION(extname, file_list, shared, cflags, dllname, obj_dir) DEFINE('CFLAGS_' + EXT + '_OBJ', '$(CFLAGS_PHP) $(CFLAGS_' + EXT + ')');
}
+ if (MODE_PHPIZE && FSO.FileExists(PHP_DIR + "/include/main/config.pickle.h")) {
+ cflags = "/FI main/config.pickle.h " + cflags;
+ }
ADD_FLAG("CFLAGS_" + EXT, cflags);
if (PHP_DSP != "no") {
@@ -1520,7 +1528,7 @@ function output_as_table(header, ar_out) var min = new Array(l);
var max = new Array(l);
- if (l != ar_out[0].length) {
+ if (!!ar_out[0] && l != ar_out[0].length) {
STDOUT.WriteLine("Invalid header argument, can't output the table " + l + " " + ar_out[0].length );
return;
}
@@ -1672,6 +1680,9 @@ function generate_files() generate_internal_functions();
generate_config_h();
generate_phpize();
+ } else {
+ generate_config_pickle_h();
+ generate_ext_pickle();
}
STDOUT.WriteLine("Done.");
STDOUT.WriteBlankLines(1);
@@ -1684,6 +1695,140 @@ function generate_files() }
}
+function generate_ext_pickle()
+{
+ var content;
+ var DEPS = null;
+ var dest;
+ var deps_lines = new Array();
+
+ var build_var_name = function(name) {
+ return "PHP_" + name.toUpperCase();
+ }
+
+ STDOUT.WriteLine("Generating pickle deps");
+ dest = PHP_DIR + "/script/";
+
+ if (!FSO.FolderExists(dest)) {
+ FSO.CreateFolder(dest);
+ }
+
+ if (FSO.FileExists(dest + "/ext_pickle.js")) {
+ DEPS = FSO.OpenTextFile(dest + "/ext_pickle.js", 1);
+
+ while (!DEPS.AtEndOfStream) {
+ var ln = DEPS.ReadLine();
+ var found = false;
+
+ for (var i in extensions_enabled) {
+ var reg0 = new RegExp(build_var_name(extensions_enabled[i][0]) + "\s*=.+", "g");
+ var reg1 = new RegExp(build_var_name(extensions_enabled[i][0]) + "_SHARED" + "\s*=.+", "g");
+
+ if (ln.match(reg1) || ln.match(reg0)) {
+ found = true;
+ break;
+ }
+ }
+
+ if (!found) {
+ deps_lines.push(ln);
+ }
+ }
+ }
+
+ for (var i in extensions_enabled) {
+ deps_lines.push(build_var_name(extensions_enabled[i][0]) + "=true;");
+ deps_lines.push(build_var_name(extensions_enabled[i][0]) + "_SHARED=" + (extensions_enabled[i][1] == 'shared' ? 'true' : 'false') + ";");
+ }
+
+ if (!!DEPS) {
+ DEPS.Close();
+ DEPS = null;
+ }
+
+ /* Replace the ext_pickle.js with the new content */
+ DEPS = FSO.CreateTextFile(dest + "/ext_pickle.js", true);
+
+ for (var j in deps_lines) {
+ DEPS.WriteLine(deps_lines[j]);
+ }
+
+ DEPS.Close();
+}
+
+function generate_config_pickle_h()
+{
+ var outfile = null;
+ var lines = new Array();
+ var keys = (new VBArray(configure_hdr.Keys())).toArray();
+ dest = PHP_DIR + "/include/main";
+
+ var ignore_key = function(key) {
+ var ignores = [ "CONFIGURE_COMMAND", "PHP_COMPILER_ID", "COMPILER", "ARCHITECTURE", "HAVE_STRNLEN", "PHP_DIR" ];
+
+ for (var k in ignores) {
+ if (ignores[k] == key) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+
+ STDOUT.WriteLine("Generating main/config.pickle.h");
+
+ if (FSO.FileExists(dest + "/config.pickle.h")) {
+ outfile = FSO.OpenTextFile(dest + "/config.pickle.h", 1);
+
+ while (!outfile.AtEndOfStream) {
+ var found = false;
+ var ln = outfile.ReadLine();
+
+ for (var i in keys) {
+ var reg = new RegExp("#define[\s ]+" + keys[i] + "[\s ]*.*", "g");
+
+ if (ln.match(reg)) {
+ found = true;
+ break;
+ }
+ }
+
+ if (!found) {
+ lines.push(ln);
+ }
+ }
+ }
+
+ for (var i in keys) {
+ var item = configure_hdr.Item(keys[i]);
+
+ if (ignore_key(keys[i])) {
+ continue;
+ }
+
+ /* XXX fix comment handling */
+ /*if (!lines[j].match(/^#define.+/g)) {
+ continue;
+ }*/
+
+ lines.push("#define " + keys[i] + " " + item[0]);
+ }
+
+ if (outfile) {
+ outfile.Close();
+ outfile = null;
+ }
+
+ outfile = FSO.CreateTextFile(dest + "/config.pickle.h", true);
+
+ for (var k in lines) {
+ outfile.WriteLine(lines[k]);
+ }
+
+ outfile.Close();
+}
+
function generate_config_h()
{
var infile, outfile;
@@ -1757,6 +1902,7 @@ function generate_phpize() var MF = FSO.CreateTextFile(dest + "/phpize.js", true);
var DEPS = FSO.CreateTextFile(dest + "/ext_deps.js", true);
+
prefix = get_define("PHP_PREFIX");
prefix = prefix.replace(new RegExp("/", "g"), "\\");
prefix = prefix.replace(new RegExp("\\\\", "g"), "\\\\");
@@ -1836,13 +1982,35 @@ function generate_makefile() }
}
MF.WriteLine(" @for %D in ($(INSTALL_HEADERS_DIR)) do @copy %D*.h $(BUILD_DIR_DEV)\\include\\%D /y >nul");
+ if (MODE_PHPIZE) {
+ MF.WriteBlankLines(1);
+ MF.WriteLine("build-bins:");
+ for (var i in extensions_enabled) {
+ var lib = "php_" + extensions_enabled[i][0] + ".lib";
+ var dll = "php_" + extensions_enabled[i][0] + ".dll";
+ MF.WriteLine(" @copy $(BUILD_DIR)\\" + lib + " $(BUILD_DIR_DEV)\\lib");
+ MF.WriteLine(" @copy $(BUILD_DIR)\\" + dll + " $(PHP_PREFIX)");
+ }
+ } else {
+ MF.WriteBlankLines(1);
+ MF.WriteLine("build-ext-libs:");
+ for (var i in extensions_enabled) {
+ var lib = "php_" + extensions_enabled[i][0] + ".lib";
+
+ if ('shared' == extensions_enabled[i][1]) {
+ MF.WriteLine(" @copy $(BUILD_DIR)\\" + lib + " $(BUILD_DIR_DEV)\\lib");
+ }
+ }
+ }
TF.Close();
MF.WriteBlankLines(2);
MFO.Close();
TF = FSO.OpenTextFile("Makefile.objects", 1);
- MF.Write(TF.ReadAll());
+ if (!TF.AtEndOfStream) {
+ MF.Write(TF.ReadAll());
+ }
TF.Close();
MF.Close();
diff --git a/win32/build/mkdist.php b/win32/build/mkdist.php index 23d26c9c53..640e9b3bd7 100644 --- a/win32/build/mkdist.php +++ b/win32/build/mkdist.php @@ -246,7 +246,8 @@ foreach ($text_files as $src => $dest) { /* general other files */ $general_files = array( - "php.gif" => "php.gif", + "php.gif" => "php.gif", + "$GLOBALS[build_dir]\\deplister.exe" => "deplister.exe", ); foreach ($general_files as $src => $dest) { diff --git a/win32/build/phpize.js.in b/win32/build/phpize.js.in index 4813ec0b5d..c99dece618 100644 --- a/win32/build/phpize.js.in +++ b/win32/build/phpize.js.in @@ -40,9 +40,13 @@ function ERROR(msg) function file_get_contents(filename)
{
+ var t = "";
var F = FSO.OpenTextFile(filename, 1);
- var t = F.ReadAll();
- F.Close();
+
+ if (!F.AtEndOfStream) {
+ t = F.ReadAll();
+ F.Close();
+ }
return t;
}
@@ -208,6 +212,12 @@ STDOUT.WriteLine(PHP_DIR); C.WriteLine("/* This file automatically generated from script/confutils.js */");
C.WriteLine("var MODE_PHPIZE = true;");
C.WriteLine("var PHP_DIR = " + '"' + PHP_DIR.replace(new RegExp('(["\\\\])', "g"), '\\$1') + '"');
+C.WriteLine("var PHP_PREFIX = " + '"' + PHP_PREFIX.replace(new RegExp('(["\\\\])', "g"), '\\$1') + '"');
+
+C.Write(file_get_contents(PHP_DIR + "//script//ext_deps.js"));
+if (FSO.FileExists(PHP_DIR + "/script/ext_pickle.js")) {
+ C.Write(file_get_contents(PHP_DIR + "//script//ext_pickle.js"));
+}
C.Write(file_get_contents(PHP_DIR + "/script/confutils.js"));
C.Write(file_get_contents(PHP_DIR + "/script/config.phpize.js"));
|