diff options
| author | Ondřej Surý <ondrej@sury.org> | 2013-08-20 09:06:13 +0200 |
|---|---|---|
| committer | Ondřej Surý <ondrej@sury.org> | 2013-08-20 09:06:13 +0200 |
| commit | bf4af35254bfff38b18848b86bb2bf7cf11085de (patch) | |
| tree | 4357e214a9bbaea82dc6bd318cf2ddaa4c7ba01c /ext | |
| parent | d837b4550418036e76d6adb3c7dad94b1e3a5a6a (diff) | |
| download | php-bf4af35254bfff38b18848b86bb2bf7cf11085de.tar.gz | |
New upstream version 5.5.2+dfsgupstream/5.5.2+dfsg
Diffstat (limited to 'ext')
269 files changed, 3163 insertions, 814 deletions
diff --git a/ext/bz2/config.m4 b/ext/bz2/config.m4 index 3e6aa78d0..55917c07f 100644 --- a/ext/bz2/config.m4 +++ b/ext/bz2/config.m4 @@ -3,7 +3,7 @@ dnl $Id$ dnl PHP_ARG_WITH(bz2, for BZip2 support, -[ --with-bz2[=DIR] Include BZip2 support]) +[ --with-bz2[=DIR] Include BZip2 support]) if test "$PHP_BZ2" != "no"; then if test -r $PHP_BZ2/include/bzlib.h; then diff --git a/ext/com_dotnet/com_variant.c b/ext/com_dotnet/com_variant.c index 556f356b9..e153d3580 100644 --- a/ext/com_dotnet/com_variant.c +++ b/ext/com_dotnet/com_variant.c @@ -53,7 +53,7 @@ static void safe_array_from_zval(VARIANT *v, zval *z, int codepage TSRMLS_DC) if (HASH_KEY_IS_STRING == keytype) { goto bogus; - } else if (HASH_KEY_NON_EXISTANT == keytype) { + } else if (HASH_KEY_NON_EXISTENT == keytype) { break; } if (intindex > max_index) { diff --git a/ext/com_dotnet/com_wrapper.c b/ext/com_dotnet/com_wrapper.c index 597b05995..355779e4a 100644 --- a/ext/com_dotnet/com_wrapper.c +++ b/ext/com_dotnet/com_wrapper.c @@ -467,7 +467,7 @@ static void generate_dispids(php_dispatchex *disp TSRMLS_DC) /* properties */ if (Z_OBJPROP_P(disp->object)) { zend_hash_internal_pointer_reset_ex(Z_OBJPROP_P(disp->object), &pos); - while (HASH_KEY_NON_EXISTANT != (keytype = + while (HASH_KEY_NON_EXISTENT != (keytype = zend_hash_get_current_key_ex(Z_OBJPROP_P(disp->object), &name, &namelen, &pid, 0, &pos))) { char namebuf[32]; @@ -498,7 +498,7 @@ static void generate_dispids(php_dispatchex *disp TSRMLS_DC) /* functions */ if (Z_OBJCE_P(disp->object)) { zend_hash_internal_pointer_reset_ex(&Z_OBJCE_P(disp->object)->function_table, &pos); - while (HASH_KEY_NON_EXISTANT != (keytype = + while (HASH_KEY_NON_EXISTENT != (keytype = zend_hash_get_current_key_ex(&Z_OBJCE_P(disp->object)->function_table, &name, &namelen, &pid, 0, &pos))) { @@ -598,7 +598,7 @@ PHP_COM_DOTNET_API IDispatch *php_com_wrapper_export_as_sink(zval *val, GUID *si zend_hash_init(disp->name_to_dispid, 0, NULL, ZVAL_PTR_DTOR, 0); zend_hash_internal_pointer_reset_ex(id_to_name, &pos); - while (HASH_KEY_NON_EXISTANT != (keytype = + while (HASH_KEY_NON_EXISTENT != (keytype = zend_hash_get_current_key_ex(id_to_name, &name, &namelen, &pid, 0, &pos))) { if (keytype == HASH_KEY_IS_LONG) { diff --git a/ext/curl/config.m4 b/ext/curl/config.m4 index e3d1d51cc..2f82c3485 100644 --- a/ext/curl/config.m4 +++ b/ext/curl/config.m4 @@ -3,7 +3,7 @@ dnl $Id$ dnl PHP_ARG_WITH(curl, for cURL support, -[ --with-curl[=DIR] Include cURL support]) +[ --with-curl[=DIR] Include cURL support]) if test "$PHP_CURL" != "no"; then if test -r $PHP_CURL/include/curl/easy.h; then diff --git a/ext/date/php_date.c b/ext/date/php_date.c index 0f8822a90..f0c9525e5 100644 --- a/ext/date/php_date.c +++ b/ext/date/php_date.c @@ -1041,7 +1041,7 @@ char *php_date_short_day_name(timelib_sll y, timelib_sll m, timelib_sll d) static char *date_format(char *format, int format_len, timelib_time *t, int localtime) { smart_str string = {0}; - int i, length; + int i, length = 0; char buffer[97]; timelib_time_offset *offset = NULL; timelib_sll isoweek, isoyear; @@ -1396,7 +1396,7 @@ PHPAPI void php_date_set_tzdb(timelib_tzdb *tzdb) } /* }}} */ -/* {{{ php_parse_date: Backwards compability function */ +/* {{{ php_parse_date: Backwards compatibility function */ PHPAPI signed long php_parse_date(char *string, signed long *now) { timelib_time *parsed_time; @@ -2538,8 +2538,8 @@ PHPAPI int php_date_initialize(php_date_obj *dateobj, /*const*/ char *time_str, timelib_time *now; timelib_tzinfo *tzi = NULL; timelib_error_container *err = NULL; - int type = TIMELIB_ZONETYPE_ID, new_dst; - char *new_abbr; + int type = TIMELIB_ZONETYPE_ID, new_dst = 0; + char *new_abbr = NULL; timelib_sll new_offset; if (dateobj->time) { diff --git a/ext/date/php_date.h b/ext/date/php_date.h index 725590136..536629a25 100644 --- a/ext/date/php_date.h +++ b/ext/date/php_date.h @@ -182,7 +182,7 @@ ZEND_END_MODULE_GLOBALS(date) #define DATEG(v) (date_globals.v) #endif -/* Backwards compability wrapper */ +/* Backwards compatibility wrapper */ PHPAPI signed long php_parse_date(char *string, signed long *now); PHPAPI void php_mktime(INTERNAL_FUNCTION_PARAMETERS, int gmt); PHPAPI int php_idate(char format, time_t ts, int localtime TSRMLS_DC); diff --git a/ext/dba/config.m4 b/ext/dba/config.m4 index 4b123518b..5442bb141 100644 --- a/ext/dba/config.m4 +++ b/ext/dba/config.m4 @@ -557,10 +557,10 @@ PHP_ARG_WITH(cdb,, [ --without-cdb[=DIR] DBA: CDB support (bundled)], $php_dba_enable, no) PHP_ARG_ENABLE(inifile,, -[ --disable-inifile DBA: INI support (bundled)], $php_dba_enable, no) +[ --disable-inifile DBA: INI support (bundled)], $php_dba_enable, no) PHP_ARG_ENABLE(flatfile,, -[ --disable-flatfile DBA: FlatFile support (bundled)], $php_dba_enable, no) +[ --disable-flatfile DBA: FlatFile support (bundled)], $php_dba_enable, no) # CDB if test "$PHP_CDB" = "yes"; then diff --git a/ext/dom/document.c b/ext/dom/document.c index d17c7cbd5..efe6d9070 100644 --- a/ext/dom/document.c +++ b/ext/dom/document.c @@ -1973,14 +1973,15 @@ static void _dom_document_schema_validate(INTERNAL_FUNCTION_PARAMETERS, int type xmlDoc *docp; dom_object *intern; char *source = NULL, *valid_file = NULL; - int source_len = 0; + int source_len = 0, valid_opts = 0; + long flags = 0; xmlSchemaParserCtxtPtr parser; xmlSchemaPtr sptr; xmlSchemaValidCtxtPtr vptr; int is_valid; char resolved_path[MAXPATHLEN + 1]; - if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Op", &id, dom_document_class_entry, &source, &source_len) == FAILURE) { + if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Op|l", &id, dom_document_class_entry, &source, &source_len, &flags) == FAILURE) { return; } @@ -2029,6 +2030,13 @@ static void _dom_document_schema_validate(INTERNAL_FUNCTION_PARAMETERS, int type RETURN_FALSE; } +#if LIBXML_VERSION >= 20614 + if (flags & XML_SCHEMA_VAL_VC_I_CREATE) { + valid_opts |= XML_SCHEMA_VAL_VC_I_CREATE; + } +#endif + + xmlSchemaSetValidOptions(vptr, valid_opts); xmlSchemaSetValidErrors(vptr, php_libxml_error_handler, php_libxml_error_handler, vptr); is_valid = xmlSchemaValidateDoc(vptr, docp); xmlSchemaFree(sptr); @@ -2042,14 +2050,14 @@ static void _dom_document_schema_validate(INTERNAL_FUNCTION_PARAMETERS, int type } /* }}} */ -/* {{{ proto boolean dom_document_schema_validate_file(string filename); */ +/* {{{ proto boolean dom_document_schema_validate_file(string filename, int flags); */ PHP_FUNCTION(dom_document_schema_validate_file) { _dom_document_schema_validate(INTERNAL_FUNCTION_PARAM_PASSTHRU, DOM_LOAD_FILE); } /* }}} end dom_document_schema_validate_file */ -/* {{{ proto boolean dom_document_schema_validate(string source); */ +/* {{{ proto boolean dom_document_schema_validate(string source, int flags); */ PHP_FUNCTION(dom_document_schema_validate_xml) { _dom_document_schema_validate(INTERNAL_FUNCTION_PARAM_PASSTHRU, DOM_LOAD_STRING); diff --git a/ext/dom/tests/DOMDocument_loadXML_basic.phpt b/ext/dom/tests/DOMDocument_loadXML_basic.phpt new file mode 100644 index 000000000..569593c00 --- /dev/null +++ b/ext/dom/tests/DOMDocument_loadXML_basic.phpt @@ -0,0 +1,21 @@ +--TEST-- +Test DOMDocument::loadXML() basic behavior +--DESCRIPTION-- +This test verifies the basic behaviour of the method +Environment variables used in the test: +- XML_FILE: the xml file to load +- LOAD_OPTIONS: the second parameter to pass to the method +- EXPECTED_RESULT: the expected result +--CREDITS-- +Antonio Diaz Ruiz <dejalatele@gmail.com> +--INI-- +assert.bail=true +--SKIPIF-- +<?php include('skipif.inc'); ?> +--ENV-- +XML_FILE=/book.xml +LOAD_OPTIONS=0 +EXPECTED_RESULT=1 +--FILE_EXTERNAL-- +domdocumentloadxml_test_method.php +--EXPECT-- diff --git a/ext/dom/tests/DOMDocument_loadXML_error1.phpt b/ext/dom/tests/DOMDocument_loadXML_error1.phpt new file mode 100644 index 000000000..52d44ea29 --- /dev/null +++ b/ext/dom/tests/DOMDocument_loadXML_error1.phpt @@ -0,0 +1,26 @@ +--TEST-- +Test DOMDocument::loadXML() detects not-well formed XML +--DESCRIPTION-- +This test verifies the method detects an opening and ending tag mismatch +Environment variables used in the test: +- XML_FILE: the xml file to load +- LOAD_OPTIONS: the second parameter to pass to the method +- EXPECTED_RESULT: the expected result +--CREDITS-- +Antonio Diaz Ruiz <dejalatele@gmail.com> +--INI-- +assert.bail=true +--SKIPIF-- +<?php include('skipif.inc'); ?> +--ENV-- +XML_FILE=/not_well_formed.xml +LOAD_OPTIONS=0 +EXPECTED_RESULT=0 +--FILE_EXTERNAL-- +domdocumentloadxml_test_method.php +--EXPECTF-- +Warning: DOMDocument::load%r(XML){0,1}%r(): Opening and ending tag mismatch: title line 5 and book %s + +Warning: DOMDocument::load%r(XML){0,1}%r(): expected '>' %s + +Warning: DOMDocument::load%r(XML){0,1}%r(): Premature end of data in tag books %s diff --git a/ext/dom/tests/DOMDocument_loadXML_error2.phpt b/ext/dom/tests/DOMDocument_loadXML_error2.phpt new file mode 100644 index 000000000..6ac4193da --- /dev/null +++ b/ext/dom/tests/DOMDocument_loadXML_error2.phpt @@ -0,0 +1,30 @@ +--TEST-- +Test DOMDocument::loadXML() detects not-well formed XML +--DESCRIPTION-- +This test verifies the method detects attributes values not closed between " or ' +Environment variables used in the test: +- XML_FILE: the xml file to load +- LOAD_OPTIONS: the second parameter to pass to the method +- EXPECTED_RESULT: the expected result +--CREDITS-- +Antonio Diaz Ruiz <dejalatele@gmail.com> +--INI-- +assert.bail=true +--SKIPIF-- +<?php include('skipif.inc'); ?> +--ENV-- +XML_FILE=/not_well_formed2.xml +LOAD_OPTIONS=0 +EXPECTED_RESULT=0 +--FILE_EXTERNAL-- +domdocumentloadxml_test_method.php +--EXPECTF-- +Warning: DOMDocument::load%r(XML){0,1}%r(): AttValue: " or ' expected %s + +Warning: DOMDocument::load%r(XML){0,1}%r(): attributes construct error %s + +Warning: DOMDocument::load%r(XML){0,1}%r(): Couldn't find end of Start Tag book %s + +Warning: DOMDocument::load%r(XML){0,1}%r(): Opening and ending tag mismatch: books %s + +Warning: DOMDocument::load%r(XML){0,1}%r(): Extra content at the end of the document %s diff --git a/ext/dom/tests/DOMDocument_loadXML_error3.phpt b/ext/dom/tests/DOMDocument_loadXML_error3.phpt new file mode 100644 index 000000000..07f7ca773 --- /dev/null +++ b/ext/dom/tests/DOMDocument_loadXML_error3.phpt @@ -0,0 +1,22 @@ +--TEST-- +Test DOMDocument::loadXML() detects not-well formed XML +--DESCRIPTION-- +This test verifies the method detects a typo in tag names +Environment variables used in the test: +- XML_FILE: the xml file to load +- LOAD_OPTIONS: the second parameter to pass to the method +- EXPECTED_RESULT: the expected result +--CREDITS-- +Antonio Diaz Ruiz <dejalatele@gmail.com> +--INI-- +assert.bail=true +--SKIPIF-- +<?php include('skipif.inc'); ?> +--ENV-- +XML_FILE=/not_well_formed3.xml +LOAD_OPTIONS=0 +EXPECTED_RESULT=0 +--FILE_EXTERNAL-- +domdocumentloadxml_test_method.php +--EXPECTF-- +Warning: DOMDocument::load%r(XML){0,1}%r(): Opening and ending tag mismatch: boOk line 8 and book %s diff --git a/ext/dom/tests/DOMDocument_loadXML_error4.phpt b/ext/dom/tests/DOMDocument_loadXML_error4.phpt new file mode 100644 index 000000000..e35d3dcea --- /dev/null +++ b/ext/dom/tests/DOMDocument_loadXML_error4.phpt @@ -0,0 +1,22 @@ +--TEST-- +Test DOMDocument::loadXML() detects not-well formed XML +--DESCRIPTION-- +This test verifies the method detects an unsupported xml version +Environment variables used in the test: +- XML_FILE: the xml file to load +- LOAD_OPTIONS: the second parameter to pass to the method +- EXPECTED_RESULT: the expected result +--CREDITS-- +Antonio Diaz Ruiz <dejalatele@gmail.com> +--INI-- +assert.bail=true +--SKIPIF-- +<?php include('skipif.inc'); ?> +--ENV-- +XML_FILE=/not_well_formed4.xml +LOAD_OPTIONS=0 +EXPECTED_RESULT=0 +--FILE_EXTERNAL-- +domdocumentloadxml_test_method.php +--EXPECTF-- +Warning: DOMDocument::load%r(XML){0,1}%r(): Unsupported version '3.1' %s diff --git a/ext/dom/tests/DOMDocument_loadXML_error5.phpt b/ext/dom/tests/DOMDocument_loadXML_error5.phpt new file mode 100644 index 000000000..a4aa1858f --- /dev/null +++ b/ext/dom/tests/DOMDocument_loadXML_error5.phpt @@ -0,0 +1,22 @@ +--TEST-- +Test DOMDocument::loadXML() detects not-well formed XML +--DESCRIPTION-- +This test verifies the method detects extra content at the end of the document +Environment variables used in the test: +- XML_FILE: the xml file to load +- LOAD_OPTIONS: the second parameter to pass to the method +- EXPECTED_RESULT: the expected result +--CREDITS-- +Antonio Diaz Ruiz <dejalatele@gmail.com> +--INI-- +assert.bail=true +--SKIPIF-- +<?php include('skipif.inc'); ?> +--ENV-- +XML_FILE=/not_well_formed5.xml +LOAD_OPTIONS=0 +EXPECTED_RESULT=0 +--FILE_EXTERNAL-- +domdocumentloadxml_test_method.php +--EXPECTF-- +Warning: DOMDocument::load%r(XML){0,1}%r(): Extra content at the end of the document %s diff --git a/ext/dom/tests/DOMDocument_loadXML_variation1.phpt b/ext/dom/tests/DOMDocument_loadXML_variation1.phpt new file mode 100644 index 000000000..558137526 --- /dev/null +++ b/ext/dom/tests/DOMDocument_loadXML_variation1.phpt @@ -0,0 +1,21 @@ +--TEST-- +Test DOMDocument::loadXML() with LIBXML_DTDLOAD option +--DESCRIPTION-- +This test verifies the right behaviour of the LIBXML_DTDLOAD constant +Environment variables used in the test: +- XML_FILE: the xml file to load +- LOAD_OPTIONS: the second parameter to pass to the method +- EXPECTED_RESULT: the expected result +--CREDITS-- +Antonio Diaz Ruiz <dejalatele@gmail.com> +--INI-- +assert.bail=true +--SKIPIF-- +<?php include('skipif.inc'); ?> +--ENV-- +XML_FILE=/book_with_dtd2.xml +LOAD_OPTIONS=LIBXML_DTDLOAD +EXPECTED_RESULT=1 +--FILE_EXTERNAL-- +domdocumentloadxml_test_method.php +--EXPECT-- diff --git a/ext/dom/tests/DOMDocument_loadXML_variation2.phpt b/ext/dom/tests/DOMDocument_loadXML_variation2.phpt new file mode 100644 index 000000000..71f638efc --- /dev/null +++ b/ext/dom/tests/DOMDocument_loadXML_variation2.phpt @@ -0,0 +1,22 @@ +--TEST-- +Test DOMDocument::loadXML() with LIBXML_DTDVALID option +--DESCRIPTION-- +This test verifies the right behaviour of the LIBXML_DTDVALID constant +Environment variables used in the test: +- XML_FILE: the xml file to load +- LOAD_OPTIONS: the second parameter to pass to the method +- EXPECTED_RESULT: the expected result +--CREDITS-- +Antonio Diaz Ruiz <dejalatele@gmail.com> +--INI-- +assert.bail=true +--SKIPIF-- +<?php include('skipif.inc'); ?> +--ENV-- +XML_FILE=/wrong_book_with_dtd2.xml +LOAD_OPTIONS=LIBXML_DTDVALID +EXPECTED_RESULT=1 +--FILE_EXTERNAL-- +domdocumentloadxml_test_method.php +--EXPECTF-- +Warning: DOMDocument::load%r(XML){0,1}%r(): Element book content does not follow the DTD, expecting (title , author), got (title author author ) %s diff --git a/ext/dom/tests/DOMDocument_loadXML_variation3.phpt b/ext/dom/tests/DOMDocument_loadXML_variation3.phpt new file mode 100644 index 000000000..8e61ec4db --- /dev/null +++ b/ext/dom/tests/DOMDocument_loadXML_variation3.phpt @@ -0,0 +1,22 @@ +--TEST-- +Test DOMDocument::loadXML() with LIBXML_DTDVALID and LIBXML_NOERROR options +--DESCRIPTION-- +This test vrifies the right behaviour of the LIBXML_NOERROR constant +which avoids the display of the warning message +Environment variables used in the test: +- XML_FILE: the xml file to load +- LOAD_OPTIONS: the second parameter to pass to the method +- EXPECTED_RESULT: the expected result +--CREDITS-- +Antonio Diaz Ruiz <dejalatele@gmail.com> +--INI-- +assert.bail=true +--SKIPIF-- +<?php include('skipif.inc'); ?> +--ENV-- +XML_FILE=/wrong_book_with_dtd.xml +LOAD_OPTIONS=LIBXML_DTDVALID | LIBXML_NOERROR +EXPECTED_RESULT=1 +--FILE_EXTERNAL-- +domdocumentloadxml_test_method.php +--EXPECT-- diff --git a/ext/dom/tests/DOMDocument_loadXML_variation4.phpt b/ext/dom/tests/DOMDocument_loadXML_variation4.phpt new file mode 100644 index 000000000..4f1ea37c1 --- /dev/null +++ b/ext/dom/tests/DOMDocument_loadXML_variation4.phpt @@ -0,0 +1,32 @@ +--TEST-- +Test DOMDocument::loadXML() with LIBXML_DTDATTR, LIBXML_NOCDATA, LIBXML_NOENT, LIBXML_NOBLANKS +--DESCRIPTION-- +This test verifies the right behaviour of the following constants: +LIBXML_DTDATTR, LIBXML_NOCDATA, LIBXML_NOENT and LIBXML_NOBLANKS +Environment variables used in the test: +- XML_FILE: the xml file to load +- LOAD_OPTIONS: the second parameter to pass to the method +- EXPECTED_RESULT: the expected result +--CREDITS-- +Antonio Diaz Ruiz <dejalatele@gmail.com> +--INI-- +assert.bail=true +--SKIPIF-- +<?php include('skipif.inc'); ?> +--ENV-- +XML_FILE=/book_with_dtd2.xml +LOAD_OPTIONS=LIBXML_DTDATTR|LIBXML_NOCDATA|LIBXML_NOENT|LIBXML_NOBLANKS +EXPECTED_RESULT=1 +--FILE_EXTERNAL-- +domdocumentloadxml_test_method_savexml.php +--EXPECT-- +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE books [ +<!ENTITY entitest "entity is only for test purposes"> +<!ATTLIST title default CDATA "default title"> +<!ELEMENT books (book)*> +<!ELEMENT book (title , author)> +<!ELEMENT title (#PCDATA)> +<!ELEMENT author (#PCDATA)> +]> +<books><book><title default="default title">The Grapes of Wrath</title><author>John Steinbeck</author></book><book><title default="default title">The Pearl</title><author>John Steinbeck</author></book><book><title default="default title">entity is only for test purposes</title><author>data for test</author></book></books> diff --git a/ext/dom/tests/DOMDocument_load_basic.phpt b/ext/dom/tests/DOMDocument_load_basic.phpt new file mode 100644 index 000000000..6d70ed452 --- /dev/null +++ b/ext/dom/tests/DOMDocument_load_basic.phpt @@ -0,0 +1,21 @@ +--TEST-- +Test DOMDocument::load() basic behavior +--DESCRIPTION-- +This test verifies the basic behaviour of the method +Environment variables used in the test: +- XML_FILE: the xml file to load +- LOAD_OPTIONS: the second parameter to pass to the method +- EXPECTED_RESULT: the expected result +--CREDITS-- +Antonio Diaz Ruiz <dejalatele@gmail.com> +--INI-- +assert.bail=true +--SKIPIF-- +<?php include('skipif.inc'); ?> +--ENV-- +XML_FILE=/book.xml +LOAD_OPTIONS=0 +EXPECTED_RESULT=1 +--FILE_EXTERNAL-- +domdocumentload_test_method.php +--EXPECT-- diff --git a/ext/dom/tests/DOMDocument_load_error1.phpt b/ext/dom/tests/DOMDocument_load_error1.phpt new file mode 100644 index 000000000..2ac3f5097 --- /dev/null +++ b/ext/dom/tests/DOMDocument_load_error1.phpt @@ -0,0 +1,26 @@ +--TEST-- +Test DOMDocument::load() detects not-well formed XML +--DESCRIPTION-- +This test verifies the method detects an opening and ending tag mismatch +Environment variables used in the test: +- XML_FILE: the xml file to load +- LOAD_OPTIONS: the second parameter to pass to the method +- EXPECTED_RESULT: the expected result +--CREDITS-- +Antonio Diaz Ruiz <dejalatele@gmail.com> +--INI-- +assert.bail=true +--SKIPIF-- +<?php include('skipif.inc'); ?> +--ENV-- +XML_FILE=/not_well_formed.xml +LOAD_OPTIONS=0 +EXPECTED_RESULT=0 +--FILE_EXTERNAL-- +domdocumentload_test_method.php +--EXPECTF-- +Warning: DOMDocument::load%r(XML){0,1}%r(): Opening and ending tag mismatch: title line 5 and book %s + +Warning: DOMDocument::load%r(XML){0,1}%r(): expected '>' %s + +Warning: DOMDocument::load%r(XML){0,1}%r(): Premature end of data in tag books %s diff --git a/ext/dom/tests/DOMDocument_load_error2.phpt b/ext/dom/tests/DOMDocument_load_error2.phpt new file mode 100644 index 000000000..23a5e4827 --- /dev/null +++ b/ext/dom/tests/DOMDocument_load_error2.phpt @@ -0,0 +1,30 @@ +--TEST-- +Test DOMDocument::load() detects not-well formed XML +--DESCRIPTION-- +This test verifies the method detects attributes values not closed between " or ' +Environment variables used in the test: +- XML_FILE: the xml file to load +- LOAD_OPTIONS: the second parameter to pass to the method +- EXPECTED_RESULT: the expected result +--CREDITS-- +Antonio Diaz Ruiz <dejalatele@gmail.com> +--INI-- +assert.bail=true +--SKIPIF-- +<?php include('skipif.inc'); ?> +--ENV-- +XML_FILE=/not_well_formed2.xml +LOAD_OPTIONS=0 +EXPECTED_RESULT=0 +--FILE_EXTERNAL-- +domdocumentload_test_method.php +--EXPECTF-- +Warning: DOMDocument::load%r(XML){0,1}%r(): AttValue: " or ' expected %s + +Warning: DOMDocument::load%r(XML){0,1}%r(): attributes construct error %s + +Warning: DOMDocument::load%r(XML){0,1}%r(): Couldn't find end of Start Tag book %s + +Warning: DOMDocument::load%r(XML){0,1}%r(): Opening and ending tag mismatch: books %s + +Warning: DOMDocument::load%r(XML){0,1}%r(): Extra content at the end of the document %s diff --git a/ext/dom/tests/DOMDocument_load_error3.phpt b/ext/dom/tests/DOMDocument_load_error3.phpt new file mode 100644 index 000000000..b9ac49c46 --- /dev/null +++ b/ext/dom/tests/DOMDocument_load_error3.phpt @@ -0,0 +1,22 @@ +--TEST-- +Test DOMDocument::load() detects not-well formed XML +--DESCRIPTION-- +This test verifies the method detects and opening and ending tag mismatch +Environment variables used in the test: +- XML_FILE: the xml file to load +- LOAD_OPTIONS: the second parameter to pass to the method +- EXPECTED_RESULT: the expected result +--CREDITS-- +Antonio Diaz Ruiz <dejalatele@gmail.com> +--INI-- +assert.bail=true +--SKIPIF-- +<?php include('skipif.inc'); ?> +--ENV-- +XML_FILE=/not_well_formed3.xml +LOAD_OPTIONS=0 +EXPECTED_RESULT=0 +--FILE_EXTERNAL-- +domdocumentload_test_method.php +--EXPECTF-- +Warning: DOMDocument::load%r(XML){0,1}%r(): Opening and ending tag mismatch: boOk line 8 and book %s diff --git a/ext/dom/tests/DOMDocument_load_error4.phpt b/ext/dom/tests/DOMDocument_load_error4.phpt new file mode 100644 index 000000000..ca9ed79a3 --- /dev/null +++ b/ext/dom/tests/DOMDocument_load_error4.phpt @@ -0,0 +1,22 @@ +--TEST-- +Test DOMDocument::load() detects not-well formed XML +--DESCRIPTION-- +This test verifies the method detects an unsupported xml version +Environment variables used in the test: +- XML_FILE: the xml file to load +- LOAD_OPTIONS: the second parameter to pass to the method +- EXPECTED_RESULT: the expected result +--CREDITS-- +Antonio Diaz Ruiz <dejalatele@gmail.com> +--INI-- +assert.bail=true +--SKIPIF-- +<?php include('skipif.inc'); ?> +--ENV-- +XML_FILE=/not_well_formed4.xml +LOAD_OPTIONS=0 +EXPECTED_RESULT=0 +--FILE_EXTERNAL-- +domdocumentload_test_method.php +--EXPECTF-- +Warning: DOMDocument::load%r(XML){0,1}%r(): Unsupported version '3.1' %s diff --git a/ext/dom/tests/DOMDocument_load_error5.phpt b/ext/dom/tests/DOMDocument_load_error5.phpt new file mode 100644 index 000000000..a374f9474 --- /dev/null +++ b/ext/dom/tests/DOMDocument_load_error5.phpt @@ -0,0 +1,22 @@ +--TEST-- +Test DOMDocument::load() detects not-well formed XML +--DESCRIPTION-- +This test verifies the method detects extra content at the end of the document +Environment variables used in the test: +- XML_FILE: the xml file to load +- LOAD_OPTIONS: the second parameter to pass to the method +- EXPECTED_RESULT: the expected result +--CREDITS-- +Antonio Diaz Ruiz <dejalatele@gmail.com> +--INI-- +assert.bail=true +--SKIPIF-- +<?php include('skipif.inc'); ?> +--ENV-- +XML_FILE=/not_well_formed5.xml +LOAD_OPTIONS=0 +EXPECTED_RESULT=0 +--FILE_EXTERNAL-- +domdocumentload_test_method.php +--EXPECTF-- +Warning: DOMDocument::load%r(XML){0,1}%r(): Extra content at the end of the document %s diff --git a/ext/dom/tests/DOMDocument_load_variation1.phpt b/ext/dom/tests/DOMDocument_load_variation1.phpt new file mode 100644 index 000000000..b2b99e74c --- /dev/null +++ b/ext/dom/tests/DOMDocument_load_variation1.phpt @@ -0,0 +1,21 @@ +--TEST-- +Test DOMDocument::load() with LIBXML_DTDLOAD option +--DESCRIPTION-- +This test verifies the right behaviour of the LIBXML_DTDLOAD constant +Environment variables used in the test: +- XML_FILE: the xml file to load +- LOAD_OPTIONS: the second parameter to pass to the method +- EXPECTED_RESULT: the expected result +--CREDITS-- +Antonio Diaz Ruiz <dejalatele@gmail.com> +--INI-- +assert.bail=true +--SKIPIF-- +<?php include('skipif.inc'); ?> +--ENV-- +XML_FILE=/book_with_dtd.xml +LOAD_OPTIONS=LIBXML_DTDLOAD +EXPECTED_RESULT=1 +--FILE_EXTERNAL-- +domdocumentload_test_method.php +--EXPECT-- diff --git a/ext/dom/tests/DOMDocument_load_variation2.phpt b/ext/dom/tests/DOMDocument_load_variation2.phpt new file mode 100644 index 000000000..c8460e55e --- /dev/null +++ b/ext/dom/tests/DOMDocument_load_variation2.phpt @@ -0,0 +1,22 @@ +--TEST-- +Test DOMDocument::load() with LIBXML_DTDVALID option +--DESCRIPTION-- +This test verifies the right behaviour of the LIBXML_DTDVALID constant +Environment variables used in the test: +- XML_FILE: the xml file to load +- LOAD_OPTIONS: the second parameter to pass to the method +- EXPECTED_RESULT: the expected result +--CREDITS-- +Antonio Diaz Ruiz <dejalatele@gmail.com> +--INI-- +assert.bail=true +--SKIPIF-- +<?php include('skipif.inc'); ?> +--ENV-- +XML_FILE=/wrong_book_with_dtd.xml +LOAD_OPTIONS=LIBXML_DTDVALID +EXPECTED_RESULT=1 +--FILE_EXTERNAL-- +domdocumentload_test_method.php +--EXPECTF-- +Warning: DOMDocument::load%r(XML){0,1}%r(): Element book content does not follow the DTD, expecting (title , author), got (title author author ) %s diff --git a/ext/dom/tests/DOMDocument_load_variation3.phpt b/ext/dom/tests/DOMDocument_load_variation3.phpt new file mode 100644 index 000000000..77801d475 --- /dev/null +++ b/ext/dom/tests/DOMDocument_load_variation3.phpt @@ -0,0 +1,22 @@ +--TEST-- +Test DOMDocument::load() with LIBXML_DTDVALID and LIBXML_NOERROR options +--DESCRIPTION-- +This test vrifies the right behaviour of the LIBXML_NOERROR constant +which avoids the display of the warning message +Environment variables used in the test: +- XML_FILE: the xml file to load +- LOAD_OPTIONS: the second parameter to pass to the method +- EXPECTED_RESULT: the expected result +--CREDITS-- +Antonio Diaz Ruiz <dejalatele@gmail.com> +--INI-- +assert.bail=true +--SKIPIF-- +<?php include('skipif.inc'); ?> +--ENV-- +XML_FILE=/wrong_book_with_dtd.xml +LOAD_OPTIONS=LIBXML_DTDVALID | LIBXML_NOERROR +EXPECTED_RESULT=1 +--FILE_EXTERNAL-- +domdocumentload_test_method.php +--EXPECT-- diff --git a/ext/dom/tests/DOMDocument_load_variation4.phpt b/ext/dom/tests/DOMDocument_load_variation4.phpt new file mode 100644 index 000000000..3bf7ccc04 --- /dev/null +++ b/ext/dom/tests/DOMDocument_load_variation4.phpt @@ -0,0 +1,25 @@ +--TEST-- +Test DOMDocument::load() with LIBXML_DTDATTR, LIBXML_NOCDATA, LIBXML_NOENT, LIBXML_NOBLANKS +--DESCRIPTION-- +This test verifies the right behaviour of the following constants: +LIBXML_DTDATTR, LIBXML_NOCDATA, LIBXML_NOENT and LIBXML_NOBLANKS +Environment variables used in the test: +- XML_FILE: the xml file to load +- LOAD_OPTIONS: the second parameter to pass to the method +- EXPECTED_RESULT: the expected result +--CREDITS-- +Antonio Diaz Ruiz <dejalatele@gmail.com> +--INI-- +assert.bail=true +--SKIPIF-- +<?php include('skipif.inc'); ?> +--ENV-- +XML_FILE=/book_with_dtd.xml +LOAD_OPTIONS=LIBXML_DTDATTR|LIBXML_NOCDATA|LIBXML_NOENT|LIBXML_NOBLANKS +EXPECTED_RESULT=1 +--FILE_EXTERNAL-- +domdocumentload_test_method_savexml.php +--EXPECT-- +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE books SYSTEM "books.dtd"> +<books><book><title default="default title">The Grapes of Wrath</title><author>John Steinbeck</author></book><book><title default="default title">The Pearl</title><author>John Steinbeck</author></book><book><title default="default title">entity is only for test purposes</title><author>data for test</author></book></books> diff --git a/ext/dom/tests/DOMDocument_schemaValidateSource_addAttrs.phpt b/ext/dom/tests/DOMDocument_schemaValidateSource_addAttrs.phpt new file mode 100644 index 000000000..994b94d0c --- /dev/null +++ b/ext/dom/tests/DOMDocument_schemaValidateSource_addAttrs.phpt @@ -0,0 +1,25 @@ +--TEST-- +DomDocument::schemaValidateSource() - Add missing attribute default values from schema +--CREDITS-- +Chris Wright <info@daverandom.com> +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php + +$doc = new DOMDocument; + +$doc->load(dirname(__FILE__)."/book-attr.xml"); + +$xsd = file_get_contents(dirname(__FILE__)."/book.xsd"); + +$doc->schemaValidateSource($xsd, LIBXML_SCHEMA_CREATE); + +foreach ($doc->getElementsByTagName('book') as $book) { + var_dump($book->getAttribute('is-hardback')); +} + +?> +--EXPECT-- +string(5) "false" +string(4) "true" diff --git a/ext/dom/tests/DOMDocument_schemaValidateSource_error4.phpt b/ext/dom/tests/DOMDocument_schemaValidateSource_error4.phpt index 65c8d8678..f841b8742 100644 --- a/ext/dom/tests/DOMDocument_schemaValidateSource_error4.phpt +++ b/ext/dom/tests/DOMDocument_schemaValidateSource_error4.phpt @@ -17,5 +17,5 @@ var_dump($result); ?> --EXPECTF-- -Warning: DOMDocument::schemaValidateSource() expects exactly 1 parameter, 0 given in %s.php on line %d +Warning: DOMDocument::schemaValidateSource() expects at least 1 parameter, 0 given in %s.php on line %d NULL diff --git a/ext/dom/tests/DOMDocument_schemaValidateSource_missingAttrs.phpt b/ext/dom/tests/DOMDocument_schemaValidateSource_missingAttrs.phpt new file mode 100644 index 000000000..7c98a74b1 --- /dev/null +++ b/ext/dom/tests/DOMDocument_schemaValidateSource_missingAttrs.phpt @@ -0,0 +1,25 @@ +--TEST-- +DomDocument::schemaValidateSource() - Don't add missing attribute default values from schema +--CREDITS-- +Chris Wright <info@daverandom.com> +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php + +$doc = new DOMDocument; + +$doc->load(dirname(__FILE__)."/book-attr.xml"); + +$xsd = file_get_contents(dirname(__FILE__)."/book.xsd"); + +$doc->schemaValidateSource($xsd); + +foreach ($doc->getElementsByTagName('book') as $book) { + var_dump($book->getAttribute('is-hardback')); +} + +?> +--EXPECT-- +string(0) "" +string(4) "true" diff --git a/ext/dom/tests/DOMDocument_schemaValidate_addAttrs.phpt b/ext/dom/tests/DOMDocument_schemaValidate_addAttrs.phpt new file mode 100644 index 000000000..e0b5251b2 --- /dev/null +++ b/ext/dom/tests/DOMDocument_schemaValidate_addAttrs.phpt @@ -0,0 +1,23 @@ +--TEST-- +DomDocument::schemaValidate() - Add missing attribute default values from schema +--CREDITS-- +Chris Wright <info@daverandom.com> +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php + +$doc = new DOMDocument; + +$doc->load(dirname(__FILE__)."/book-attr.xml"); + +$doc->schemaValidate(dirname(__FILE__)."/book.xsd", LIBXML_SCHEMA_CREATE); + +foreach ($doc->getElementsByTagName('book') as $book) { + var_dump($book->getAttribute('is-hardback')); +} + +?> +--EXPECT-- +string(5) "false" +string(4) "true" diff --git a/ext/dom/tests/DOMDocument_schemaValidate_error4.phpt b/ext/dom/tests/DOMDocument_schemaValidate_error4.phpt index d4817deca..9e4b6c4b7 100644 --- a/ext/dom/tests/DOMDocument_schemaValidate_error4.phpt +++ b/ext/dom/tests/DOMDocument_schemaValidate_error4.phpt @@ -17,5 +17,5 @@ var_dump($result); ?> --EXPECTF-- -Warning: DOMDocument::schemaValidate() expects exactly 1 parameter, 0 given in %s.php on line %d +Warning: DOMDocument::schemaValidate() expects at least 1 parameter, 0 given in %s.php on line %d NULL diff --git a/ext/dom/tests/DOMDocument_schemaValidate_missingAttrs.phpt b/ext/dom/tests/DOMDocument_schemaValidate_missingAttrs.phpt new file mode 100644 index 000000000..d253ad969 --- /dev/null +++ b/ext/dom/tests/DOMDocument_schemaValidate_missingAttrs.phpt @@ -0,0 +1,23 @@ +--TEST-- +DomDocument::schemaValidate() - Don't add missing attribute default values from schema +--CREDITS-- +Chris Wright <info@daverandom.com> +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php + +$doc = new DOMDocument; + +$doc->load(dirname(__FILE__)."/book-attr.xml"); + +$doc->schemaValidate(dirname(__FILE__)."/book.xsd"); + +foreach ($doc->getElementsByTagName('book') as $book) { + var_dump($book->getAttribute('is-hardback')); +} + +?> +--EXPECT-- +string(0) "" +string(4) "true" diff --git a/ext/dom/tests/book-attr.xml b/ext/dom/tests/book-attr.xml new file mode 100644 index 000000000..ba4298d09 --- /dev/null +++ b/ext/dom/tests/book-attr.xml @@ -0,0 +1,11 @@ +<?xml version="1.0" ?> +<books> + <book> + <title>The Grapes of Wrath</title> + <author>John Steinbeck</author> + </book> + <book is-hardback="true"> + <title>The Pearl</title> + <author>John Steinbeck</author> + </book> +</books> diff --git a/ext/dom/tests/book.xsd b/ext/dom/tests/book.xsd index 45986fc4b..6b4a8ea54 100755 --- a/ext/dom/tests/book.xsd +++ b/ext/dom/tests/book.xsd @@ -9,6 +9,7 @@ <xs:element name="title" type="xs:string"/> <xs:element name="author" type="xs:string"/> </xs:sequence> + <xs:attribute name="is-hardback" type="xs:boolean" default="false" use="optional" /> </xs:complexType> </xs:element> </xs:sequence> diff --git a/ext/dom/tests/book_with_dtd.xml b/ext/dom/tests/book_with_dtd.xml new file mode 100644 index 000000000..de12e9210 --- /dev/null +++ b/ext/dom/tests/book_with_dtd.xml @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!DOCTYPE books SYSTEM "books.dtd"> +<books> + <book> + <title>The Grapes of Wrath</title> + <author>John Steinbeck</author> + </book> + <book> + <title>The Pearl</title> + <author>John Steinbeck</author> + </book> + <book> + <title>&entitest;</title> + <author><![CDATA[data for test]]></author> + </book> +</books> diff --git a/ext/dom/tests/book_with_dtd2.xml b/ext/dom/tests/book_with_dtd2.xml new file mode 100644 index 000000000..aeb4f0b80 --- /dev/null +++ b/ext/dom/tests/book_with_dtd2.xml @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!DOCTYPE books [ +<!ENTITY entitest "entity is only for test purposes"> +<!ATTLIST title default CDATA "default title"> +<!ELEMENT books (book*)> +<!ELEMENT book (title, author)> +<!ELEMENT title (#PCDATA)> +<!ELEMENT author (#PCDATA)> +]> +<books> + <book> + <title>The Grapes of Wrath</title> + <author>John Steinbeck</author> + </book> + <book> + <title>The Pearl</title> + <author>John Steinbeck</author> + </book> + <book> + <title>&entitest;</title> + <author><![CDATA[data for test]]></author> + </book> +</books> diff --git a/ext/dom/tests/books.dtd b/ext/dom/tests/books.dtd new file mode 100644 index 000000000..b3f03c1c1 --- /dev/null +++ b/ext/dom/tests/books.dtd @@ -0,0 +1,7 @@ +<!ENTITY entitest "entity is only for test purposes"> +<!ATTLIST title + default CDATA "default title"> + <!ELEMENT books (book*)> + <!ELEMENT book (title, author)> + <!ELEMENT title (#PCDATA)> + <!ELEMENT author (#PCDATA)> diff --git a/ext/dom/tests/bug44648.phpt b/ext/dom/tests/bug44648.phpt index d04f590ac..4ff7ac389 100644 --- a/ext/dom/tests/bug44648.phpt +++ b/ext/dom/tests/bug44648.phpt @@ -1,5 +1,5 @@ --TEST-- -Bug #44648 (Attribute names not checked for wellformedness) +Bug #44648 (Attribute names not checked for well formedness) --SKIPIF-- <?php require_once('skipif.inc'); ?> --FILE-- diff --git a/ext/dom/tests/domdocumentload_test_method.php b/ext/dom/tests/domdocumentload_test_method.php new file mode 100644 index 000000000..7afce15c3 --- /dev/null +++ b/ext/dom/tests/domdocumentload_test_method.php @@ -0,0 +1,12 @@ +<?php +include(dirname(__FILE__) . '/domdocumentload_utilities.php'); + +$doc = new DOMDocument(); + +$libxml_options = libxml_options_to_int(getenv('LOAD_OPTIONS')); + +$result = $doc->load(dirname(__FILE__) . getenv('XML_FILE'), $libxml_options); + +$expectedResult = (bool) getenv('EXPECTED_RESULT'); +assert('$result === $expectedResult'); +?> diff --git a/ext/dom/tests/domdocumentload_test_method_savexml.php b/ext/dom/tests/domdocumentload_test_method_savexml.php new file mode 100644 index 000000000..8ffd94452 --- /dev/null +++ b/ext/dom/tests/domdocumentload_test_method_savexml.php @@ -0,0 +1,14 @@ +<?php +include(dirname(__FILE__) . '/domdocumentload_utilities.php'); + +$doc = new DOMDocument(); + +$libxml_options = libxml_options_to_int(getenv('LOAD_OPTIONS')); + +$result = $doc->load(dirname(__FILE__) . getenv('XML_FILE'), $libxml_options); + +$expectedResult = (bool) getenv('EXPECTED_RESULT'); +assert('$result === $expectedResult'); + +echo $doc->saveXML(); +?> diff --git a/ext/dom/tests/domdocumentload_utilities.php b/ext/dom/tests/domdocumentload_utilities.php new file mode 100644 index 000000000..efd1e5a1a --- /dev/null +++ b/ext/dom/tests/domdocumentload_utilities.php @@ -0,0 +1,16 @@ +<?php + +function libxml_options_to_int($libxmlOptions) { + + $defined_constants = get_defined_constants(true); + $env_array = explode('|', $libxmlOptions); + $libxml_constants = array_intersect_key($defined_constants['libxml'], array_flip($env_array)); + + $sum = 0; + foreach($libxml_constants as $value) { + $sum = $sum|$value; + } + + return $sum; +} +?> diff --git a/ext/dom/tests/domdocumentloadxml_test_method.php b/ext/dom/tests/domdocumentloadxml_test_method.php new file mode 100644 index 000000000..7c4be85cf --- /dev/null +++ b/ext/dom/tests/domdocumentloadxml_test_method.php @@ -0,0 +1,12 @@ +<?php +include(dirname(__FILE__) . '/domdocumentload_utilities.php'); + +$doc = new DOMDocument(); + +$libxml_options = libxml_options_to_int(getenv('LOAD_OPTIONS')); +$result = $doc->loadXML(file_get_contents(dirname(__FILE__) . getenv('XML_FILE')), + $libxml_options); + +$expectedResult = (bool) getenv('EXPECTED_RESULT'); +assert('$result === $expectedResult'); +?> diff --git a/ext/dom/tests/domdocumentloadxml_test_method_savexml.php b/ext/dom/tests/domdocumentloadxml_test_method_savexml.php new file mode 100644 index 000000000..550219fb7 --- /dev/null +++ b/ext/dom/tests/domdocumentloadxml_test_method_savexml.php @@ -0,0 +1,14 @@ +<?php +include(dirname(__FILE__) . '/domdocumentload_utilities.php'); + +$doc = new DOMDocument(); + +$libxml_options = libxml_options_to_int(getenv('LOAD_OPTIONS')); +$result = $doc->loadXML(file_get_contents(dirname(__FILE__) . getenv('XML_FILE')), + $libxml_options); + +$expectedResult = (bool) getenv('EXPECTED_RESULT'); +assert('$result === $expectedResult'); + +echo $doc->saveXML(); +?> diff --git a/ext/dom/tests/not_well_formed.xml b/ext/dom/tests/not_well_formed.xml new file mode 100644 index 000000000..d362e0c4b --- /dev/null +++ b/ext/dom/tests/not_well_formed.xml @@ -0,0 +1,12 @@ +<?xml version="1.0" ?> +<!-- Opening and ending tag mismatch --> +<books> + <book> + <title>The Grapes of Wrath + <author>John Steinbeck</author> + </book> + <book> + <title>The Pearl</title> + <author>John Steinbeck</author> + </book> +</books> diff --git a/ext/dom/tests/not_well_formed2.xml b/ext/dom/tests/not_well_formed2.xml new file mode 100644 index 000000000..da6b3bccb --- /dev/null +++ b/ext/dom/tests/not_well_formed2.xml @@ -0,0 +1,12 @@ +<?xml version="1.0" ?> +<!-- AttValue: " or ' expected --> +<books> + <book number=nine> + <title>The Grapes of Wrath</title> + <author>John Steinbeck</author> + </book> + <book> + <title>The Pearl</title> + <author>John Steinbeck</author> + </book> +</books> diff --git a/ext/dom/tests/not_well_formed3.xml b/ext/dom/tests/not_well_formed3.xml new file mode 100644 index 000000000..99b218907 --- /dev/null +++ b/ext/dom/tests/not_well_formed3.xml @@ -0,0 +1,12 @@ +<?xml version="1.0" ?> +<!-- Opening and ending tag mismatch --> +<books> + <book> + <title>The Grapes of Wrath</title> + <author>John Steinbeck</author> + </book> + <boOk> + <title>The Pearl</title> + <author>John Steinbeck</author> + </book> +</books> diff --git a/ext/dom/tests/not_well_formed4.xml b/ext/dom/tests/not_well_formed4.xml new file mode 100644 index 000000000..581b8bd96 --- /dev/null +++ b/ext/dom/tests/not_well_formed4.xml @@ -0,0 +1,12 @@ +<?xml version="3.1" ?> +<!-- Unsupported version '3.1' --> +<books> + <book> + <title>The Grapes of Wrath</title> + <author>John Steinbeck</author> + </book> + <book> + <title>The Pearl</title> + <author>John Steinbeck</author> + </book> +</books> diff --git a/ext/dom/tests/not_well_formed5.xml b/ext/dom/tests/not_well_formed5.xml new file mode 100644 index 000000000..f42ead83a --- /dev/null +++ b/ext/dom/tests/not_well_formed5.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" ?> +<!-- Extra content at the end of the document --> + <book> + <title>The Grapes of Wrath</title> + <author>John Steinbeck</author> + </book> + <book> + <title>The Pearl</title> + <author>John Steinbeck</author> + </book> diff --git a/ext/dom/tests/wrong_book_with_dtd.xml b/ext/dom/tests/wrong_book_with_dtd.xml new file mode 100644 index 000000000..3a2d48e35 --- /dev/null +++ b/ext/dom/tests/wrong_book_with_dtd.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!DOCTYPE books SYSTEM "books.dtd"> +<books> + <book> + <title>The Grapes of Wrath</title> + <author>John Steinbeck</author> + <author>John Steinbeck</author> + </book> + <book> + <title>The Pearl</title> + <author>John Steinbeck</author> + </book> +</books> diff --git a/ext/dom/tests/wrong_book_with_dtd2.xml b/ext/dom/tests/wrong_book_with_dtd2.xml new file mode 100644 index 000000000..6c49deb1f --- /dev/null +++ b/ext/dom/tests/wrong_book_with_dtd2.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!DOCTYPE books [ +<!ENTITY entitest "entity is only for test purposes"> +<!ATTLIST title default CDATA "default title"> +<!ELEMENT books (book)*> +<!ELEMENT book (title , author)> +<!ELEMENT title (#PCDATA)> +<!ELEMENT author (#PCDATA)> +]> +<books> + <book> + <title>The Grapes of Wrath</title> + <author>John Steinbeck</author> + <author>John Steinbeck</author> + </book> + <book> + <title>The Pearl</title> + <author>John Steinbeck</author> + </book> +</books> diff --git a/ext/dom/xpath.c b/ext/dom/xpath.c index cf556a350..d12ef3032 100644 --- a/ext/dom/xpath.c +++ b/ext/dom/xpath.c @@ -74,7 +74,7 @@ const zend_function_entry php_dom_xpath_class_functions[] = { static void dom_xpath_ext_function_php(xmlXPathParserContextPtr ctxt, int nargs, int type) /* {{{ */ { - zval **args; + zval **args = NULL; zval *retval; int result, i, ret; int error = 0; diff --git a/ext/enchant/config.m4 b/ext/enchant/config.m4 index cc40d0bd0..db8a69c5d 100755 --- a/ext/enchant/config.m4 +++ b/ext/enchant/config.m4 @@ -3,7 +3,7 @@ dnl $Id$ dnl PHP_ARG_WITH(enchant,for ENCHANT support, -[ --with-enchant[=DIR] Include enchant support. +[ --with-enchant[=DIR] Include enchant support. GNU Aspell version 1.1.3 or higher required.]) if test "$PHP_ENCHANT" != "no"; then diff --git a/ext/ereg/config0.m4 b/ext/ereg/config0.m4 index f4f819093..caec39d28 100644 --- a/ext/ereg/config0.m4 +++ b/ext/ereg/config0.m4 @@ -5,7 +5,7 @@ dnl dnl Check for regex library type dnl PHP_ARG_WITH(regex,, -[ --with-regex=TYPE regex library type: system, php. [TYPE=php] +[ --with-regex=TYPE Regex library type: system, php. [TYPE=php] WARNING: Do NOT use unless you know what you are doing!], php, no) case $PHP_REGEX in diff --git a/ext/fileinfo/tests/magic b/ext/fileinfo/tests/magic index 374734d57..aa75fb65b 100644 --- a/ext/fileinfo/tests/magic +++ b/ext/fileinfo/tests/magic @@ -11969,7 +11969,7 @@ #>65 string ZSYS (Pre-System 7 system file) #>65 string acf3 (Aldus FreeHand) #>65 string cdev (control panel) -#>65 string dfil (Desk Acessory suitcase) +#>65 string dfil (Desk Accessory suitcase) #>65 string libr (library) #>65 string nX^d (WriteNow word processor) #>65 string nX^w (WriteNow dictionary) diff --git a/ext/filter/config.m4 b/ext/filter/config.m4 index b4e32a21a..676f5d99e 100644 --- a/ext/filter/config.m4 +++ b/ext/filter/config.m4 @@ -5,7 +5,7 @@ PHP_ARG_ENABLE(filter, whether to enable input filter support, [ --disable-filter Disable input filter support], yes) PHP_ARG_WITH(pcre-dir, pcre install prefix, -[ --with-pcre-dir FILTER: pcre install prefix], no, no) +[ --with-pcre-dir FILTER: pcre install prefix], no, no) if test "$PHP_FILTER" != "no"; then diff --git a/ext/filter/filter.c b/ext/filter/filter.c index da951feb0..12aebcf36 100644 --- a/ext/filter/filter.c +++ b/ext/filter/filter.c @@ -243,7 +243,7 @@ PHP_MINIT_FUNCTION(filter) REGISTER_LONG_CONSTANT("FILTER_SANITIZE_STRIPPED", FILTER_SANITIZE_STRING, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("FILTER_SANITIZE_ENCODED", FILTER_SANITIZE_ENCODED, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("FILTER_SANITIZE_SPECIAL_CHARS", FILTER_SANITIZE_SPECIAL_CHARS, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("FILTER_SANITIZE_FULL_SPECIAL_CHARS", FILTER_SANITIZE_SPECIAL_CHARS, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("FILTER_SANITIZE_FULL_SPECIAL_CHARS", FILTER_SANITIZE_FULL_SPECIAL_CHARS, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("FILTER_SANITIZE_EMAIL", FILTER_SANITIZE_EMAIL, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("FILTER_SANITIZE_URL", FILTER_SANITIZE_URL, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("FILTER_SANITIZE_NUMBER_INT", FILTER_SANITIZE_NUMBER_INT, CONST_CS | CONST_PERSISTENT); diff --git a/ext/ftp/ftp.c b/ext/ftp/ftp.c index bde4792a1..0d6704f9d 100644 --- a/ext/ftp/ftp.c +++ b/ext/ftp/ftp.c @@ -39,7 +39,7 @@ #ifdef PHP_WIN32 #include <winsock2.h> #elif defined(NETWARE) -#ifdef USE_WINSOCK /* Modified to use Winsock (NOVSOCK2.H), atleast for now */ +#ifdef USE_WINSOCK /* Modified to use Winsock (NOVSOCK2.H), at least for now */ #include <novsock2.h> #else #include <sys/socket.h> @@ -612,7 +612,7 @@ ftp_chmod(ftpbuf_t *ftp, const int mode, const char *filename, const int filenam /* {{{ ftp_alloc */ int -ftp_alloc(ftpbuf_t *ftp, const int size, char **response) +ftp_alloc(ftpbuf_t *ftp, const long size, char **response) { char buffer[64]; @@ -620,8 +620,8 @@ ftp_alloc(ftpbuf_t *ftp, const int size, char **response) return 0; } - snprintf(buffer, sizeof(buffer) - 1, "%d", size); - + snprintf(buffer, sizeof(buffer) - 1, "%ld", size); + if (!ftp_putcmd(ftp, "ALLO", buffer)) { return 0; } @@ -787,7 +787,7 @@ ftp_pasv(ftpbuf_t *ftp, int pasv) /* {{{ ftp_get */ int -ftp_get(ftpbuf_t *ftp, php_stream *outstream, const char *path, ftptype_t type, int resumepos TSRMLS_DC) +ftp_get(ftpbuf_t *ftp, php_stream *outstream, const char *path, ftptype_t type, long resumepos TSRMLS_DC) { databuf_t *data = NULL; int lastch; @@ -808,11 +808,7 @@ ftp_get(ftpbuf_t *ftp, php_stream *outstream, const char *path, ftptype_t type, ftp->data = data; if (resumepos > 0) { - if (resumepos > 2147483647) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "PHP cannot handle files greater than 2147483647 bytes."); - goto bail; - } - snprintf(arg, sizeof(arg), "%u", resumepos); + snprintf(arg, sizeof(arg), "%ld", resumepos); if (!ftp_putcmd(ftp, "REST", arg)) { goto bail; } @@ -885,10 +881,10 @@ bail: /* {{{ ftp_put */ int -ftp_put(ftpbuf_t *ftp, const char *path, php_stream *instream, ftptype_t type, int startpos TSRMLS_DC) +ftp_put(ftpbuf_t *ftp, const char *path, php_stream *instream, ftptype_t type, long startpos TSRMLS_DC) { databuf_t *data = NULL; - int size; + long size; char *ptr; int ch; char arg[11]; @@ -905,11 +901,7 @@ ftp_put(ftpbuf_t *ftp, const char *path, php_stream *instream, ftptype_t type, i ftp->data = data; if (startpos > 0) { - if (startpos > 2147483647) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "PHP cannot handle files with a size greater than 2147483647 bytes."); - goto bail; - } - snprintf(arg, sizeof(arg), "%u", startpos); + snprintf(arg, sizeof(arg), "%ld", startpos); if (!ftp_putcmd(ftp, "REST", arg)) { goto bail; } @@ -966,7 +958,7 @@ bail: /* {{{ ftp_size */ -int +long ftp_size(ftpbuf_t *ftp, const char *path) { if (ftp == NULL) { @@ -981,7 +973,7 @@ ftp_size(ftpbuf_t *ftp, const char *path) if (!ftp_getresp(ftp) || ftp->resp != 213) { return -1; } - return atoi(ftp->inbuf); + return atol(ftp->inbuf); } /* }}} */ @@ -1143,7 +1135,7 @@ ftp_putcmd(ftpbuf_t *ftp, const char *cmd, const char *args) int ftp_readline(ftpbuf_t *ftp) { - int size, rcvd; + long size, rcvd; char *data, *eol; /* shift the extra to the front */ @@ -1236,7 +1228,8 @@ ftp_getresp(ftpbuf_t *ftp) int my_send(ftpbuf_t *ftp, php_socket_t s, void *buf, size_t len) { - int n, size, sent; + long size, sent; + int n; size = len; while (size) { @@ -1719,7 +1712,7 @@ bail: /* {{{ ftp_nb_get */ int -ftp_nb_get(ftpbuf_t *ftp, php_stream *outstream, const char *path, ftptype_t type, int resumepos TSRMLS_DC) +ftp_nb_get(ftpbuf_t *ftp, php_stream *outstream, const char *path, ftptype_t type, long resumepos TSRMLS_DC) { databuf_t *data = NULL; char arg[11]; @@ -1737,14 +1730,7 @@ ftp_nb_get(ftpbuf_t *ftp, php_stream *outstream, const char *path, ftptype_t typ } if (resumepos>0) { - /* We are working on an architecture that supports 64-bit integers - * since php is 32 bit by design, we bail out with warning - */ - if (resumepos > 2147483647) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "PHP cannot handle files greater than 2147483648 bytes."); - goto bail; - } - snprintf(arg, sizeof(arg), "%u", resumepos); + snprintf(arg, sizeof(arg), "%ld", resumepos); if (!ftp_putcmd(ftp, "REST", arg)) { goto bail; } @@ -1843,7 +1829,7 @@ bail: /* {{{ ftp_nb_put */ int -ftp_nb_put(ftpbuf_t *ftp, const char *path, php_stream *instream, ftptype_t type, int startpos TSRMLS_DC) +ftp_nb_put(ftpbuf_t *ftp, const char *path, php_stream *instream, ftptype_t type, long startpos TSRMLS_DC) { databuf_t *data = NULL; char arg[11]; @@ -1858,11 +1844,7 @@ ftp_nb_put(ftpbuf_t *ftp, const char *path, php_stream *instream, ftptype_t type goto bail; } if (startpos > 0) { - if (startpos > 2147483647) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "PHP cannot handle files with a size greater than 2147483647 bytes."); - goto bail; - } - snprintf(arg, sizeof(arg), "%u", startpos); + snprintf(arg, sizeof(arg), "%ld", startpos); if (!ftp_putcmd(ftp, "REST", arg)) { goto bail; } @@ -1899,7 +1881,7 @@ bail: int ftp_nb_continue_write(ftpbuf_t *ftp TSRMLS_DC) { - int size; + long size; char *ptr; int ch; diff --git a/ext/ftp/ftp.h b/ext/ftp/ftp.h index c7db45789..69de7dbb7 100644 --- a/ext/ftp/ftp.h +++ b/ext/ftp/ftp.h @@ -146,7 +146,7 @@ int ftp_chmod(ftpbuf_t *ftp, const int mode, const char *filename, const int fi * however some servers will not accept STOR or APPE until ALLO is confirmed. * If response is passed, it is estrdup()ed from ftp->inbuf and must be freed * or assigned to a zval returned to the user */ -int ftp_alloc(ftpbuf_t *ftp, const int size, char **response); +int ftp_alloc(ftpbuf_t *ftp, const long size, char **response); /* returns a NULL-terminated array of filenames in the given path * or NULL on error. the return array must be freed (but don't @@ -169,15 +169,15 @@ int ftp_pasv(ftpbuf_t *ftp, int pasv); /* retrieves a file and saves its contents to outfp * returns true on success, false on error */ -int ftp_get(ftpbuf_t *ftp, php_stream *outstream, const char *path, ftptype_t type, int resumepos TSRMLS_DC); +int ftp_get(ftpbuf_t *ftp, php_stream *outstream, const char *path, ftptype_t type, long resumepos TSRMLS_DC); /* stores the data from a file, socket, or process as a file on the remote server * returns true on success, false on error */ -int ftp_put(ftpbuf_t *ftp, const char *path, php_stream *instream, ftptype_t type, int startpos TSRMLS_DC); +int ftp_put(ftpbuf_t *ftp, const char *path, php_stream *instream, ftptype_t type, long startpos TSRMLS_DC); /* returns the size of the given file, or -1 on error */ -int ftp_size(ftpbuf_t *ftp, const char *path); +long ftp_size(ftpbuf_t *ftp, const char *path); /* returns the last modified time of the given file, or -1 on error */ time_t ftp_mdtm(ftpbuf_t *ftp, const char *path); @@ -194,12 +194,12 @@ int ftp_site(ftpbuf_t *ftp, const char *cmd); /* retrieves part of a file and saves its contents to outfp * returns true on success, false on error */ -int ftp_nb_get(ftpbuf_t *ftp, php_stream *outstream, const char *path, ftptype_t type, int resumepos TSRMLS_DC); +int ftp_nb_get(ftpbuf_t *ftp, php_stream *outstream, const char *path, ftptype_t type, long resumepos TSRMLS_DC); /* stores the data from a file, socket, or process as a file on the remote server * returns true on success, false on error */ -int ftp_nb_put(ftpbuf_t *ftp, const char *path, php_stream *instream, ftptype_t type, int startpos TSRMLS_DC); +int ftp_nb_put(ftpbuf_t *ftp, const char *path, php_stream *instream, ftptype_t type, long startpos TSRMLS_DC); /* continues a previous nb_(f)get command */ diff --git a/ext/ftp/php_ftp.c b/ext/ftp/php_ftp.c index 73071936e..da22e0b63 100644 --- a/ext/ftp/php_ftp.c +++ b/ext/ftp/php_ftp.c @@ -784,8 +784,8 @@ PHP_FUNCTION(ftp_nb_fget) ftptype_t xtype; php_stream *stream; char *file; - int file_len, ret; - long mode, resumepos=0; + int file_len; + long mode, resumepos=0, ret; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rrsl|l", &z_ftp, &z_file, &file, &file_len, &mode, &resumepos) == FAILURE) { return; @@ -968,9 +968,7 @@ PHP_FUNCTION(ftp_nb_get) RETURN_LONG(PHP_FTP_FAILED); } - if (ret == PHP_FTP_FINISHED) { - php_stream_close(outstream); - } + php_stream_close(outstream); RETURN_LONG(ret); } @@ -982,7 +980,7 @@ PHP_FUNCTION(ftp_nb_continue) { zval *z_ftp; ftpbuf_t *ftp; - int ret; + long ret; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &z_ftp) == FAILURE) { return; @@ -1120,7 +1118,7 @@ PHP_FUNCTION(ftp_put) ftpbuf_t *ftp; ftptype_t xtype; char *remote, *local; - int remote_len, local_len; + long remote_len, local_len; long mode, startpos=0; php_stream *instream; @@ -1173,8 +1171,8 @@ PHP_FUNCTION(ftp_nb_put) ftpbuf_t *ftp; ftptype_t xtype; char *remote, *local; - int remote_len, local_len, ret; - long mode, startpos=0; + int remote_len, local_len; + long mode, startpos=0, ret; php_stream *instream; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rppl|l", &z_ftp, &remote, &remote_len, &local, &local_len, &mode, &startpos) == FAILURE) { diff --git a/ext/ftp/tests/filesize_large.phpt b/ext/ftp/tests/filesize_large.phpt new file mode 100644 index 000000000..05f12a3e5 --- /dev/null +++ b/ext/ftp/tests/filesize_large.phpt @@ -0,0 +1,23 @@ +--TEST-- +Verify php can handle filesizes >32bit +--SKIPIF-- +<?php +require 'skipif.inc'; +if (2147483647 == PHP_INT_MAX) { + die('skip 64-bit only'); +} +?> +--FILE-- +<?php +require 'server.inc'; + +$ftp = ftp_connect('127.0.0.1', $port); +if (!$ftp) die("Couldn't connect to the server"); + +ftp_login($ftp, 'user', 'pass'); +var_dump(ftp_size($ftp, 'largefile')); + +ftp_close($ftp); +?> +--EXPECT-- +int(5368709120) diff --git a/ext/ftp/tests/ftp_nb_get_large.phpt b/ext/ftp/tests/ftp_nb_get_large.phpt new file mode 100644 index 000000000..3fbf2a483 --- /dev/null +++ b/ext/ftp/tests/ftp_nb_get_large.phpt @@ -0,0 +1,36 @@ +--TEST-- +Testing ftp_nb_fget can handle large files incl. resume +--SKIPIF-- +<?php +require 'skipif.inc'; +if (2147483647 == PHP_INT_MAX) { + die('skip ot supported on this system'); +} +if (disk_free_space(__DIR__) < 10*1024*1024*1024) { + die('not enough disk space'); +} +?> +--FILE-- +<?php +require 'server.inc'; + +$ftp = ftp_connect('127.0.0.1', $port); +ftp_login($ftp, 'user', 'pass'); +if (!$ftp) die("Couldn't connect to the server"); + +$local_file = dirname(__FILE__) . DIRECTORY_SEPARATOR . "localfile.txt"; +touch($local_file); +ftp_nb_get($ftp, $local_file, 'fget_large.txt', FTP_BINARY, 5368709119); +$fp = fopen($local_file, 'r'); +fseek($fp, 5368709119); +var_dump(fread($fp, 1)); +var_dump(filesize($local_file)); +fclose($fp); +?> +--CLEAN-- +<?php +@unlink(dirname(__FILE__) . DIRECTORY_SEPARATOR . "localfile.txt"); +?> +--EXPECT-- +string(1) "X" +int(5368709120) diff --git a/ext/ftp/tests/server.inc b/ext/ftp/tests/server.inc index 861788062..7dc8fa08d 100644 --- a/ext/ftp/tests/server.inc +++ b/ext/ftp/tests/server.inc @@ -357,7 +357,17 @@ if ($pid) { $transfer_type = $ascii? 'ASCII' : 'BINARY' ; fputs($fs, "Bar\r\n"); fputs($s, "226 Closing data Connection.\r\n"); - break; + break; + case "fget_large": + fputs($s, "150 File status okay; about to open data connection.\r\n"); + $transfer_type = $ascii? 'ASCII' : 'BINARY' ; + if ($GLOBALS['rest_pos'] == '5368709119') { + fputs($fs, "X"); + } else { + fputs($fs, "Y"); + } + fputs($s, "226 Closing data Connection.\r\n"); + break; default: fputs($s, "550 {$matches[1]}: No such file or directory \r\n"); break; @@ -393,11 +403,12 @@ if ($pid) { }elseif (preg_match('/^LIST no_exists\//', $buf, $matches)) { fputs($s, "425 Error establishing connection\r\n"); - }elseif (preg_match('/^REST \d+/', $buf, $matches)) { + }elseif (preg_match('/^REST (\d+)/', $buf, $matches)) { + $GLOBALS['rest_pos'] = $matches[1]; fputs($s, "350 OK\r\n"); - } - - else { + }elseif (preg_match('/^SIZE largefile/', $buf)) { + fputs($s, "213 5368709120\r\n"); + }else { fputs($s, "500 Syntax error, command unrecognized.\r\n"); dump_and_exit($buf); } @@ -407,4 +418,4 @@ if ($pid) { } fclose($socket); -?>
\ No newline at end of file +?> diff --git a/ext/gd/config.m4 b/ext/gd/config.m4 index 50660af6c..c9e080faa 100644 --- a/ext/gd/config.m4 +++ b/ext/gd/config.m4 @@ -7,11 +7,11 @@ dnl Configure options dnl PHP_ARG_WITH(gd, for GD support, -[ --with-gd[=DIR] Include GD support. DIR is the GD library base +[ --with-gd[=DIR] Include GD support. DIR is the GD library base install directory [BUNDLED]]) if test -z "$PHP_VPX_DIR"; then PHP_ARG_WITH(vpx-dir, for the location of libvpx, - [ --with-vpx-dir[=DIR] GD: Set the path to libvpx install prefix], no, no) + [ --with-vpx-dir[=DIR] GD: Set the path to libvpx install prefix], no, no) fi if test -z "$PHP_JPEG_DIR"; then @@ -39,10 +39,10 @@ PHP_ARG_WITH(t1lib, for T1lib support, [ --with-t1lib[=DIR] GD: Include T1lib support. T1lib version >= 5.0.0 required], no, no) PHP_ARG_ENABLE(gd-native-ttf, whether to enable truetype string function in GD, -[ --enable-gd-native-ttf GD: Enable TrueType string function], no, no) +[ --enable-gd-native-ttf GD: Enable TrueType string function], no, no) PHP_ARG_ENABLE(gd-jis-conv, whether to enable JIS-mapped Japanese font support in GD, -[ --enable-gd-jis-conv GD: Enable JIS-mapped Japanese font support], no, no) +[ --enable-gd-jis-conv GD: Enable JIS-mapped Japanese font support], no, no) dnl dnl Checks for the configure options diff --git a/ext/gd/gd.c b/ext/gd/gd.c index 8f32ad506..fb258214a 100644 --- a/ext/gd/gd.c +++ b/ext/gd/gd.c @@ -2434,7 +2434,7 @@ static void _php_image_create_from(INTERNAL_FUNCTION_PARAMETERS, int image_type, fflush(fp); } -register_im: +/* register_im: */ if (im) { ZEND_REGISTER_RESOURCE(return_value, im, le_gd); php_stream_close(stream); diff --git a/ext/gd/libgd/gd.c b/ext/gd/libgd/gd.c index 7ed6617c5..54890bc17 100644 --- a/ext/gd/libgd/gd.c +++ b/ext/gd/libgd/gd.c @@ -3011,7 +3011,6 @@ void gdImageGetClip (gdImagePtr im, int *x1P, int *y1P, int *x2P, int *y2P) int gdImagePaletteToTrueColor(gdImagePtr src) { unsigned int y; - unsigned char alloc_y = 0; unsigned int yy; if (src == NULL) { diff --git a/ext/gettext/config.m4 b/ext/gettext/config.m4 index 02d436c6e..24dddd3a4 100644 --- a/ext/gettext/config.m4 +++ b/ext/gettext/config.m4 @@ -3,7 +3,7 @@ dnl $Id$ dnl PHP_ARG_WITH(gettext,for GNU gettext support, -[ --with-gettext[=DIR] Include GNU gettext support]) +[ --with-gettext[=DIR] Include GNU gettext support]) if test "$PHP_GETTEXT" != "no"; then for i in $PHP_GETTEXT /usr/local /usr; do diff --git a/ext/gmp/config.m4 b/ext/gmp/config.m4 index 9606b2f56..2140aaf70 100644 --- a/ext/gmp/config.m4 +++ b/ext/gmp/config.m4 @@ -3,7 +3,7 @@ dnl $Id$ dnl PHP_ARG_WITH(gmp, for GNU MP support, -[ --with-gmp[=DIR] Include GNU MP support]) +[ --with-gmp[=DIR] Include GNU MP support]) if test "$PHP_GMP" != "no"; then diff --git a/ext/gmp/gmp.c b/ext/gmp/gmp.c index f8c3a0773..e3a3563aa 100644 --- a/ext/gmp/gmp.c +++ b/ext/gmp/gmp.c @@ -1069,7 +1069,7 @@ ZEND_FUNCTION(gmp_powm) zval **base_arg, **exp_arg, **mod_arg; mpz_t *gmpnum_base, *gmpnum_exp, *gmpnum_mod, *gmpnum_result; int use_ui = 0; - int temp_base, temp_exp, temp_mod; + int temp_base = 0, temp_exp = 0, temp_mod; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ZZZ", &base_arg, &exp_arg, &mod_arg) == FAILURE){ return; diff --git a/ext/hash/config.m4 b/ext/hash/config.m4 index 79ac25e19..44c6d267b 100644 --- a/ext/hash/config.m4 +++ b/ext/hash/config.m4 @@ -2,7 +2,7 @@ dnl $Id$ dnl config.m4 for extension hash PHP_ARG_WITH(mhash, for mhash support, -[ --with-mhash[=DIR] Include mhash support]) +[ --with-mhash[=DIR] Include mhash support]) PHP_ARG_ENABLE(hash, whether to enable hash support, [ --disable-hash Disable hash support], yes) diff --git a/ext/hash/hash.c b/ext/hash/hash.c index 9cede1412..117221484 100644 --- a/ext/hash/hash.c +++ b/ext/hash/hash.c @@ -597,7 +597,7 @@ PHP_FUNCTION(hash_algos) array_init(return_value); for(zend_hash_internal_pointer_reset_ex(&php_hash_hashtable, &pos); - (type = zend_hash_get_current_key_ex(&php_hash_hashtable, &str, &str_len, &idx, 0, &pos)) != HASH_KEY_NON_EXISTANT; + (type = zend_hash_get_current_key_ex(&php_hash_hashtable, &str, &str_len, &idx, 0, &pos)) != HASH_KEY_NON_EXISTENT; zend_hash_move_forward_ex(&php_hash_hashtable, &pos)) { add_next_index_stringl(return_value, str, str_len-1, 1); } @@ -1042,7 +1042,7 @@ PHP_MINFO_FUNCTION(hash) long type; for(zend_hash_internal_pointer_reset_ex(&php_hash_hashtable, &pos); - (type = zend_hash_get_current_key_ex(&php_hash_hashtable, &str, NULL, &idx, 0, &pos)) != HASH_KEY_NON_EXISTANT; + (type = zend_hash_get_current_key_ex(&php_hash_hashtable, &str, NULL, &idx, 0, &pos)) != HASH_KEY_NON_EXISTENT; zend_hash_move_forward_ex(&php_hash_hashtable, &pos)) { s += slprintf(s, e - s, "%s ", str); } diff --git a/ext/iconv/config.m4 b/ext/iconv/config.m4 index d673b0adb..10d21ccc6 100644 --- a/ext/iconv/config.m4 +++ b/ext/iconv/config.m4 @@ -3,7 +3,7 @@ dnl $Id$ dnl PHP_ARG_WITH(iconv, for iconv support, -[ --without-iconv[=DIR] Exclude iconv support], yes) +[ --without-iconv[=DIR] Exclude iconv support], yes) if test "$PHP_ICONV" != "no"; then diff --git a/ext/imap/config.m4 b/ext/imap/config.m4 index 3ad7c107d..3efc24590 100644 --- a/ext/imap/config.m4 +++ b/ext/imap/config.m4 @@ -95,7 +95,7 @@ AC_DEFUN([PHP_IMAP_SSL_CHK], [ PHP_ARG_WITH(imap,for IMAP support, -[ --with-imap[=DIR] Include IMAP support. DIR is the c-client install prefix]) +[ --with-imap[=DIR] Include IMAP support. DIR is the c-client install prefix]) PHP_ARG_WITH(kerberos,for IMAP Kerberos support, [ --with-kerberos[=DIR] IMAP: Include Kerberos support. DIR is the Kerberos install prefix], no, no) diff --git a/ext/interbase/config.m4 b/ext/interbase/config.m4 index 603145ad6..dfd850b00 100644 --- a/ext/interbase/config.m4 +++ b/ext/interbase/config.m4 @@ -3,7 +3,7 @@ dnl $Id$ dnl PHP_ARG_WITH(interbase,for InterBase support, -[ --with-interbase[=DIR] Include InterBase support. DIR is the InterBase base +[ --with-interbase[=DIR] Include InterBase support. DIR is the InterBase base install directory [/usr/interbase]]) if test "$PHP_INTERBASE" != "no"; then diff --git a/ext/intl/breakiterator/breakiterator_class.cpp b/ext/intl/breakiterator/breakiterator_class.cpp index 7bf271a34..7ca7e94c9 100644 --- a/ext/intl/breakiterator/breakiterator_class.cpp +++ b/ext/intl/breakiterator/breakiterator_class.cpp @@ -245,32 +245,32 @@ ZEND_BEGIN_ARG_INFO_EX(ainfo_biter_void, 0, 0, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(ainfo_biter_locale, 0, 0, 0) - ZEND_ARG_INFO(0, "locale") + ZEND_ARG_INFO(0, locale) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(ainfo_biter_setText, 0, 0, 1) - ZEND_ARG_INFO(0, "text") + ZEND_ARG_INFO(0, text) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(ainfo_biter_next, 0, 0, 0) - ZEND_ARG_INFO(0, "offset") + ZEND_ARG_INFO(0, offset) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(ainfo_biter_offset, 0, 0, 1) - ZEND_ARG_INFO(0, "offset") + ZEND_ARG_INFO(0, offset) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(ainfo_biter_get_locale, 0, 0, 1) - ZEND_ARG_INFO(0, "locale_type") + ZEND_ARG_INFO(0, locale_type) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(ainfo_biter_getPartsIterator, 0, 0, 0) - ZEND_ARG_INFO(0, "key_type") + ZEND_ARG_INFO(0, key_type) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(ainfo_rbbi___construct, 0, 0, 1) - ZEND_ARG_INFO(0, "rules") - ZEND_ARG_INFO(0, "areCompiled") + ZEND_ARG_INFO(0, rules) + ZEND_ARG_INFO(0, areCompiled) ZEND_END_ARG_INFO() /* }}} */ diff --git a/ext/intl/collator/collator_convert.c b/ext/intl/collator/collator_convert.c index e989d4c65..2a3ac10fb 100644 --- a/ext/intl/collator/collator_convert.c +++ b/ext/intl/collator/collator_convert.c @@ -139,7 +139,7 @@ void collator_convert_hash_from_utf8_to_utf16( HashTable* hash, UErrorCode* stat zend_hash_internal_pointer_reset( hash ); while( ( hashKeyType = zend_hash_get_current_key( hash, &hashKey, &hashIndex, 0 ) ) - != HASH_KEY_NON_EXISTANT ) + != HASH_KEY_NON_EXISTENT ) { /* Convert current hash item from UTF-8 to UTF-16LE. */ collator_convert_hash_item_from_utf8_to_utf16( @@ -164,7 +164,7 @@ void collator_convert_hash_from_utf16_to_utf8( HashTable* hash, UErrorCode* stat zend_hash_internal_pointer_reset( hash ); while( ( hashKeyType = zend_hash_get_current_key( hash, &hashKey, &hashIndex, 0 ) ) - != HASH_KEY_NON_EXISTANT ) + != HASH_KEY_NON_EXISTENT ) { /* Convert current hash item from UTF-16LE to UTF-8. */ collator_convert_hash_item_from_utf16_to_utf8( diff --git a/ext/intl/grapheme/grapheme_util.c b/ext/intl/grapheme/grapheme_util.c index 883fa0391..c752b0237 100644 --- a/ext/intl/grapheme/grapheme_util.c +++ b/ext/intl/grapheme/grapheme_util.c @@ -130,7 +130,7 @@ void grapheme_substr_ascii(char *str, int str_len, int f, int l, int argc, char /* {{{ grapheme_strpos_utf16 - strrpos using utf16*/ int grapheme_strpos_utf16(unsigned char *haystack, int32_t haystack_len, unsigned char*needle, int32_t needle_len, int32_t offset, int32_t *puchar_pos, int f_ignore_case, int last TSRMLS_DC) { - UChar *uhaystack = NULL, *puhaystack, *uneedle = NULL; + UChar *uhaystack = NULL, *uneedle = NULL; int32_t uhaystack_len = 0, uneedle_len = 0, char_pos, ret_pos, offset_pos = 0; unsigned char u_break_iterator_buffer[U_BRK_SAFECLONE_BUFFERSIZE]; UBreakIterator* bi = NULL; diff --git a/ext/intl/resourcebundle/resourcebundle_class.c b/ext/intl/resourcebundle/resourcebundle_class.c index db46bf5b1..9c369bdec 100644 --- a/ext/intl/resourcebundle/resourcebundle_class.c +++ b/ext/intl/resourcebundle/resourcebundle_class.c @@ -161,8 +161,8 @@ PHP_FUNCTION( resourcebundle_create ) /* {{{ resourcebundle_array_fetch */ static void resourcebundle_array_fetch(zval *object, zval *offset, zval *return_value, int fallback TSRMLS_DC) { - int32_t meindex; - char * mekey; + int32_t meindex = 0; + char * mekey = NULL; long mekeylen; zend_bool is_numeric = 0; char *pbuf; diff --git a/ext/ldap/config.m4 b/ext/ldap/config.m4 index 58d994c10..3c8e23ea8 100644 --- a/ext/ldap/config.m4 +++ b/ext/ldap/config.m4 @@ -63,7 +63,7 @@ AC_DEFUN([PHP_LDAP_SASL_CHECKS], [ ]) PHP_ARG_WITH(ldap,for LDAP support, -[ --with-ldap[=DIR] Include LDAP support]) +[ --with-ldap[=DIR] Include LDAP support]) PHP_ARG_WITH(ldap-sasl,for LDAP Cyrus SASL support, [ --with-ldap-sasl[=DIR] LDAP: Include Cyrus SASL support], no, no) diff --git a/ext/libxml/libxml.c b/ext/libxml/libxml.c index b1cb45db7..354cb548a 100644 --- a/ext/libxml/libxml.c +++ b/ext/libxml/libxml.c @@ -44,6 +44,7 @@ #include <libxml/xmlsave.h> #ifdef LIBXML_SCHEMAS_ENABLED #include <libxml/relaxng.h> +#include <libxml/xmlschemas.h> #endif #include "php_libxml.h" @@ -798,6 +799,11 @@ static PHP_MINIT_FUNCTION(libxml) #endif REGISTER_LONG_CONSTANT("LIBXML_NOEMPTYTAG", LIBXML_SAVE_NOEMPTYTAG, CONST_CS | CONST_PERSISTENT); + /* Schema validation options */ +#if defined(LIBXML_SCHEMAS_ENABLED) && LIBXML_VERSION >= 20614 + REGISTER_LONG_CONSTANT("LIBXML_SCHEMA_CREATE", XML_SCHEMA_VAL_VC_I_CREATE, CONST_CS | CONST_PERSISTENT); +#endif + /* Additional constants for use with loading html */ #if LIBXML_VERSION >= 20707 REGISTER_LONG_CONSTANT("LIBXML_HTML_NOIMPLIED", HTML_PARSE_NOIMPLIED, CONST_CS | CONST_PERSISTENT); diff --git a/ext/mbstring/config.m4 b/ext/mbstring/config.m4 index 5d70d45b8..25bf23876 100644 --- a/ext/mbstring/config.m4 +++ b/ext/mbstring/config.m4 @@ -344,19 +344,19 @@ PHP_ARG_ENABLE(mbstring, whether to enable multibyte string support, [ --enable-mbstring Enable multibyte string support]) PHP_ARG_ENABLE([mbregex], [whether to enable multibyte regex support], -[ --disable-mbregex MBSTRING: Disable multibyte regex support], yes, no) +[ --disable-mbregex MBSTRING: Disable multibyte regex support], yes, no) PHP_ARG_ENABLE([mbregex_backtrack], [whether to check multibyte regex backtrack], [ --disable-mbregex-backtrack - MBSTRING: Disable multibyte regex backtrack check], yes, no) + MBSTRING: Disable multibyte regex backtrack check], yes, no) PHP_ARG_WITH(libmbfl, [for external libmbfl], [ --with-libmbfl[=DIR] MBSTRING: Use external libmbfl. DIR is the libmbfl base - install directory [BUNDLED]], no, no) + install directory [BUNDLED]], no, no) PHP_ARG_WITH(onig, [for external oniguruma], [ --with-onig[=DIR] MBSTRING: Use external oniguruma. DIR is the oniguruma install prefix. - If DIR is not set, the bundled oniguruma will be used], no, no) + If DIR is not set, the bundled oniguruma will be used], no, no) if test "$PHP_MBSTRING" != "no"; then AC_DEFINE([HAVE_MBSTRING],1,[whether to have multibyte string support]) diff --git a/ext/mbstring/libmbfl/filters/mbfilter_utf8.c b/ext/mbstring/libmbfl/filters/mbfilter_utf8.c index fcee61053..553970034 100644 --- a/ext/mbstring/libmbfl/filters/mbfilter_utf8.c +++ b/ext/mbstring/libmbfl/filters/mbfilter_utf8.c @@ -79,7 +79,7 @@ const struct mbfl_convert_vtbl vtbl_utf8_wchar = { mbfl_filt_conv_common_ctor, mbfl_filt_conv_common_dtor, mbfl_filt_conv_utf8_wchar, - mbfl_filt_conv_common_flush + mbfl_filt_conv_utf8_wchar_flush }; const struct mbfl_convert_vtbl vtbl_wchar_utf8 = { @@ -93,6 +93,17 @@ const struct mbfl_convert_vtbl vtbl_wchar_utf8 = { #define CK(statement) do { if ((statement) < 0) return (-1); } while (0) +int mbfl_filt_put_invalid_char(int c, mbfl_convert_filter *filter) +{ + int w; + w = c & MBFL_WCSGROUP_MASK; + w |= MBFL_WCSGROUP_THROUGH; + filter->status = 0; + filter->cache = 0; + CK((*filter->output_function)(w, filter->data)); +} + + /* * UTF-8 => wchar */ @@ -100,111 +111,104 @@ int mbfl_filt_conv_utf8_wchar(int c, mbfl_convert_filter *filter) { int s, c1, w = 0, flag = 0; - if (c < 0x80) { - if (filter->status != 0) { - w = (filter->cache & MBFL_WCSGROUP_MASK) | MBFL_WCSGROUP_THROUGH; - CK((*filter->output_function)(w, filter->data)); - filter->status = 0; - filter->cache = 0; - } - if (c >= 0) { +retry: + switch (filter->status & 0xff) { + case 0x00: + if (c < 0x80) { CK((*filter->output_function)(c, filter->data)); + } else if (c >= 0xc2 && c <= 0xdf) { /* 2byte code first char: 0xc2-0xdf */ + filter->status = 0x10; + filter->cache = c & 0x1f; + } else if (c >= 0xe0 && c <= 0xef) { /* 3byte code first char: 0xe0-0xef */ + filter->status = 0x20; + filter->cache = c & 0xf; + } else if (c >= 0xf0 && c <= 0xf4) { /* 3byte code first char: 0xf0-0xf4 */ + filter->status = 0x30; + filter->cache = c & 0x7; + } else { + mbfl_filt_put_invalid_char(c, filter); } - } else if (c < 0xc0) { - int status = filter->status & 0xff; - switch (status) { - case 0x10: /* 2byte code 2nd char: 0x80-0xbf */ - case 0x21: /* 3byte code 3rd char: 0x80-0xbf */ - case 0x32: /* 4byte code 4th char: 0x80-0xbf */ - filter->status = 0; - s = filter->cache | (c & 0x3f); + break; + case 0x10: /* 2byte code 2nd char: 0x80-0xbf */ + case 0x21: /* 3byte code 3rd char: 0x80-0xbf */ + case 0x32: /* 4byte code 4th char: 0x80-0xbf */ + filter->status = 0; + if (c >= 0x80 && c <= 0xbf) { + s = (filter->cache<<6) | (c & 0x3f); filter->cache = 0; - if ((status == 0x10 && s >= 0x80) || - (status == 0x21 && s >= 0x800 && (s < 0xd800 || s > 0xdfff)) || - (status == 0x32 && s >= 0x10000 && s < 0x110000)) { - CK((*filter->output_function)(s, filter->data)); - } else { - w = s & MBFL_WCSGROUP_MASK; - flag = 1; - } - break; - case 0x20: /* 3byte code 2nd char: 0:0xa0-0xbf,D:0x80-9F,1-C,E-F:0x80-0x9f */ - s = filter->cache | ((c & 0x3f) << 6); - c1 = (s >> 12) & 0xf; - if ((c1 == 0x0 && c >= 0xa0) || - (c1 == 0xd && c < 0xa0) || - (c1 > 0x0 && c1 != 0xd)) { - filter->cache = s; - filter->status++; - } else { - w = s & MBFL_WCSGROUP_MASK; - flag = 1; - } - break; - case 0x31: /* 4byte code 3rd char: 0x80-0xbf */ - filter->cache |= ((c & 0x3f) << 6); - filter->status++; - break; - case 0x30: /* 4byte code 2nd char: 0:0x90-0xbf,1-3:0x80-0xbf,4:0x80-0x8f */ - s = filter->cache | ((c & 0x3f) << 12); - c1 = (s >> 18) & 0x7; - if ((c1 == 0x0 && c >= 0x90) || - (c1 > 0x0 && c1 < 0x4) || - (c1 == 0x4 && c < 0x90)) { - filter->cache = s; - filter->status++; - } else { - w = s & MBFL_WCSGROUP_MASK; - flag = 1; - } - break; - default: - w = c & MBFL_WCSGROUP_MASK; - flag = 1; - break; + CK((*filter->output_function)(s, filter->data)); + } else { + mbfl_filt_put_invalid_char(filter->cache, filter); + goto retry; } - } else if (c < 0xc2) { /* invalid: 0xc0,0xc1 */ - w = c & MBFL_WCSGROUP_MASK; - flag = 1; - } else if (c < 0xe0) { /* 2byte code first char: 0xc2-0xdf */ - if (filter->status == 0x0) { - filter->status = 0x10; - filter->cache = (c & 0x1f) << 6; + break; + case 0x20: /* 3byte code 2nd char: 0:0xa0-0xbf,D:0x80-9F,1-C,E-F:0x80-0x9f */ + s = (filter->cache<<6) | (c & 0x3f); + c1 = filter->cache & 0xf; + + if ((c >= 0x80 && c <= 0xbf) && + ((c1 == 0x0 && c >= 0xa0) || + (c1 == 0xd && c < 0xa0) || + (c1 > 0x0 && c1 != 0xd))) { + filter->cache = s; + filter->status++; } else { - w = c & MBFL_WCSGROUP_MASK; - flag = 1; + mbfl_filt_put_invalid_char(filter->cache, filter); + goto retry; } - } else if (c < 0xf0) { /* 3byte code first char: 0xe0-0xef */ - if (filter->status == 0x0) { - filter->status = 0x20; - filter->cache = (c & 0xf) << 12; + break; + case 0x30: /* 4byte code 2nd char: 0:0x90-0xbf,1-3:0x80-0xbf,4:0x80-0x8f */ + s = (filter->cache<<6) | (c & 0x3f); + c1 = filter->cache & 0x7; + + if ((c >= 0x80 && c <= 0xbf) && + ((c1 == 0x0 && c >= 0x90) || + (c1 == 0x4 && c < 0x90) || + (c1 > 0x0 && c1 != 0x4))) { + filter->cache = s; + filter->status++; } else { - w = c & MBFL_WCSGROUP_MASK; - flag = 1; + mbfl_filt_put_invalid_char(filter->cache, filter); + goto retry; } - } else if (c < 0xf5) { /* 4byte code first char: 0xf0-0xf4 */ - if (filter->status == 0x0) { - filter->status = 0x30; - filter->cache = (c & 0x7) << 18; + break; + case 0x31: /* 4byte code 3rd char: 0x80-0xbf */ + if (c >= 0x80 && c <= 0xbf) { + filter->cache = (filter->cache<<6) | (c & 0x3f); + filter->status++; } else { - w = c & MBFL_WCSGROUP_MASK; - flag = 1; + mbfl_filt_put_invalid_char(filter->cache, filter); + goto retry; } - } else { - w = c & MBFL_WCSGROUP_MASK; - flag = 1; - } - - if (flag) { - w |= MBFL_WCSGROUP_THROUGH; - CK((*filter->output_function)(w, filter->data)); + break; + default: filter->status = 0; - filter->cache = 0; + break; } return c; } +int mbfl_filt_conv_utf8_wchar_flush(mbfl_convert_filter *filter) +{ + int status, cache; + + status = filter->status; + cache = filter->cache; + + filter->status = 0; + filter->cache = 0; + + if (status != 0) { + mbfl_filt_put_invalid_char(cache, filter); + } + + if (filter->flush_function != NULL) { + (*filter->flush_function)(filter->data); + } + return 0; +} + /* * wchar => UTF-8 */ diff --git a/ext/mbstring/libmbfl/filters/mbfilter_utf8.h b/ext/mbstring/libmbfl/filters/mbfilter_utf8.h index 07bf65502..970ace646 100644 --- a/ext/mbstring/libmbfl/filters/mbfilter_utf8.h +++ b/ext/mbstring/libmbfl/filters/mbfilter_utf8.h @@ -37,5 +37,6 @@ extern const struct mbfl_convert_vtbl vtbl_wchar_utf8; int mbfl_filt_conv_utf8_wchar(int c, mbfl_convert_filter *filter); int mbfl_filt_conv_wchar_utf8(int c, mbfl_convert_filter *filter); +int mbfl_filt_conv_utf8_wchar_flush(mbfl_convert_filter *filter); #endif /* MBFL_MBFILTER_UTF8_H */ diff --git a/ext/mbstring/libmbfl/filters/mbfilter_utf8_mobile.c b/ext/mbstring/libmbfl/filters/mbfilter_utf8_mobile.c index 62feca40b..f9b643c17 100644 --- a/ext/mbstring/libmbfl/filters/mbfilter_utf8_mobile.c +++ b/ext/mbstring/libmbfl/filters/mbfilter_utf8_mobile.c @@ -37,6 +37,7 @@ #include "mbfilter_sjis_mobile.h" extern int mbfl_filt_ident_utf8(int c, mbfl_identify_filter *filter); +extern int mbfl_filt_conv_utf8_wchar_flush(mbfl_convert_filter *filter); extern const unsigned char mblen_table_utf8[]; @@ -115,7 +116,7 @@ const struct mbfl_convert_vtbl vtbl_utf8_docomo_wchar = { mbfl_filt_conv_common_ctor, mbfl_filt_conv_common_dtor, mbfl_filt_conv_utf8_mobile_wchar, - mbfl_filt_conv_common_flush + mbfl_filt_conv_utf8_wchar_flush }; const struct mbfl_convert_vtbl vtbl_wchar_utf8_docomo = { @@ -133,7 +134,7 @@ const struct mbfl_convert_vtbl vtbl_utf8_kddi_a_wchar = { mbfl_filt_conv_common_ctor, mbfl_filt_conv_common_dtor, mbfl_filt_conv_utf8_mobile_wchar, - mbfl_filt_conv_common_flush + mbfl_filt_conv_utf8_wchar_flush }; const struct mbfl_convert_vtbl vtbl_wchar_utf8_kddi_a = { @@ -151,7 +152,7 @@ const struct mbfl_convert_vtbl vtbl_utf8_kddi_b_wchar = { mbfl_filt_conv_common_ctor, mbfl_filt_conv_common_dtor, mbfl_filt_conv_utf8_mobile_wchar, - mbfl_filt_conv_common_flush + mbfl_filt_conv_utf8_wchar_flush }; const struct mbfl_convert_vtbl vtbl_wchar_utf8_kddi_b = { @@ -169,7 +170,7 @@ const struct mbfl_convert_vtbl vtbl_utf8_sb_wchar = { mbfl_filt_conv_common_ctor, mbfl_filt_conv_common_dtor, mbfl_filt_conv_utf8_mobile_wchar, - mbfl_filt_conv_common_flush + mbfl_filt_conv_utf8_wchar_flush }; const struct mbfl_convert_vtbl vtbl_wchar_utf8_sb = { @@ -191,119 +192,97 @@ int mbfl_filt_conv_utf8_mobile_wchar(int c, mbfl_convert_filter *filter) int s, w = 0, flag = 0; int s1 = 0, c1 = 0, snd = 0; - if (c < 0x80) { - if (c >= 0) { +retry: + switch (filter->status & 0xff) { + case 0x00: + if (c < 0x80) { CK((*filter->output_function)(c, filter->data)); + } else if (c >= 0xc2 && c <= 0xdf) { /* 2byte code first char: 0xc2-0xdf */ + filter->status = 0x10; + filter->cache = c & 0x1f; + } else if (c >= 0xe0 && c <= 0xef) { /* 3byte code first char: 0xe0-0xef */ + filter->status = 0x20; + filter->cache = c & 0xf; + } else if (c >= 0xf0 && c <= 0xf4) { /* 3byte code first char: 0xf0-0xf4 */ + filter->status = 0x30; + filter->cache = c & 0x7; + } else { + mbfl_filt_put_invalid_char(c, filter); } + break; + case 0x10: /* 2byte code 2nd char: 0x80-0xbf */ + case 0x21: /* 3byte code 3rd char: 0x80-0xbf */ + case 0x32: /* 4byte code 4th char: 0x80-0xbf */ filter->status = 0; - } else if (c < 0xc0) { - int status = filter->status & 0xff; - switch (status) { - case 0x10: /* 2byte code 2nd char: 0x80-0xbf */ - case 0x21: /* 3byte code 3rd char: 0x80-0xbf */ - case 0x32: /* 4byte code 4th char: 0x80-0xbf */ - filter->status = 0; - s = filter->cache | (c & 0x3f); + if (c >= 0x80 && c <= 0xbf) { + s = (filter->cache<<6) | (c & 0x3f); filter->cache = 0; - if ((status == 0x10 && s >= 0x80) || - (status == 0x21 && s >= 0x800 && (s < 0xd800 || s > 0xdfff)) || - (status == 0x32 && s >= 0x10000 && s < 0x110000)) { - - if (filter->from->no_encoding == mbfl_no_encoding_utf8_docomo && - mbfilter_conv_r_map_tbl(s, &s1, mbfl_docomo2uni_pua, 4) > 0) { - s = mbfilter_sjis_emoji_docomo2unicode(s1, &snd); - } else if (filter->from->no_encoding == mbfl_no_encoding_utf8_kddi_a && - mbfilter_conv_r_map_tbl(s, &s1, mbfl_kddi2uni_pua, 7) > 0) { - s = mbfilter_sjis_emoji_kddi2unicode(s1, &snd); - } else if (filter->from->no_encoding == mbfl_no_encoding_utf8_kddi_b && - mbfilter_conv_r_map_tbl(s, &s1, mbfl_kddi2uni_pua_b, 8) > 0) { - s = mbfilter_sjis_emoji_kddi2unicode(s1, &snd); - } else if (filter->from->no_encoding == mbfl_no_encoding_utf8_sb && - mbfilter_conv_r_map_tbl(s, &s1, mbfl_sb2uni_pua, 6) > 0) { - s = mbfilter_sjis_emoji_sb2unicode(s1, &snd); - } - - if (snd > 0) { - CK((*filter->output_function)(snd, filter->data)); - } - CK((*filter->output_function)(s, filter->data)); - } else { - w = s & MBFL_WCSGROUP_MASK; - flag = 1; - } - break; - case 0x20: /* 3byte code 2nd char: 0:0xa0-0xbf,D:0x80-9F,1-C,E-F:0x80-0x9f */ - s = filter->cache | ((c & 0x3f) << 6); - c1 = (s >> 12) & 0xf; - if ((c1 == 0x0 && c >= 0xa0) || - (c1 == 0xd && c < 0xa0) || - (c1 > 0x0 && c1 != 0xd)) { - filter->cache = s; - filter->status++; - } else { - w = s & MBFL_WCSGROUP_MASK; - flag = 1; + + if (filter->from->no_encoding == mbfl_no_encoding_utf8_docomo && + mbfilter_conv_r_map_tbl(s, &s1, mbfl_docomo2uni_pua, 4) > 0) { + s = mbfilter_sjis_emoji_docomo2unicode(s1, &snd); + } else if (filter->from->no_encoding == mbfl_no_encoding_utf8_kddi_a && + mbfilter_conv_r_map_tbl(s, &s1, mbfl_kddi2uni_pua, 7) > 0) { + s = mbfilter_sjis_emoji_kddi2unicode(s1, &snd); + } else if (filter->from->no_encoding == mbfl_no_encoding_utf8_kddi_b && + mbfilter_conv_r_map_tbl(s, &s1, mbfl_kddi2uni_pua_b, 8) > 0) { + s = mbfilter_sjis_emoji_kddi2unicode(s1, &snd); + } else if (filter->from->no_encoding == mbfl_no_encoding_utf8_sb && + mbfilter_conv_r_map_tbl(s, &s1, mbfl_sb2uni_pua, 6) > 0) { + s = mbfilter_sjis_emoji_sb2unicode(s1, &snd); } - break; - case 0x31: /* 4byte code 3rd char: 0x80-0xbf */ - filter->cache |= ((c & 0x3f) << 6); - filter->status++; - break; - case 0x30: /* 4byte code 2nd char: 0:0x90-0xbf,1-3:0x80-0xbf,4:0x80-0x8f */ - s = filter->cache | ((c & 0x3f) << 12); - c1 = (s >> 18) & 0x7; - if ((c1 == 0x0 && c >= 0x90) || - (c1 > 0x0 && c1 < 0x4) || - (c1 == 0x4 && c < 0x90)) { - filter->cache = s; - filter->status++; - } else { - w = s & MBFL_WCSGROUP_MASK; - flag = 1; + + if (snd > 0) { + CK((*filter->output_function)(snd, filter->data)); } - break; - default: - w = c & MBFL_WCSGROUP_MASK; - flag = 1; - break; + CK((*filter->output_function)(s, filter->data)); + } else { + mbfl_filt_put_invalid_char(filter->cache, filter); + goto retry; } - } else if (c < 0xc2) { /* invalid: 0xc0,0xc1 */ - w = c & MBFL_WCSGROUP_MASK; - flag = 1; - } else if (c < 0xe0) { /* 2byte code first char: 0xc2-0xdf */ - if (filter->status == 0x0) { - filter->status = 0x10; - filter->cache = (c & 0x1f) << 6; + break; + case 0x20: /* 3byte code 2nd char: 0:0xa0-0xbf,D:0x80-9F,1-C,E-F:0x80-0x9f */ + s = (filter->cache<<6) | (c & 0x3f); + c1 = filter->cache & 0xf; + + if ((c >= 0x80 && c <= 0xbf) && + ((c1 == 0x0 && c >= 0xa0) || + (c1 == 0xd && c < 0xa0) || + (c1 > 0x0 && c1 != 0xd))) { + filter->cache = s; + filter->status++; } else { - w = c & MBFL_WCSGROUP_MASK; - flag = 1; + mbfl_filt_put_invalid_char(filter->cache, filter); + goto retry; } - } else if (c < 0xf0) { /* 3byte code first char: 0xe0-0xef */ - if (filter->status == 0x0) { - filter->status = 0x20; - filter->cache = (c & 0xf) << 12; + break; + case 0x30: /* 4byte code 2nd char: 0:0x90-0xbf,1-3:0x80-0xbf,4:0x80-0x8f */ + s = (filter->cache<<6) | (c & 0x3f); + c1 = filter->cache & 0x7; + + if ((c >= 0x80 && c <= 0xbf) && + ((c1 == 0x0 && c >= 0x90) || + (c1 == 0x4 && c < 0x90) || + (c1 > 0x0 && c1 != 0x4))) { + filter->cache = s; + filter->status++; } else { - w = c & MBFL_WCSGROUP_MASK; - flag = 1; + mbfl_filt_put_invalid_char(filter->cache, filter); + goto retry; } - } else if (c < 0xf5) { /* 4byte code first char: 0xf0-0xf4 */ - if (filter->status == 0x0) { - filter->status = 0x30; - filter->cache = (c & 0x7) << 18; + break; + case 0x31: /* 4byte code 3rd char: 0x80-0xbf */ + if (c >= 0x80 && c <= 0xbf) { + filter->cache = (filter->cache<<6) | (c & 0x3f); + filter->status++; } else { - w = c & MBFL_WCSGROUP_MASK; - flag = 1; + mbfl_filt_put_invalid_char(filter->cache, filter); + goto retry; } - } else { - w = c & MBFL_WCSGROUP_MASK; - flag = 1; - } - - if (flag) { - w |= MBFL_WCSGROUP_THROUGH; - CK((*filter->output_function)(w, filter->data)); + break; + default: filter->status = 0; - filter->cache = 0; + break; } return c; diff --git a/ext/mbstring/oniguruma/HISTORY b/ext/mbstring/oniguruma/HISTORY index 244cd3d15..7add6f9a9 100644 --- a/ext/mbstring/oniguruma/HISTORY +++ b/ext/mbstring/oniguruma/HISTORY @@ -878,7 +878,7 @@ History 2004/10/18: [impl] (thanks Imai Yasumasa) enclose #include <sys/types.h> by #ifndef __BORLANDC__. 2004/10/18: [bug] (thanks Imai Yasumasa) - memory acess violation in select_opt_exact_info(). + memory access violation in select_opt_exact_info(). 2004/09/25: [dist] fix doc/API and doc/API.ja. 2004/09/25: [bug] fix OP_SEMI_END_BUF process in match_at() for the case USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE diff --git a/ext/mbstring/tests/bug65045.phpt b/ext/mbstring/tests/bug65045.phpt new file mode 100644 index 000000000..03a090ded --- /dev/null +++ b/ext/mbstring/tests/bug65045.phpt @@ -0,0 +1,29 @@ +--TEST-- +Bug #65045: mb_convert_encoding breaks well-formed character +--SKIPIF-- +<?php extension_loaded('mbstring') or die('skip mbstring not available'); ?> +--FILE-- +<?php + +//declare(encoding = 'UTF-8'); +mb_internal_encoding('UTF-8'); + +$str = "\xF0\xA4\xAD". "\xF0\xA4\xAD\xA2"."\xF0\xA4\xAD\xA2"; +$expected = "\xEF\xBF\xBD"."\xF0\xA4\xAD\xA2"."\xF0\xA4\xAD\xA2"; + +$str2 = "\xF0\xA4\xAD\xA2"."\xF0\xA4\xAD\xA2"."\xF0\xA4\xAD"; +$expected2 = "\xF0\xA4\xAD\xA2"."\xF0\xA4\xAD\xA2"."\xEF\xBF\xBD"; + +mb_substitute_character(0xFFFD); +var_dump( + $expected === htmlspecialchars_decode(htmlspecialchars($str, ENT_SUBSTITUTE, 'UTF-8')), + $expected2 === htmlspecialchars_decode(htmlspecialchars($str2, ENT_SUBSTITUTE, 'UTF-8')), + $expected === mb_convert_encoding($str, 'UTF-8', 'UTF-8'), + $expected2 === mb_convert_encoding($str2, 'UTF-8', 'UTF-8') +); + +--EXPECT-- +bool(true) +bool(true) +bool(true) +bool(true)
\ No newline at end of file diff --git a/ext/mbstring/tests/illformed_utf_sequences.phpt b/ext/mbstring/tests/illformed_utf_sequences.phpt index b5b9d94db..378b956d6 100644 --- a/ext/mbstring/tests/illformed_utf_sequences.phpt +++ b/ext/mbstring/tests/illformed_utf_sequences.phpt @@ -25,28 +25,28 @@ var_dump(chk_enc("\x31\x32\x33", 0)); var_dump(chk_enc("\x41\x42\x43", 0)); var_dump(chk_enc("\xc0\xb1\xc0\xb2\xc0\xb3", 6)); var_dump(chk_enc("\xc1\x81\xc1\x82\xc1\x83", 6)); -var_dump(chk_enc("\xe0\x80\xb1\xe0\x80\xb2\xe0\x80\xb3", 6)); -var_dump(chk_enc("\xe0\x81\x81\xe0\x81\x82\xe0\x81\x83", 6)); -var_dump(chk_enc("\xf0\x80\x80\xb1\xf0\x80\x80\xb2\xf0\x80\x80\xb3", 9)); -var_dump(chk_enc("\xf0\x80\x81\x81\xf0\x80\x81\x82\xf0\x81\x83", 8)); +var_dump(chk_enc("\xe0\x80\xb1\xe0\x80\xb2\xe0\x80\xb3", 9)); +var_dump(chk_enc("\xe0\x81\x81\xe0\x81\x82\xe0\x81\x83", 9)); +var_dump(chk_enc("\xf0\x80\x80\xb1\xf0\x80\x80\xb2\xf0\x80\x80\xb3", 12)); +var_dump(chk_enc("\xf0\x80\x81\x81\xf0\x80\x81\x82\xf0\x81\x83", 11)); var_dump(chk_enc("\xf8\x80\x80\x80\xb1\xf8\x80\x80\x80\xb2\xf8\x80\x80\x80\xb3", 15)); var_dump(chk_enc("\xf8\x80\x80\x81\x81\xf8\x80\x80\x81\x82\xf8\x80\x80\x81\x83", 15)); var_dump(chk_enc("\xfc\x80\x80\x80\x80\xb1\xfc\x80\x80\x80\x80\xb2\xfc\x80\x80\x80\x80\xb3", 18)); var_dump(chk_enc("\xfc\x80\x80\x80\x81\x81\xfc\x80\x80\x80\x81\x82\xfc\x80\x80\x80\x81\x83", 18)); var_dump(chk_enc("\xc2\xa2\xc2\xa3\xc2\xa5", 0)); -var_dump(chk_enc("\xe0\x82\xa2\xe0\x82\xa3\xe0\x82\xa5", 6)); -var_dump(chk_enc("\xf0\x80\x82\xa2\xf0\x80\x82\xa3\xf0\x80\x82\xa5", 9)); +var_dump(chk_enc("\xe0\x82\xa2\xe0\x82\xa3\xe0\x82\xa5", 9)); +var_dump(chk_enc("\xf0\x80\x82\xa2\xf0\x80\x82\xa3\xf0\x80\x82\xa5", 12)); var_dump(chk_enc("\xf8\x80\x80\x82\xa2\xf8\x80\x80\x82\xa3\xf8\x80\x80\x82\xa5", 15)); var_dump(chk_enc("\xfc\x80\x80\x80\x82\xa2\xfc\x80\x80\x80\x82\xa3\xfc\x80\x80\x80\x82\xa5", 18)); var_dump(chk_enc("\xc1\xbf", 2)); var_dump(chk_enc("\xc2\x80", 0)); var_dump(chk_enc("\xdf\xbf", 0)); -var_dump(chk_enc("\xe0\x9f\xff", 2)); +var_dump(chk_enc("\xe0\x9f\xff", 3)); var_dump(chk_enc("\xe0\xa0\x80", 2)); var_dump(chk_enc("\xef\xbf\xbf", 0)); -var_dump(chk_enc("\xf0\x8f\xbf\xbf", 3)); +var_dump(chk_enc("\xf0\x8f\xbf\xbf", 4)); var_dump(chk_enc("\xf0\x90\x80\x80", 0)); var_dump(chk_enc("\xf7\xbf\xbf\xbf", 4)); var_dump(chk_enc("\xf8\x87\xbf\xbf\xbf", 5)); @@ -61,7 +61,7 @@ echo "UTF-8 and surrogates area\n"; $out = ''; $cnt = 0; for ($i = 0xd7ff; $i <= 0xe000; ++$i) { - $s = chk_enc(pack('C3', 0xe0 | ($i >> 12), 0x80 | ($i >> 6) & 0x3f, 0x80 | $i & 0x3f), 2); + $s = chk_enc(pack('C3', 0xe0 | ($i >> 12), 0x80 | ($i >> 6) & 0x3f, 0x80 | $i & 0x3f), 3); if ($s === false) { $cnt++; } else { diff --git a/ext/mbstring/tests/mb_http_output.phpt b/ext/mbstring/tests/mb_http_output.phpt index 7fb3335fe..6f149bfc9 100644 --- a/ext/mbstring/tests/mb_http_output.phpt +++ b/ext/mbstring/tests/mb_http_output.phpt @@ -4,7 +4,7 @@ mb_http_output() <?php extension_loaded('mbstring') or die('skip mbstring not available'); ?> --FILE-- <?php -//TODO: Add more encoding. Wrong paramter type test. +//TODO: Add more encoding. Wrong parameter type test. //$debug = true; ini_set('include_path', dirname(__FILE__)); include_once('common.inc'); diff --git a/ext/mcrypt/config.m4 b/ext/mcrypt/config.m4 index cc68d8627..ab954e649 100644 --- a/ext/mcrypt/config.m4 +++ b/ext/mcrypt/config.m4 @@ -21,7 +21,7 @@ AC_DEFUN([PHP_MCRYPT_CHECK_VERSION],[ PHP_ARG_WITH(mcrypt, for mcrypt support, -[ --with-mcrypt[=DIR] Include mcrypt support]) +[ --with-mcrypt[=DIR] Include mcrypt support]) if test "$PHP_MCRYPT" != "no"; then for i in $PHP_MCRYPT /usr/local /usr; do diff --git a/ext/mssql/config.m4 b/ext/mssql/config.m4 index 4231bb360..2a298af73 100644 --- a/ext/mssql/config.m4 +++ b/ext/mssql/config.m4 @@ -3,7 +3,7 @@ dnl $Id$ dnl PHP_ARG_WITH(mssql,for MSSQL support via FreeTDS, -[ --with-mssql[=DIR] Include MSSQL-DB support. DIR is the FreeTDS home +[ --with-mssql[=DIR] Include MSSQL-DB support. DIR is the FreeTDS home directory [/usr/local/freetds]]) if test "$PHP_MSSQL" != "no"; then diff --git a/ext/mssql/php_mssql.c b/ext/mssql/php_mssql.c index fbeaa60ef..d74f0829d 100644 --- a/ext/mssql/php_mssql.c +++ b/ext/mssql/php_mssql.c @@ -243,7 +243,12 @@ PHP_INI_BEGIN() STD_PHP_INI_ENTRY_EX("mssql.max_links", "-1", PHP_INI_SYSTEM, OnUpdateLong, max_links, zend_mssql_globals, mssql_globals, display_link_numbers) STD_PHP_INI_ENTRY_EX("mssql.min_error_severity", "10", PHP_INI_ALL, OnUpdateLong, cfg_min_error_severity, zend_mssql_globals, mssql_globals, display_link_numbers) STD_PHP_INI_ENTRY_EX("mssql.min_message_severity", "10", PHP_INI_ALL, OnUpdateLong, cfg_min_message_severity, zend_mssql_globals, mssql_globals, display_link_numbers) - STD_PHP_INI_BOOLEAN("mssql.compatability_mode", "0", PHP_INI_ALL, OnUpdateBool, compatability_mode, zend_mssql_globals, mssql_globals) + /* + mssql.compatAbility_mode (with typo) was used for relatively long time. + Unless it is fixed the old version is also kept for compatibility reasons. + */ + STD_PHP_INI_BOOLEAN("mssql.compatability_mode", "0", PHP_INI_ALL, OnUpdateBool, compatibility_mode, zend_mssql_globals, mssql_globals) + STD_PHP_INI_BOOLEAN("mssql.compatibility_mode", "0", PHP_INI_ALL, OnUpdateBool, compatibility_mode, zend_mssql_globals, mssql_globals) STD_PHP_INI_ENTRY_EX("mssql.connect_timeout", "5", PHP_INI_ALL, OnUpdateLong, connect_timeout, zend_mssql_globals, mssql_globals, display_link_numbers) STD_PHP_INI_ENTRY_EX("mssql.timeout", "60", PHP_INI_ALL, OnUpdateLong, timeout, zend_mssql_globals, mssql_globals, display_link_numbers) STD_PHP_INI_ENTRY_EX("mssql.textsize", "-1", PHP_INI_ALL, OnUpdateLong, textsize, zend_mssql_globals, mssql_globals, display_text_size) @@ -415,12 +420,12 @@ static void _mssql_bind_hash_dtor(void *data) */ static PHP_GINIT_FUNCTION(mssql) { - long compatability_mode; + long compatibility_mode; mssql_globals->num_persistent = 0; mssql_globals->get_column_content = php_mssql_get_column_content_with_type; - if (cfg_get_long("mssql.compatability_mode", &compatability_mode) == SUCCESS) { - if (compatability_mode) { + if (cfg_get_long("mssql.compatibility_mode", &compatibility_mode) == SUCCESS) { + if (compatibility_mode) { mssql_globals->get_column_content = php_mssql_get_column_content_without_type; } } diff --git a/ext/mssql/php_mssql.h b/ext/mssql/php_mssql.h index b73c84204..2b7d3e19c 100644 --- a/ext/mssql/php_mssql.h +++ b/ext/mssql/php_mssql.h @@ -166,7 +166,7 @@ ZEND_BEGIN_MODULE_GLOBALS(mssql) long min_error_severity, min_message_severity; long cfg_min_error_severity, cfg_min_message_severity; long connect_timeout, timeout; - zend_bool compatability_mode; + zend_bool compatibility_mode; void (*get_column_content)(mssql_link *mssql_ptr,int offset,zval *result,int column_type TSRMLS_DC); long textsize, textlimit, batchsize; zend_bool datetimeconvert; diff --git a/ext/mysql/config.m4 b/ext/mysql/config.m4 index 5968c4334..fd7f52ef3 100644 --- a/ext/mysql/config.m4 +++ b/ext/mysql/config.m4 @@ -40,13 +40,14 @@ AC_DEFUN([PHP_MYSQL_SOCKET_SEARCH], [ PHP_ARG_WITH(mysql, for MySQL support, -[ --with-mysql[=DIR] Include MySQL support. DIR is the MySQL base +[ --with-mysql[=DIR] Include MySQL support. DIR is the MySQL base directory, if no DIR is passed or the value is mysqlnd the MySQL native driver will be used]) PHP_ARG_WITH(mysql-sock, for specified location of the MySQL UNIX socket, -[ --with-mysql-sock[=DIR] MySQL/MySQLi/PDO_MYSQL: Location of the MySQL unix socket pointer. - If unspecified, the default locations are searched], no, no) +[ --with-mysql-sock[=SOCKPATH] + MySQL/MySQLi/PDO_MYSQL: Location of the MySQL unix socket pointer. + If unspecified, the default locations are searched], no, no) if test -z "$PHP_ZLIB_DIR"; then PHP_ARG_WITH(zlib-dir, for the location of libz, diff --git a/ext/mysql/php_mysql.c b/ext/mysql/php_mysql.c index 3b50dd5ed..88bb9ab21 100644 --- a/ext/mysql/php_mysql.c +++ b/ext/mysql/php_mysql.c @@ -1922,7 +1922,7 @@ PHP_FUNCTION(mysql_result) /* johannes TODO: -Do 2 zend_parse_paramters calls instead of type "z" and switch below +Do 2 zend_parse_parameters calls instead of type "z" and switch below Q: String or long first? */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl|z", &result, &row, &field) == FAILURE) { diff --git a/ext/mysqli/config.m4 b/ext/mysqli/config.m4 index 687b42289..f6c86e762 100644 --- a/ext/mysqli/config.m4 +++ b/ext/mysqli/config.m4 @@ -3,13 +3,14 @@ dnl $Id$ dnl config.m4 for extension mysqli PHP_ARG_WITH(mysqli, for MySQLi support, -[ --with-mysqli[=FILE] Include MySQLi support. FILE is the path +[ --with-mysqli[=FILE] Include MySQLi support. FILE is the path to mysql_config. If no value or mysqlnd is passed as FILE, the MySQL native driver will be used]) PHP_ARG_ENABLE(embedded_mysqli, whether to enable embedded MySQLi support, -[ --enable-embedded-mysqli MYSQLi: Enable embedded support - Note: Does not work with MySQL native driver!], no, no) +[ --enable-embedded-mysqli + MYSQLi: Enable embedded support + Note: Does not work with MySQL native driver!], no, no) if test "$PHP_MYSQLI" = "yes" || test "$PHP_MYSQLI" = "mysqlnd"; then dnl This needs to be set in any extension which wishes to use mysqlnd diff --git a/ext/mysqli/tests/mysqli_get_client_stats.phpt b/ext/mysqli/tests/mysqli_get_client_stats.phpt index ef5ef6ee6..a22fc58f5 100644 --- a/ext/mysqli/tests/mysqli_get_client_stats.phpt +++ b/ext/mysqli/tests/mysqli_get_client_stats.phpt @@ -166,7 +166,7 @@ mysqlnd.collect_memory_statistics=1 mysqli_get_client_stats_assert_gt('bytes_sent', $info, $expected, $test_counter); mysqli_get_client_stats_assert_gt('bytes_received', $info, $expected, $test_counter); - // real_data_* get incremeneted after mysqli_*fetch*() + // real_data_* get incremented after mysqli_*fetch*() mysqli_get_client_stats_assert_eq('bytes_received_real_data_normal', $info, "0", $test_counter); mysqli_get_client_stats_assert_eq('bytes_received_real_data_ps', $info, "0", $test_counter); diff --git a/ext/mysqlnd/config9.m4 b/ext/mysqlnd/config9.m4 index 3fc767b23..09aca5af8 100644 --- a/ext/mysqlnd/config9.m4 +++ b/ext/mysqlnd/config9.m4 @@ -8,11 +8,11 @@ PHP_ARG_ENABLE(mysqlnd, whether to enable mysqlnd, PHP_ARG_ENABLE(mysqlnd_compression_support, whether to disable compressed protocol support in mysqlnd, [ --disable-mysqlnd-compression-support - Disable support for the MySQL compressed protocol in mysqlnd], yes, no) + Disable support for the MySQL compressed protocol in mysqlnd], yes, no) if test -z "$PHP_ZLIB_DIR"; then PHP_ARG_WITH(zlib-dir, for the location of libz, - [ --with-zlib-dir[=DIR] mysqlnd: Set the path to libz install prefix], no, no) + [ --with-zlib-dir[=DIR] mysqlnd: Set the path to libz install prefix], no, no) fi dnl If some extension uses mysqlnd it will get compiled in PHP core diff --git a/ext/mysqlnd/mysqlnd.c b/ext/mysqlnd/mysqlnd.c index 1a898690e..b41e5424f 100644 --- a/ext/mysqlnd/mysqlnd.c +++ b/ext/mysqlnd/mysqlnd.c @@ -1225,6 +1225,7 @@ MYSQLND_METHOD(mysqlnd_conn_data, reap_query)(MYSQLND_CONN_DATA * conn TSRMLS_DC #include "php_network.h" +/* {{{ mysqlnd_stream_array_to_fd_set */ MYSQLND ** mysqlnd_stream_array_check_for_readiness(MYSQLND ** conn_array TSRMLS_DC) { int cnt = 0; @@ -1255,14 +1256,17 @@ MYSQLND ** mysqlnd_stream_array_check_for_readiness(MYSQLND ** conn_array TSRMLS } return ret; } +/* }}} */ -/* {{{ stream_select mysqlnd_stream_array_to_fd_set functions */ +/* {{{ mysqlnd_stream_array_to_fd_set */ static int mysqlnd_stream_array_to_fd_set(MYSQLND ** conn_array, fd_set * fds, php_socket_t * max_fd TSRMLS_DC) { php_socket_t this_fd; - int cnt = 0; + php_stream *stream = NULL; + unsigned int cnt = 0; MYSQLND **p = conn_array; + DBG_ENTER("mysqlnd_stream_array_to_fd_set"); while (*p) { /* get the fd. @@ -1270,7 +1274,9 @@ static int mysqlnd_stream_array_to_fd_set(MYSQLND ** conn_array, fd_set * fds, p * when casting. It is only used here so that the buffered data warning * is not displayed. * */ - if (SUCCESS == php_stream_cast((*p)->data->net->data->m.get_stream((*p)->data->net TSRMLS_CC), PHP_STREAM_AS_FD_FOR_SELECT | PHP_STREAM_CAST_INTERNAL, + stream = (*p)->data->net->data->m.get_stream((*p)->data->net TSRMLS_CC); + DBG_INF_FMT("conn=%llu stream=%p", (*p)->data->thread_id, stream); + if (stream != NULL && SUCCESS == php_stream_cast(stream, PHP_STREAM_AS_FD_FOR_SELECT | PHP_STREAM_CAST_INTERNAL, (void*)&this_fd, 1) && this_fd >= 0) { PHP_SAFE_FD_SET(this_fd, fds); @@ -1282,20 +1288,25 @@ static int mysqlnd_stream_array_to_fd_set(MYSQLND ** conn_array, fd_set * fds, p } p++; } - return cnt ? 1 : 0; + DBG_RETURN(cnt ? 1 : 0); } +/* }}} */ + +/* {{{ mysqlnd_stream_array_from_fd_set */ static int mysqlnd_stream_array_from_fd_set(MYSQLND ** conn_array, fd_set * fds TSRMLS_DC) { php_socket_t this_fd; + php_stream *stream = NULL; int ret = 0; zend_bool disproportion = FALSE; - - MYSQLND **fwd = conn_array, **bckwd = conn_array; + DBG_ENTER("mysqlnd_stream_array_from_fd_set"); while (*fwd) { - if (SUCCESS == php_stream_cast((*fwd)->data->net->data->m.get_stream((*fwd)->data->net TSRMLS_CC), PHP_STREAM_AS_FD_FOR_SELECT | PHP_STREAM_CAST_INTERNAL, + stream = (*fwd)->data->net->data->m.get_stream((*fwd)->data->net TSRMLS_CC); + DBG_INF_FMT("conn=%llu stream=%p", (*fwd)->data->thread_id, stream); + if (stream != NULL && SUCCESS == php_stream_cast(stream, PHP_STREAM_AS_FD_FOR_SELECT | PHP_STREAM_CAST_INTERNAL, (void*)&this_fd, 1) && this_fd >= 0) { if (PHP_SAFE_FD_ISSET(this_fd, fds)) { if (disproportion) { @@ -1312,7 +1323,7 @@ static int mysqlnd_stream_array_from_fd_set(MYSQLND ** conn_array, fd_set * fds } *bckwd = NULL;/* NULL-terminate the list */ - return ret; + DBG_RETURN(ret); } /* }}} */ diff --git a/ext/mysqlnd/mysqlnd_net.c b/ext/mysqlnd/mysqlnd_net.c index ba2b1745e..fabceb4c8 100644 --- a/ext/mysqlnd/mysqlnd_net.c +++ b/ext/mysqlnd/mysqlnd_net.c @@ -805,7 +805,7 @@ MYSQLND_METHOD(mysqlnd_net, consume_uneaten_data)(MYSQLND_NET * const net, enum /* Switch to non-blocking mode and try to consume something from the line, if possible, then continue. This saves us from looking for - the actuall place where out-of-order packets have been sent. + the actual place where out-of-order packets have been sent. If someone is completely sure that everything is fine, he can switch it off. */ diff --git a/ext/oci8/config.m4 b/ext/oci8/config.m4 index 34ae76c44..39c037548 100644 --- a/ext/oci8/config.m4 +++ b/ext/oci8/config.m4 @@ -103,7 +103,7 @@ dnl --with-oci8=shared,instantclient,/path/to/client/dir/lib dnl or dnl --with-oci8=shared,/path/to/oracle/home PHP_ARG_WITH(oci8, for Oracle Database OCI8 support, -[ --with-oci8[=DIR] Include Oracle Database OCI8 support. DIR defaults to \$ORACLE_HOME. +[ --with-oci8[=DIR] Include Oracle Database OCI8 support. DIR defaults to \$ORACLE_HOME. Use --with-oci8=instantclient,/path/to/instant/client/lib to use an Oracle Instant Client installation]) diff --git a/ext/odbc/config.m4 b/ext/odbc/config.m4 index 5be3288f3..14ec97bf3 100644 --- a/ext/odbc/config.m4 +++ b/ext/odbc/config.m4 @@ -101,7 +101,7 @@ dnl configure options dnl if test -z "$ODBC_TYPE"; then PHP_ARG_WITH(adabas,, -[ --with-adabas[=DIR] Include Adabas D support [/usr/local]]) +[ --with-adabas[=DIR] Include Adabas D support [/usr/local]]) if test "$PHP_ADABAS" != "no"; then AC_MSG_CHECKING([for Adabas support]) @@ -128,7 +128,7 @@ fi if test -z "$ODBC_TYPE"; then PHP_ARG_WITH(sapdb,, -[ --with-sapdb[=DIR] Include SAP DB support [/usr/local]]) +[ --with-sapdb[=DIR] Include SAP DB support [/usr/local]]) if test "$PHP_SAPDB" != "no"; then AC_MSG_CHECKING([for SAP DB support]) @@ -146,7 +146,7 @@ fi if test -z "$ODBC_TYPE"; then PHP_ARG_WITH(solid,, -[ --with-solid[=DIR] Include Solid support [/usr/local/solid]]) +[ --with-solid[=DIR] Include Solid support [/usr/local/solid]]) if test "$PHP_SOLID" != "no"; then AC_MSG_CHECKING(for Solid support) @@ -171,7 +171,7 @@ fi if test -z "$ODBC_TYPE"; then PHP_ARG_WITH(ibm-db2,, -[ --with-ibm-db2[=DIR] Include IBM DB2 support [/home/db2inst1/sqllib]]) +[ --with-ibm-db2[=DIR] Include IBM DB2 support [/home/db2inst1/sqllib]]) if test "$PHP_IBM_DB2" != "no"; then AC_MSG_CHECKING(for IBM DB2 support) @@ -208,7 +208,7 @@ fi if test -z "$ODBC_TYPE"; then PHP_ARG_WITH(ODBCRouter,, -[ --with-ODBCRouter[=DIR] Include ODBCRouter.com support [/usr]]) +[ --with-ODBCRouter[=DIR] Include ODBCRouter.com support [/usr]]) if test "$PHP_ODBCROUTER" != "no"; then AC_MSG_CHECKING(for ODBCRouter.com support) @@ -228,7 +228,7 @@ fi if test -z "$ODBC_TYPE"; then PHP_ARG_WITH(empress,, -[ --with-empress[=DIR] Include Empress support [\$EMPRESSPATH] +[ --with-empress[=DIR] Include Empress support [\$EMPRESSPATH] (Empress Version >= 8.60 required)]) if test "$PHP_EMPRESS" != "no"; then @@ -291,7 +291,7 @@ fi if test -z "$ODBC_TYPE"; then PHP_ARG_WITH(birdstep,, -[ --with-birdstep[=DIR] Include Birdstep support [/usr/local/birdstep]]) +[ --with-birdstep[=DIR] Include Birdstep support [/usr/local/birdstep]]) if test "$PHP_BIRDSTEP" != "no"; then AC_MSG_CHECKING(for Birdstep support) @@ -338,15 +338,14 @@ fi if test -z "$ODBC_TYPE"; then PHP_ARG_WITH(custom-odbc,, -[ --with-custom-odbc[=DIR] - Include user defined ODBC support. DIR is ODBC install base +[ --with-custom-odbc[=DIR] Include user defined ODBC support. DIR is ODBC install base directory [/usr/local]. Make sure to define CUSTOM_ODBC_LIBS and have some odbc.h in your include dirs. f.e. you should define following for Sybase SQL Anywhere 5.5.00 on QNX, prior to running this configure script: - CPPFLAGS=\"-DODBC_QNX -DSQLANY_BUG\" - LDFLAGS=-lunix - CUSTOM_ODBC_LIBS=\"-ldblib -lodbc\"]) + CPPFLAGS=\"-DODBC_QNX -DSQLANY_BUG\" + LDFLAGS=-lunix + CUSTOM_ODBC_LIBS=\"-ldblib -lodbc\"]) if test "$PHP_CUSTOM_ODBC" != "no"; then AC_MSG_CHECKING(for a custom ODBC support) @@ -366,7 +365,7 @@ fi if test -z "$ODBC_TYPE"; then PHP_ARG_WITH(iodbc,, -[ --with-iodbc[=DIR] Include iODBC support [/usr/local]]) +[ --with-iodbc[=DIR] Include iODBC support [/usr/local]]) if test "$PHP_IODBC" != "no"; then AC_MSG_CHECKING(for iODBC support) @@ -387,7 +386,7 @@ fi if test -z "$ODBC_TYPE"; then PHP_ARG_WITH(esoob,, -[ --with-esoob[=DIR] Include Easysoft OOB support [/usr/local/easysoft/oob/client]]) +[ --with-esoob[=DIR] Include Easysoft OOB support [/usr/local/easysoft/oob/client]]) if test "$PHP_ESOOB" != "no"; then AC_MSG_CHECKING(for Easysoft ODBC-ODBC Bridge support) @@ -407,7 +406,7 @@ fi if test -z "$ODBC_TYPE"; then PHP_ARG_WITH(unixODBC,, -[ --with-unixODBC[=DIR] Include unixODBC support [/usr/local]]) +[ --with-unixODBC[=DIR] Include unixODBC support [/usr/local]]) if test "$PHP_UNIXODBC" != "no"; then AC_MSG_CHECKING(for unixODBC support) @@ -428,7 +427,7 @@ fi if test -z "$ODBC_TYPE"; then PHP_ARG_WITH(dbmaker,, -[ --with-dbmaker[=DIR] Include DBMaker support]) +[ --with-dbmaker[=DIR] Include DBMaker support]) if test "$PHP_DBMAKER" != "no"; then AC_MSG_CHECKING(for DBMaker support) diff --git a/ext/opcache/Optimizer/block_pass.c b/ext/opcache/Optimizer/block_pass.c index b8c381406..7f874e7a4 100644 --- a/ext/opcache/Optimizer/block_pass.c +++ b/ext/opcache/Optimizer/block_pass.c @@ -558,6 +558,52 @@ static void zend_rebuild_access_path(zend_cfg *cfg, zend_op_array *op_array, int convert_to_string((v)); \ } +static void strip_nop(zend_code_block *block) +{ + zend_op *opline = block->start_opline; + zend_op *end, *new_end; + int new_len = 0; + + /* remove leading NOPs */ + while (block->len > 0 && block->start_opline->opcode == ZEND_NOP) { + if (block->len == 1) { + /* this block is all NOPs, join with following block */ + if (block->follow_to) { + delete_code_block(block); + } + return; + } + block->start_opline++; + block->start_opline_no++; + block->len--; + } + + /* strip the inside NOPs */ + opline = new_end = block->start_opline; + end = opline + block->len; + + while (opline < end) { + zend_op *src; + int len = 0; + + while (opline < end && opline->opcode == ZEND_NOP) { + opline++; + } + src = opline; + + while (opline < end && opline->opcode != ZEND_NOP) { + opline++; + } + len = opline - src; + + /* move up non-NOP opcodes */ + memmove(new_end, src, len*sizeof(zend_op)); + + new_end += len; + } + block->len = new_end - block->start_opline; +} + static void zend_optimize_block(zend_code_block *block, zend_op_array *op_array, char *used_ext TSRMLS_DC) { zend_op *opline = block->start_opline; @@ -1168,45 +1214,7 @@ static void zend_optimize_block(zend_code_block *block, zend_op_array *op_array, opline++; } - /* remove leading NOPs */ - while (block->len > 0 && block->start_opline->opcode == ZEND_NOP) { - if (block->len == 1) { - /* this block is all NOPs, join with following block */ - if (block->follow_to) { - delete_code_block(block); - } - if (op_array->T) { - efree(Tsource); - } - return; - } - block->start_opline++; - block->start_opline_no++; - block->len--; - } - - /* strip the inside NOPs */ - opline = block->start_opline; - end = opline + block->len; - while (opline < end) { - if (opline->opcode == ZEND_NOP) { - zend_op *nop = opline + 1; - int noplen; - while (nop < end && nop->opcode == ZEND_NOP) { - nop++; - } - noplen = nop-opline; - if (nop < end) { - /* move up non-NOP opcodes */ - memmove(opline, nop, (end-nop)*sizeof(zend_op)); - } else { - /* all NOPs up to the end, do nothing */ - } - block->len -= noplen; - end = block->start_opline + block->len; - } - opline++; - } + strip_nop(block); if (op_array->T) { efree(Tsource); diff --git a/ext/opcache/Optimizer/pass1_5.c b/ext/opcache/Optimizer/pass1_5.c index dc9e7319a..46406c383 100644 --- a/ext/opcache/Optimizer/pass1_5.c +++ b/ext/opcache/Optimizer/pass1_5.c @@ -388,6 +388,58 @@ if (ZEND_OPTIMIZER_PASS_1 & OPTIMIZATION_LEVEL) { } } break; + +#if ZEND_EXTENSION_API_NO >= PHP_5_5_X_API_NO + case ZEND_FETCH_R: + case ZEND_FETCH_W: + case ZEND_FETCH_RW: + case ZEND_FETCH_FUNC_ARG: + case ZEND_FETCH_IS: + case ZEND_FETCH_UNSET: + if (opline != op_array->opcodes && + (opline-1)->opcode == ZEND_BEGIN_SILENCE && + (opline->extended_value & ZEND_FETCH_TYPE_MASK) == ZEND_FETCH_LOCAL && + opline->op1_type == IS_CONST && + opline->op2_type == IS_UNUSED && + Z_TYPE(ZEND_OP1_LITERAL(opline)) == IS_STRING && + (Z_STRLEN(ZEND_OP1_LITERAL(opline)) != sizeof("this")-1 || + memcmp(Z_STRVAL(ZEND_OP1_LITERAL(opline)), "this", sizeof("this")) != 0)) { + + int var = opline->result.var; + int level = 0; + zend_op *op = opline + 1; + + while (op < end) { + if (op->opcode == ZEND_BEGIN_SILENCE) { + level++; + } else if (op->opcode == ZEND_END_SILENCE) { + if (level == 0) { + break; + } else { + level--; + } + } + if (op->op1_type == IS_VAR && op->op1.var == var) { + op->op1_type = IS_CV; + op->op1.var = zend_optimizer_lookup_cv(op_array, + Z_STRVAL(ZEND_OP1_LITERAL(opline)), + Z_STRLEN(ZEND_OP1_LITERAL(opline))); + MAKE_NOP(opline); + break; + } else if (op->op2_type == IS_VAR && op->op2.var == var) { + op->op2_type = IS_CV; + op->op2.var = zend_optimizer_lookup_cv(op_array, + Z_STRVAL(ZEND_OP1_LITERAL(opline)), + Z_STRLEN(ZEND_OP1_LITERAL(opline))); + MAKE_NOP(opline); + break; + } + op++; + } + } + break; +#endif + } opline++; i++; diff --git a/ext/opcache/Optimizer/zend_optimizer.c b/ext/opcache/Optimizer/zend_optimizer.c index a6450ab5c..1f411d5da 100644 --- a/ext/opcache/Optimizer/zend_optimizer.c +++ b/ext/opcache/Optimizer/zend_optimizer.c @@ -28,6 +28,35 @@ #define OPTIMIZATION_LEVEL \
ZCG(accel_directives).optimization_level
+#if ZEND_EXTENSION_API_NO >= PHP_5_5_X_API_NO
+static int zend_optimizer_lookup_cv(zend_op_array *op_array, char* name, int name_len)
+{
+ int i = 0;
+ ulong hash_value = zend_inline_hash_func(name, name_len+1);
+
+ while (i < op_array->last_var) {
+ if (op_array->vars[i].name == name ||
+ (op_array->vars[i].hash_value == hash_value &&
+ op_array->vars[i].name_len == name_len &&
+ memcmp(op_array->vars[i].name, name, name_len) == 0)) {
+ return i;
+ }
+ i++;
+ }
+ i = op_array->last_var;
+ op_array->last_var++;
+ op_array->vars = erealloc(op_array->vars, op_array->last_var * sizeof(zend_compiled_variable));
+ if (IS_INTERNED(name)) {
+ op_array->vars[i].name = name;
+ } else {
+ op_array->vars[i].name = estrndup(name, name_len);
+ }
+ op_array->vars[i].name_len = name_len;
+ op_array->vars[i].hash_value = hash_value;
+ return i;
+}
+#endif
+
#if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO
int zend_optimizer_add_literal(zend_op_array *op_array, const zval *zv TSRMLS_DC)
{
diff --git a/ext/opcache/README b/ext/opcache/README index 311001224..6c3cc746e 100644 --- a/ext/opcache/README +++ b/ext/opcache/README @@ -199,6 +199,10 @@ opcache.protect_memory (default "0") Protect the shared memory from unexpected writing during script execution. Useful for internal debugging only. +opcache.restrict_api (default "") + Allows calling OPcache API functions only from PHP scripts which path is + started from specified string. The default "" means no restriction. + opcache.mmap_base Mapping base of shared memory segments (for Windows only). All the PHP processes have to map shared memory into the same address space. This diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c index f05798e04..b5474c050 100644 --- a/ext/opcache/ZendAccelerator.c +++ b/ext/opcache/ZendAccelerator.c @@ -2163,7 +2163,9 @@ static void accel_fast_zval_ptr_dtor(zval **zval_ptr) case IS_CONSTANT_ARRAY: { TSRMLS_FETCH(); +#if ZEND_EXTENSION_API_NO >= PHP_5_3_X_API_NO GC_REMOVE_ZVAL_FROM_BUFFER(zvalue); +#endif if (zvalue->value.ht && (zvalue->value.ht != &EG(symbol_table))) { /* break possible cycles */ Z_TYPE_P(zvalue) = IS_NULL; @@ -2176,7 +2178,9 @@ static void accel_fast_zval_ptr_dtor(zval **zval_ptr) { TSRMLS_FETCH(); +#if ZEND_EXTENSION_API_NO >= PHP_5_3_X_API_NO GC_REMOVE_ZVAL_FROM_BUFFER(zvalue); +#endif Z_OBJ_HT_P(zvalue)->del_ref(zvalue TSRMLS_CC); } break; @@ -2652,12 +2656,9 @@ static void accel_free_ts_resources() #endif } -static void accel_shutdown(zend_extension *extension) +void accel_shutdown(TSRMLS_D) { zend_ini_entry *ini_entry; - TSRMLS_FETCH(); - - (void)extension; /* keep the compiler happy */ zend_accel_blacklist_shutdown(&accel_blacklist); @@ -2675,6 +2676,11 @@ static void accel_shutdown(zend_extension *extension) } #if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO +# ifndef ZTS + zend_hash_clean(CG(function_table)); + zend_hash_clean(CG(class_table)); + zend_hash_clean(EG(zend_constants)); +# endif CG(interned_strings_start) = orig_interned_strings_start; CG(interned_strings_end) = orig_interned_strings_end; zend_new_interned_string = orig_new_interned_string; @@ -2764,7 +2770,7 @@ ZEND_EXT_API zend_extension zend_extension_entry = { "http://www.zend.com/", /* URL */ "Copyright (c) 1999-2013", /* copyright */ accel_startup, /* startup */ - accel_shutdown, /* shutdown */ + NULL, /* shutdown */ accel_activate, /* per-script activation */ accel_deactivate, /* per-script deactivation */ NULL, /* message handler */ diff --git a/ext/opcache/ZendAccelerator.h b/ext/opcache/ZendAccelerator.h index 733e544e1..361b60b08 100644 --- a/ext/opcache/ZendAccelerator.h +++ b/ext/opcache/ZendAccelerator.h @@ -27,7 +27,7 @@ #endif #define ACCELERATOR_PRODUCT_NAME "Zend OPcache" -#define ACCELERATOR_VERSION "7.0.2-dev" +#define ACCELERATOR_VERSION "7.0.3-dev" /* 2 - added Profiler support, on 20010712 */ /* 3 - added support for Optimizer's encoded-only-files mode */ /* 4 - works with the new Optimizer, that supports the file format with licenses */ @@ -232,6 +232,7 @@ typedef struct _zend_accel_directives { #if ZEND_EXTENSION_API_NO > PHP_5_3_X_API_NO long interned_strings_buffer; #endif + char *restrict_api; } zend_accel_directives; typedef struct _zend_accel_globals { @@ -316,6 +317,7 @@ extern zend_accel_globals accel_globals; extern char *zps_api_failure_reason; +void accel_shutdown(TSRMLS_D); void zend_accel_schedule_restart(zend_accel_restart_reason reason TSRMLS_DC); void zend_accel_schedule_restart_if_necessary(zend_accel_restart_reason reason TSRMLS_DC); int zend_accel_invalidate(const char *filename, int filename_len, zend_bool force TSRMLS_DC); diff --git a/ext/opcache/config.m4 b/ext/opcache/config.m4 index f9c38b1f7..1798fe13f 100644 --- a/ext/opcache/config.m4 +++ b/ext/opcache/config.m4 @@ -3,7 +3,7 @@ dnl $Id$ dnl PHP_ARG_ENABLE(opcache, whether to enable Zend OPcache support, -[ --enable-opcache Enable Zend OPcache support], yes) +[ --enable-opcache Enable Zend OPcache support], yes) if test "$PHP_OPCACHE" != "no"; then @@ -357,7 +357,9 @@ extern int lock_file; # endif #endif int main() { return 0; } -], [], [AC_MSG_ERROR([Don't know how to define struct flock on this system[,] set --enable-opcache=no])], []) +], +[AC_MSG_RESULT([done])], +[AC_MSG_ERROR([Don't know how to define struct flock on this system[,] set --enable-opcache=no])], []) PHP_NEW_EXTENSION(opcache, ZendAccelerator.c \ diff --git a/ext/opcache/tests/blacklist.inc b/ext/opcache/tests/blacklist.inc new file mode 100644 index 000000000..a9db75141 --- /dev/null +++ b/ext/opcache/tests/blacklist.inc @@ -0,0 +1,3 @@ +<?php + echo "ok\n"; +?> diff --git a/ext/opcache/tests/blacklist.phpt b/ext/opcache/tests/blacklist.phpt index f4a34723a..57e4c306d 100644 --- a/ext/opcache/tests/blacklist.phpt +++ b/ext/opcache/tests/blacklist.phpt @@ -9,7 +9,13 @@ opcache.blacklist_filename={PWD}/opcache-*.blacklist --FILE-- <?php $conf = opcache_get_configuration(); -print_r($conf['blacklist']); +$conf = $conf['blacklist']; +$conf[3] = preg_replace("!^\\Q".dirname(__FILE__)."\\E!", "__DIR__", $conf[3]); +$conf[4] = preg_replace("!^\\Q".dirname(__FILE__)."\\E!", "__DIR__", $conf[4]); +print_r($conf); +include("blacklist.inc"); +$status = opcache_get_status(); +print_r(count($status['scripts'])); ?> --EXPECT-- Array @@ -17,4 +23,10 @@ Array [0] => /path/to/foo [1] => /path/to/foo2 [2] => /path/to/bar -)
\ No newline at end of file + [3] => __DIR__/blacklist.inc + [4] => __DIR__/current.php + [5] => /tmp/path/?nocache.inc + [6] => /tmp/path/*/somedir +) +ok +1 diff --git a/ext/opcache/tests/opcache-2.blacklist b/ext/opcache/tests/opcache-2.blacklist index 4f6580a77..575d9fab3 100644 --- a/ext/opcache/tests/opcache-2.blacklist +++ b/ext/opcache/tests/opcache-2.blacklist @@ -1 +1,6 @@ /path/to/bar +; wildcard and relative entires +blacklist.inc +./current.php +/tmp/path/?nocache.inc +/tmp/path/*/somedir diff --git a/ext/opcache/zend_accelerator_blacklist.c b/ext/opcache/zend_accelerator_blacklist.c index b09d0e54c..da83cfd31 100644 --- a/ext/opcache/zend_accelerator_blacklist.c +++ b/ext/opcache/zend_accelerator_blacklist.c @@ -30,6 +30,10 @@ # include "main/php_regex.h" #endif +#if ZEND_EXTENSION_API_NO < PHP_5_3_X_API_NO +# include "ext/standard/php_string.h" +#endif + #ifdef ZEND_WIN32 # define REGEX_MODE (REG_EXTENDED|REG_NOSUB|REG_ICASE) #else @@ -86,9 +90,9 @@ static void blacklist_report_regexp_error(regex_t *comp_regex, int reg_err) static void zend_accel_blacklist_update_regexp(zend_blacklist *blacklist) { - char *regexp; - int i, j, clen, reg_err, end = 0, rlen = 6; + int i, reg_err; zend_regexp_list **regexp_list_it, *it; + char regexp[12*1024], *p, *end, *c, *backtrack = NULL; if (blacklist->pos == 0) { /* we have no blacklist to talk about */ @@ -96,36 +100,91 @@ static void zend_accel_blacklist_update_regexp(zend_blacklist *blacklist) } regexp_list_it = &(blacklist->regexp_list); - for (i = 0; i < blacklist->pos; i++) { - rlen += blacklist->entries[i].path_length * 2 + 2; - /* don't create a regexp buffer bigger than 12K)*/ - if ((i + 1 == blacklist->pos) || ((rlen + blacklist->entries[i + 1].path_length * 2 + 2) > (12 * 1024))) { - regexp = (char *)malloc(rlen); - if (!regexp) { - zend_accel_error(ACCEL_LOG_ERROR, "malloc() failed\n"); - return; + regexp[0] = '^'; + regexp[1] = '('; + p = regexp + 2; + end = regexp + sizeof(regexp) - sizeof("[^\\\\]*)\0"); + + for (i = 0; i < blacklist->pos; ) { + c = blacklist->entries[i].path; + if (p + blacklist->entries[i].path_length < end) { + while (*c && p < end) { + switch (*c) { + case '?': + c++; +#ifdef ZEND_WIN32 + p[0] = '['; /* * => [^\\] on Win32 */ + p[1] = '^'; + p[2] = '\\'; + p[3] = '\\'; + p[4] = ']'; + p += 5; +#else + p[0] = '['; /* * => [^/] on *nix */ + p[1] = '^'; + p[2] = '/'; + p[3] = ']'; + p += 4; +#endif + break; + case '*': + c++; + if (*c == '*') { + c++; + p[0] = '.'; /* ** => .* */ + p[1] = '*'; + p += 2; + } else { +#ifdef ZEND_WIN32 + p[0] = '['; /* * => [^\\]* on Win32 */ + p[1] = '^'; + p[2] = '\\'; + p[3] = '\\'; + p[4] = ']'; + p[5] = '*'; + p += 6; +#else + p[0] = '['; /* * => [^/]* on *nix */ + p[1] = '^'; + p[2] = '/'; + p[3] = ']'; + p[4] = '*'; + p += 5; +#endif + } + break; + case '^': + case '.': + case '[': + case ']': + case '$': + case '(': + case ')': + case '|': + case '+': + case '{': + case '}': + case '\\': + *p++ = '\\'; + /* break missing intentionally */ + default: + *p++ = *c++; + } } - regexp[0] = '^'; - regexp[1] = '('; - - clen = 2; - for (j = end; j <= i; j++) { + } - int c; - if (j != end) { - regexp[clen++] = '|'; - } - /* copy mangled filename */ - for (c = 0; c < blacklist->entries[j].path_length; c++) { - if (strchr("^.[]$()|*+?{}\\", blacklist->entries[j].path[c])) { - regexp[clen++] = '\\'; - } - regexp[clen++] = blacklist->entries[j].path[c]; + if (*c || i == blacklist->pos - 1) { + if (*c) { + if (!backtrack) { + zend_accel_error(ACCEL_LOG_ERROR, "Too long blacklist entry\n"); } + p = backtrack; + } else { + i++; } - regexp[clen++] = ')'; - regexp[clen] = '\0'; + *p++ = ')'; + *p++ = '\0'; it = (zend_regexp_list*)malloc(sizeof(zend_regexp_list)); if (!it) { @@ -138,11 +197,13 @@ static void zend_accel_blacklist_update_regexp(zend_blacklist *blacklist) blacklist_report_regexp_error(&it->comp_regex, reg_err); } /* prepare for the next iteration */ - free(regexp); - end = i + 1; - rlen = 6; + p = regexp + 2; *regexp_list_it = it; regexp_list_it = &it->next; + } else { + backtrack = p; + *p++ = '|'; + i++; } } } @@ -182,9 +243,9 @@ static void zend_accel_blacklist_loadone(zend_blacklist *blacklist, char *filena void zend_accel_blacklist_load(zend_blacklist *blacklist, char *filename) #endif { - char buf[MAXPATHLEN + 1], real_path[MAXPATHLEN + 1]; + char buf[MAXPATHLEN + 1], real_path[MAXPATHLEN + 1], *blacklist_path = NULL; FILE *fp; - int path_length; + int path_length, blacklist_path_length; TSRMLS_FETCH(); if ((fp = fopen(filename, "r")) == NULL) { @@ -194,6 +255,15 @@ void zend_accel_blacklist_load(zend_blacklist *blacklist, char *filename) zend_accel_error(ACCEL_LOG_DEBUG,"Loading blacklist file: '%s'", filename); + if (VCWD_REALPATH(filename, buf)) { +#if ZEND_EXTENSION_API_NO < PHP_5_3_X_API_NO + blacklist_path_length = php_dirname(buf, strlen(buf)); +#else + blacklist_path_length = zend_dirname(buf, strlen(buf)); +#endif + blacklist_path = zend_strndup(buf, blacklist_path_length); + } + memset(buf, 0, sizeof(buf)); memset(real_path, 0, sizeof(real_path)); @@ -230,7 +300,11 @@ void zend_accel_blacklist_load(zend_blacklist *blacklist, char *filename) } path_dup = zend_strndup(pbuf, path_length); - expand_filepath(path_dup, real_path TSRMLS_CC); + if (blacklist_path) { + expand_filepath_ex(path_dup, real_path, blacklist_path, blacklist_path_length TSRMLS_CC); + } else { + expand_filepath(path_dup, real_path TSRMLS_CC); + } path_length = strlen(real_path); free(path_dup); @@ -247,6 +321,9 @@ void zend_accel_blacklist_load(zend_blacklist *blacklist, char *filename) blacklist->pos++; } fclose(fp); + if (blacklist_path) { + free(blacklist_path); + } zend_accel_blacklist_update_regexp(blacklist); } @@ -254,7 +331,8 @@ void zend_accel_blacklist_load(zend_blacklist *blacklist, char *filename) void zend_accel_blacklist_load(zend_blacklist *blacklist, char *filename) { glob_t globbuf; - int ret, i; + int ret; + unsigned int i; memset(&globbuf, 0, sizeof(glob_t)); diff --git a/ext/opcache/zend_accelerator_module.c b/ext/opcache/zend_accelerator_module.c index fa4e3d85b..f9ddaa98b 100644 --- a/ext/opcache/zend_accelerator_module.c +++ b/ext/opcache/zend_accelerator_module.c @@ -71,6 +71,21 @@ static zend_function_entry accel_functions[] = { { NULL, NULL, NULL, 0, 0 } }; +static int validate_api_restriction(TSRMLS_D) +{ + if (ZCG(accel_directives).restrict_api && *ZCG(accel_directives).restrict_api) { + int len = strlen(ZCG(accel_directives).restrict_api); + + if (!SG(request_info).path_translated || + strlen(SG(request_info).path_translated) < len || + memcmp(SG(request_info).path_translated, ZCG(accel_directives).restrict_api, len) != 0) { + zend_error(E_WARNING, ACCELERATOR_PRODUCT_NAME " API is restricted by \"restrict_api\" configuration directive"); + return 0; + } + } + return 1; +} + static ZEND_INI_MH(OnUpdateMemoryConsumption) { long *p; @@ -251,6 +266,7 @@ ZEND_INI_BEGIN() STD_PHP_INI_BOOLEAN("opcache.enable_file_override" , "0" , PHP_INI_SYSTEM, OnUpdateBool, accel_directives.file_override_enabled, zend_accel_globals, accel_globals) STD_PHP_INI_BOOLEAN("opcache.enable_cli" , "0" , PHP_INI_SYSTEM, OnUpdateBool, accel_directives.enable_cli, zend_accel_globals, accel_globals) STD_PHP_INI_ENTRY("opcache.error_log" , "" , PHP_INI_SYSTEM, OnUpdateString, accel_directives.error_log, zend_accel_globals, accel_globals) + STD_PHP_INI_ENTRY("opcache.restrict_api" , "" , PHP_INI_SYSTEM, OnUpdateString, accel_directives.restrict_api, zend_accel_globals, accel_globals) #ifdef ZEND_WIN32 STD_PHP_INI_ENTRY("opcache.mmap_base", NULL, PHP_INI_SYSTEM, OnUpdateString, accel_directives.mmap_base, zend_accel_globals, accel_globals) @@ -378,6 +394,7 @@ static ZEND_MSHUTDOWN_FUNCTION(zend_accelerator) (void)type; /* keep the compiler happy */ UNREGISTER_INI_ENTRIES(); + accel_shutdown(TSRMLS_C); return SUCCESS; } @@ -516,6 +533,10 @@ static ZEND_FUNCTION(opcache_get_status) return; } + if (!validate_api_restriction(TSRMLS_C)) { + RETURN_FALSE; + } + if (!accel_startup_ok) { RETURN_FALSE; } @@ -586,6 +607,10 @@ static ZEND_FUNCTION(opcache_get_configuration) } #endif + if (!validate_api_restriction(TSRMLS_C)) { + RETURN_FALSE; + } + array_init(return_value); /* directives */ @@ -650,6 +675,10 @@ static ZEND_FUNCTION(opcache_reset) } #endif + if (!validate_api_restriction(TSRMLS_C)) { + RETURN_FALSE; + } + if (!ZCG(enabled) || !accel_startup_ok || !ZCSG(accelerator_enabled)) { RETURN_FALSE; } @@ -670,6 +699,10 @@ static ZEND_FUNCTION(opcache_invalidate) return; } + if (!validate_api_restriction(TSRMLS_C)) { + RETURN_FALSE; + } + if (zend_accel_invalidate(script_name, script_name_len, force TSRMLS_CC) == SUCCESS) { RETURN_TRUE; } else { diff --git a/ext/openssl/config0.m4 b/ext/openssl/config0.m4 index 2c7f4fb69..a97114f80 100644 --- a/ext/openssl/config0.m4 +++ b/ext/openssl/config0.m4 @@ -3,7 +3,7 @@ dnl $Id$ dnl PHP_ARG_WITH(openssl, for OpenSSL support, -[ --with-openssl[=DIR] Include OpenSSL support (requires OpenSSL >= 0.9.6)]) +[ --with-openssl[=DIR] Include OpenSSL support (requires OpenSSL >= 0.9.6)]) PHP_ARG_WITH(kerberos, for Kerberos support, [ --with-kerberos[=DIR] OPENSSL: Include Kerberos support], no, no) diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c index c939c01b2..4c3b2ec39 100644 --- a/ext/openssl/openssl.c +++ b/ext/openssl/openssl.c @@ -35,6 +35,9 @@ #include "ext/standard/php_fopen_wrappers.h" #include "ext/standard/md5.h" #include "ext/standard/base64.h" +#ifdef PHP_WIN32 +# include "win32/winutil.h" +#endif /* OpenSSL includes */ #include <openssl/evp.h> @@ -588,7 +591,7 @@ static void add_assoc_name_entry(zval * val, char * key, X509_NAME * name, int s for (i = 0; i < X509_NAME_entry_count(name); i++) { unsigned char *to_add; - int to_add_len; + int to_add_len = 0; ne = X509_NAME_get_entry(name, i); @@ -1408,6 +1411,74 @@ PHP_FUNCTION(openssl_x509_check_private_key) } /* }}} */ +/* Special handling of subjectAltName, see CVE-2013-4073 + * Christian Heimes + */ + +static int openssl_x509v3_subjectAltName(BIO *bio, X509_EXTENSION *extension) +{ + GENERAL_NAMES *names; + const X509V3_EXT_METHOD *method = NULL; + long i, length, num; + const unsigned char *p; + + method = X509V3_EXT_get(extension); + if (method == NULL) { + return -1; + } + + p = extension->value->data; + length = extension->value->length; + if (method->it) { + names = (GENERAL_NAMES*)(ASN1_item_d2i(NULL, &p, length, + ASN1_ITEM_ptr(method->it))); + } else { + names = (GENERAL_NAMES*)(method->d2i(NULL, &p, length)); + } + if (names == NULL) { + return -1; + } + + num = sk_GENERAL_NAME_num(names); + for (i = 0; i < num; i++) { + GENERAL_NAME *name; + ASN1_STRING *as; + name = sk_GENERAL_NAME_value(names, i); + switch (name->type) { + case GEN_EMAIL: + BIO_puts(bio, "email:"); + as = name->d.rfc822Name; + BIO_write(bio, ASN1_STRING_data(as), + ASN1_STRING_length(as)); + break; + case GEN_DNS: + BIO_puts(bio, "DNS:"); + as = name->d.dNSName; + BIO_write(bio, ASN1_STRING_data(as), + ASN1_STRING_length(as)); + break; + case GEN_URI: + BIO_puts(bio, "URI:"); + as = name->d.uniformResourceIdentifier; + BIO_write(bio, ASN1_STRING_data(as), + ASN1_STRING_length(as)); + break; + default: + /* use builtin print for GEN_OTHERNAME, GEN_X400, + * GEN_EDIPARTY, GEN_DIRNAME, GEN_IPADD and GEN_RID + */ + GENERAL_NAME_print(bio, name); + } + /* trailing ', ' except for last element */ + if (i < (num - 1)) { + BIO_puts(bio, ", "); + } + } + sk_GENERAL_NAME_pop_free(names, GENERAL_NAME_free); + + return 0; +} + /* {{{ proto array openssl_x509_parse(mixed x509 [, bool shortnames=true]) Returns an array of the fields/values of the CERT */ PHP_FUNCTION(openssl_x509_parse) @@ -1504,15 +1575,29 @@ PHP_FUNCTION(openssl_x509_parse) for (i = 0; i < X509_get_ext_count(cert); i++) { + int nid; extension = X509_get_ext(cert, i); - if (OBJ_obj2nid(X509_EXTENSION_get_object(extension)) != NID_undef) { + nid = OBJ_obj2nid(X509_EXTENSION_get_object(extension)); + if (nid != NID_undef) { extname = (char *)OBJ_nid2sn(OBJ_obj2nid(X509_EXTENSION_get_object(extension))); } else { OBJ_obj2txt(buf, sizeof(buf)-1, X509_EXTENSION_get_object(extension), 1); extname = buf; } bio_out = BIO_new(BIO_s_mem()); - if (X509V3_EXT_print(bio_out, extension, 0, 0)) { + if (nid == NID_subject_alt_name) { + if (openssl_x509v3_subjectAltName(bio_out, extension) == 0) { + add_assoc_stringl(subitem, extname, bio_buf->data, bio_buf->length, 1); + } else { + zval_dtor(return_value); + if (certresource == -1 && cert) { + X509_free(cert); + } + BIO_free(bio_out); + RETURN_FALSE; + } + } + else if (X509V3_EXT_print(bio_out, extension, 0, 0)) { BIO_get_mem_ptr(bio_out, &bio_buf); add_assoc_stringl(subitem, extname, bio_buf->data, bio_buf->length, 1); } else { diff --git a/ext/openssl/tests/cve2013_4073.pem b/ext/openssl/tests/cve2013_4073.pem new file mode 100644 index 000000000..7ebb99492 --- /dev/null +++ b/ext/openssl/tests/cve2013_4073.pem @@ -0,0 +1,28 @@ +-----BEGIN CERTIFICATE----- +MIIE2DCCA8CgAwIBAgIBADANBgkqhkiG9w0BAQUFADCBxTELMAkGA1UEBhMCVVMx +DzANBgNVBAgMBk9yZWdvbjESMBAGA1UEBwwJQmVhdmVydG9uMSMwIQYDVQQKDBpQ +eXRob24gU29mdHdhcmUgRm91bmRhdGlvbjEgMB4GA1UECwwXUHl0aG9uIENvcmUg +RGV2ZWxvcG1lbnQxJDAiBgNVBAMMG251bGwucHl0aG9uLm9yZwBleGFtcGxlLm9y +ZzEkMCIGCSqGSIb3DQEJARYVcHl0aG9uLWRldkBweXRob24ub3JnMB4XDTEzMDgw +NzEzMTE1MloXDTEzMDgwNzEzMTI1MlowgcUxCzAJBgNVBAYTAlVTMQ8wDQYDVQQI +DAZPcmVnb24xEjAQBgNVBAcMCUJlYXZlcnRvbjEjMCEGA1UECgwaUHl0aG9uIFNv +ZnR3YXJlIEZvdW5kYXRpb24xIDAeBgNVBAsMF1B5dGhvbiBDb3JlIERldmVsb3Bt +ZW50MSQwIgYDVQQDDBtudWxsLnB5dGhvbi5vcmcAZXhhbXBsZS5vcmcxJDAiBgkq +hkiG9w0BCQEWFXB5dGhvbi1kZXZAcHl0aG9uLm9yZzCCASIwDQYJKoZIhvcNAQEB +BQADggEPADCCAQoCggEBALXq7cn7Rn1vO3aA3TrzA5QLp6bb7B3f/yN0CJ2XFj+j +pHs+Gw6WWSUDpybiiKnPec33BFawq3kyblnBMjBU61ioy5HwQqVkJ8vUVjGIUq3P +vX/wBmQfzCe4o4uM89gpHyUL9UYGG8oCRa17dgqcv7u5rg0Wq2B1rgY+nHwx3JIv +KRrgSwyRkGzpN8WQ1yrXlxWjgI9de0mPVDDUlywcWze1q2kwaEPTM3hLAmD1PESA +oY/n8A/RXoeeRs9i/Pm/DGUS8ZPINXk/yOzsR/XvvkTVroIeLZqfmFpnZeF0cHzL +08LODkVJJ9zjLdT7SA4vnne4FEbAxDbKAq5qkYzaL4UCAwEAAaOB0DCBzTAMBgNV +HRMBAf8EAjAAMB0GA1UdDgQWBBSIWlXAUv9hzVKjNQ/qWpwkOCL3XDALBgNVHQ8E +BAMCBeAwgZAGA1UdEQSBiDCBhYIeYWx0bnVsbC5weXRob24ub3JnAGV4YW1wbGUu +Y29tgSBudWxsQHB5dGhvbi5vcmcAdXNlckBleGFtcGxlLm9yZ4YpaHR0cDovL251 +bGwucHl0aG9uLm9yZwBodHRwOi8vZXhhbXBsZS5vcmeHBMAAAgGHECABDbgAAAAA +AAAAAAAAAAEwDQYJKoZIhvcNAQEFBQADggEBAKxPRe99SaghcI6IWT7UNkJw9aO9 +i9eo0Fj2MUqxpKbdb9noRDy2CnHWf7EIYZ1gznXPdwzSN4YCjV5d+Q9xtBaowT0j +HPERs1ZuytCNNJTmhyqZ8q6uzMLoht4IqH/FBfpvgaeC5tBTnTT0rD5A/olXeimk +kX4LxlEx5RAvpGB2zZVRGr6LobD9rVK91xuHYNIxxxfEGE8tCCWjp0+3ksri9SXx +VHWBnbM9YaL32u3hxm8sYB/Yb8WSBavJCWJJqRStVRHM1koZlJmXNx2BX4vPo6iW +RFEIPQsFZRLrtnCAiEhyT8bC2s/Njlu6ly9gtJZWSV46Q3ZjBL4q9sHKqZQ= +-----END CERTIFICATE----- diff --git a/ext/openssl/tests/cve2013_4073.phpt b/ext/openssl/tests/cve2013_4073.phpt new file mode 100644 index 000000000..e676ddfb9 --- /dev/null +++ b/ext/openssl/tests/cve2013_4073.phpt @@ -0,0 +1,19 @@ +--TEST-- +CVE 2013-4073: Null-byte certificate handling +--SKIPIF-- +<?php +if (!extension_loaded("openssl")) die("skip"); +--FILE-- +<?php +$cert = file_get_contents(__DIR__ . '/cve2013_4073.pem'); +$info = openssl_x509_parse($cert); +var_export($info['extensions']); + +--EXPECTF-- +array ( + 'basicConstraints' => 'CA:FALSE', + 'subjectKeyIdentifier' => '88:5A:55:C0:52:FF:61:CD:52:A3:35:0F:EA:5A:9C:24:38:22:F7:5C', + 'keyUsage' => 'Digital Signature, Non Repudiation, Key Encipherment', + 'subjectAltName' => 'DNS:altnull.python.org' . "\0" . 'example.com, email:null@python.org' . "\0" . 'user@example.org, URI:http://null.python.org' . "\0" . 'http://example.org, IP Address:192.0.2.1, IP Address:2001:DB8:0:0:0:0:0:1 +', +) diff --git a/ext/openssl/xp_ssl.c b/ext/openssl/xp_ssl.c index e9a72e3f3..a1a7ffc3f 100644 --- a/ext/openssl/xp_ssl.c +++ b/ext/openssl/xp_ssl.c @@ -472,7 +472,7 @@ static inline int php_openssl_enable_crypto(php_stream *stream, do { struct timeval cur_time, - elapsed_time; + elapsed_time = {0}; if (sslsock->is_client) { n = SSL_connect(sslsock->ssl_handle); diff --git a/ext/pcntl/pcntl.c b/ext/pcntl/pcntl.c index abe6b64ac..b66f4722e 100644 --- a/ext/pcntl/pcntl.c +++ b/ext/pcntl/pcntl.c @@ -795,7 +795,7 @@ PHP_FUNCTION(pcntl_exec) snprintf(key, 100, "%ld", key_num); key_length = strlen(key); break; - case HASH_KEY_NON_EXISTANT: + case HASH_KEY_NON_EXISTENT: pair--; continue; } diff --git a/ext/pcntl/tests/pcntl_exec.phpt b/ext/pcntl/tests/pcntl_exec.phpt index 9d2ec1dcf..9a2c96ea3 100644 --- a/ext/pcntl/tests/pcntl_exec.phpt +++ b/ext/pcntl/tests/pcntl_exec.phpt @@ -8,7 +8,7 @@ if (!getenv("TEST_PHP_EXECUTABLE") || !is_executable(getenv("TEST_PHP_EXECUTABLE --FILE-- <?php echo "ok\n"; -pcntl_exec(getenv("TEST_PHP_EXECUTABLE")); +pcntl_exec(getenv("TEST_PHP_EXECUTABLE"), ['-n']); echo "nok\n"; ?> --EXPECT-- diff --git a/ext/pcntl/tests/pcntl_exec_2.phpt b/ext/pcntl/tests/pcntl_exec_2.phpt index 02b5e22aa..e18527dba 100644 --- a/ext/pcntl/tests/pcntl_exec_2.phpt +++ b/ext/pcntl/tests/pcntl_exec_2.phpt @@ -14,7 +14,7 @@ if (getenv("PCNTL_EXEC_TEST_IS_CHILD")) { exit; } echo "ok\n"; -pcntl_exec(getenv("TEST_PHP_EXECUTABLE"), array(__FILE__), array( +pcntl_exec(getenv("TEST_PHP_EXECUTABLE"), array('-n', __FILE__), array( b"PCNTL_EXEC_TEST_IS_CHILD" => b"1", b"FOO" => b"BAR", 1 => b"long") diff --git a/ext/pdo_firebird/config.m4 b/ext/pdo_firebird/config.m4 index 7b6f669a5..a89ab2aea 100644 --- a/ext/pdo_firebird/config.m4 +++ b/ext/pdo_firebird/config.m4 @@ -4,7 +4,7 @@ dnl PHP_ARG_WITH(pdo-firebird,for Firebird support for PDO, [ --with-pdo-firebird[=DIR] PDO: Firebird support. DIR is the Firebird base - install directory [/opt/firebird]]) + install directory [/opt/firebird]]) if test "$PHP_PDO_FIREBIRD" != "no"; then diff --git a/ext/pdo_mysql/config.m4 b/ext/pdo_mysql/config.m4 index a2ba2fdbd..f237f413b 100755 --- a/ext/pdo_mysql/config.m4 +++ b/ext/pdo_mysql/config.m4 @@ -4,12 +4,12 @@ dnl vim: se ts=2 sw=2 et: PHP_ARG_WITH(pdo-mysql, for MySQL support for PDO, [ --with-pdo-mysql[=DIR] PDO: MySQL support. DIR is the MySQL base directory - If no value or mysqlnd is passed as DIR, the - MySQL native driver will be used]) + If no value or mysqlnd is passed as DIR, the + MySQL native driver will be used]) if test -z "$PHP_ZLIB_DIR"; then PHP_ARG_WITH(zlib-dir, for the location of libz, - [ --with-zlib-dir[=DIR] PDO_MySQL: Set the path to libz install prefix], no, no) + [ --with-zlib-dir[=DIR] PDO_MySQL: Set the path to libz install prefix], no, no) fi if test "$PHP_PDO_MYSQL" != "no"; then diff --git a/ext/pdo_mysql/mysql_driver.c b/ext/pdo_mysql/mysql_driver.c index 54c2e8dd8..cd86503dd 100644 --- a/ext/pdo_mysql/mysql_driver.c +++ b/ext/pdo_mysql/mysql_driver.c @@ -527,9 +527,9 @@ static struct pdo_dbh_methods mysql_methods = { /* }}} */ #ifdef PHP_WIN32 -# define MYSQL_UNIX_ADDR NULL +# define PDO_DEFAULT_MYSQL_UNIX_ADDR NULL #else -# define MYSQL_UNIX_ADDR PDO_MYSQL_G(default_socket) +# define PDO_DEFAULT_MYSQL_UNIX_ADDR PDO_MYSQL_G(default_socket) #endif /* {{{ pdo_mysql_handle_factory */ @@ -545,7 +545,7 @@ static int pdo_mysql_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_ { "dbname", "", 0 }, { "host", "localhost", 0 }, { "port", "3306", 0 }, - { "unix_socket", MYSQL_UNIX_ADDR, 0 }, + { "unix_socket", PDO_DEFAULT_MYSQL_UNIX_ADDR, 0 }, }; int connect_opts = 0 #ifdef CLIENT_MULTI_RESULTS @@ -710,7 +710,7 @@ static int pdo_mysql_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_ } } -#if MYSQL_VERSION_ID > 50605 || defined(MYSQLI_USE_MYSQLND) +#if MYSQL_VERSION_ID > 50605 || defined(PDO_USE_MYSQLND) { char *public_key = pdo_attr_strval(driver_options, PDO_MYSQL_ATTR_SERVER_PUBLIC_KEY, NULL TSRMLS_CC); if (public_key) { diff --git a/ext/pdo_mysql/pdo_mysql.c b/ext/pdo_mysql/pdo_mysql.c index 401d20d8b..78c4ceefe 100644 --- a/ext/pdo_mysql/pdo_mysql.c +++ b/ext/pdo_mysql/pdo_mysql.c @@ -118,7 +118,7 @@ static PHP_MINIT_FUNCTION(pdo_mysql) REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_SSL_CA", (long)PDO_MYSQL_ATTR_SSL_CA); REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_SSL_CAPATH", (long)PDO_MYSQL_ATTR_SSL_CAPATH); REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_SSL_CIPHER", (long)PDO_MYSQL_ATTR_SSL_CIPHER); -#if MYSQL_VERSION_ID > 50605 || defined(MYSQLI_USE_MYSQLND) +#if MYSQL_VERSION_ID > 50605 || defined(PDO_USE_MYSQLND) REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_SERVER_PUBLIC_KEY", (long)PDO_MYSQL_ATTR_SERVER_PUBLIC_KEY); #endif diff --git a/ext/pdo_mysql/php_pdo_mysql_int.h b/ext/pdo_mysql/php_pdo_mysql_int.h index 42debf07e..24f7aa218 100644 --- a/ext/pdo_mysql/php_pdo_mysql_int.h +++ b/ext/pdo_mysql/php_pdo_mysql_int.h @@ -171,7 +171,7 @@ enum { PDO_MYSQL_ATTR_SSL_CA, PDO_MYSQL_ATTR_SSL_CAPATH, PDO_MYSQL_ATTR_SSL_CIPHER, -#if MYSQL_VERSION_ID > 50605 || defined(MYSQLI_USE_MYSQLND) +#if MYSQL_VERSION_ID > 50605 || defined(PDO_USE_MYSQLND) PDO_MYSQL_ATTR_SERVER_PUBLIC_KEY #endif }; diff --git a/ext/pdo_mysql/tests/bug_44454.phpt b/ext/pdo_mysql/tests/bug_44454.phpt index 89a4e2a3f..eb93d9795 100644 --- a/ext/pdo_mysql/tests/bug_44454.phpt +++ b/ext/pdo_mysql/tests/bug_44454.phpt @@ -73,8 +73,6 @@ require dirname(__FILE__) . '/mysql_pdo_test.inc'; $db = MySQLPDOTest::factory(); $db->exec('DROP TABLE IF EXISTS test'); ?> ---XFAIL-- -For some reason the exception gets thrown at the wrong place --EXPECTF-- Native Prepared Statements ... SELECT has returned 1 row... diff --git a/ext/pdo_mysql/tests/pdo_mysql_exec_load_data.phpt b/ext/pdo_mysql/tests/pdo_mysql_exec_load_data.phpt index b550cb8da..ebf22ef61 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_exec_load_data.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_exec_load_data.phpt @@ -48,6 +48,7 @@ if (($tmp[1] !== 'localhost') && ($tmp[1] !== '127.0.0.1')) } require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc'); + putenv('PDOTEST_ATTR='.serialize([PDO::MYSQL_ATTR_LOCAL_INFILE=>true])); $db = MySQLPDOTest::factory(); MySQLPDOTest::createTestTable($db, MySQLPDOTest::detect_transactional_mysql_engine($db)); diff --git a/ext/pdo_mysql/tests/pdo_mysql_phpinfo.phpt b/ext/pdo_mysql/tests/pdo_mysql_phpinfo.phpt index 9674e85f5..74b4a7358 100644 --- a/ext/pdo_mysql/tests/pdo_mysql_phpinfo.phpt +++ b/ext/pdo_mysql/tests/pdo_mysql_phpinfo.phpt @@ -18,7 +18,7 @@ $db = MySQLPDOTest::factory(); ob_end_clean(); /* PDO Driver for MySQL, client library version => 6.0.3-alpha */ - $reg = 'Client API version.*' . pcre_quote($db->getAttribute(PDO::ATTR_CLIENT_VERSION), '/'); + $reg = 'Client API version.*' . preg_quote($db->getAttribute(PDO::ATTR_CLIENT_VERSION), '/'); if (!preg_match("/$reg/", $tmp)) { printf("[001] Cannot find MySQL PDO driver line in phpinfo() output\n"); diff --git a/ext/pdo_oci/config.m4 b/ext/pdo_oci/config.m4 index 0e42d1f9a..e3795db0e 100755 --- a/ext/pdo_oci/config.m4 +++ b/ext/pdo_oci/config.m4 @@ -42,11 +42,11 @@ AC_DEFUN([AC_PDO_OCI_CHECK_LIB_DIR],[ PHP_ARG_WITH(pdo-oci, Oracle OCI support for PDO, [ --with-pdo-oci[=DIR] PDO: Oracle OCI support. DIR defaults to \$ORACLE_HOME. - Use --with-pdo-oci=instantclient,prefix,version - for an Oracle Instant Client SDK. - For example on Linux with 11.2 RPMs use: + Use --with-pdo-oci=instantclient,prefix,version + for an Oracle Instant Client SDK. + For example on Linux with 11.2 RPMs use: --with-pdo-oci=instantclient,/usr,11.2 - With 10.2 RPMs use: + With 10.2 RPMs use: --with-pdo-oci=instantclient,/usr,10.2.0.4]) if test "$PHP_PDO_OCI" != "no"; then diff --git a/ext/pdo_odbc/config.m4 b/ext/pdo_odbc/config.m4 index b70dc9d53..74734c4d6 100755 --- a/ext/pdo_odbc/config.m4 +++ b/ext/pdo_odbc/config.m4 @@ -3,25 +3,25 @@ dnl config.m4 for extension pdo_odbc dnl vim:et:sw=2:ts=2: define([PDO_ODBC_HELP_TEXT],[[ - include and lib dirs are looked for under 'dir'. - - 'flavour' can be one of: ibm-db2, iODBC, unixODBC, generic - If ',dir' part is omitted, default for the flavour - you have selected will used. e.g.: - - --with-pdo-odbc=unixODBC - - will check for unixODBC under /usr/local. You may attempt - to use an otherwise unsupported driver using the \"generic\" - flavour. The syntax for generic ODBC support is: - - --with-pdo-odbc=generic,dir,libname,ldflags,cflags - - When build as shared the extension filename is always pdo_odbc.so]]) + include and lib dirs are looked for under 'dir'. + + 'flavour' can be one of: ibm-db2, iODBC, unixODBC, generic + If ',dir' part is omitted, default for the flavour + you have selected will be used. e.g.: + + --with-pdo-odbc=unixODBC + + will check for unixODBC under /usr/local. You may attempt + to use an otherwise unsupported driver using the \"generic\" + flavour. The syntax for generic ODBC support is: + + --with-pdo-odbc=generic,dir,libname,ldflags,cflags + + When built as 'shared' the extension filename is always pdo_odbc.so]]) PHP_ARG_WITH(pdo-odbc, for ODBC v3 support for PDO, [ --with-pdo-odbc=flavour,dir - PDO: Support for 'flavour' ODBC driver.]PDO_ODBC_HELP_TEXT) + PDO: Support for 'flavour' ODBC driver.]PDO_ODBC_HELP_TEXT) AC_DEFUN([PDO_ODBC_CHECK_HEADER],[ diff --git a/ext/pdo_pgsql/config.m4 b/ext/pdo_pgsql/config.m4 index f9254a8fd..afe42e06a 100644 --- a/ext/pdo_pgsql/config.m4 +++ b/ext/pdo_pgsql/config.m4 @@ -4,7 +4,7 @@ dnl vim:et:sw=2:ts=2: PHP_ARG_WITH(pdo-pgsql,for PostgreSQL support for PDO, [ --with-pdo-pgsql[=DIR] PDO: PostgreSQL support. DIR is the PostgreSQL base - install directory or the path to pg_config]) + install directory or the path to pg_config]) if test "$PHP_PDO_PGSQL" != "no"; then diff --git a/ext/pdo_pgsql/tests/bug_33876.phpt b/ext/pdo_pgsql/tests/bug_33876.phpt index 48618e13d..6a93905b4 100644 --- a/ext/pdo_pgsql/tests/bug_33876.phpt +++ b/ext/pdo_pgsql/tests/bug_33876.phpt @@ -82,7 +82,7 @@ else # false -> "" as string, which pgsql doesn't like if (!$res->execute(array(false))) { $err = $res->errorInfo(); - // Strip additional lines ouputted by recent PgSQL versions + // Strip additional lines outputted by recent PgSQL versions $err[2] = trim(current(explode("\n", $err[2]))); print_r($err); } else { diff --git a/ext/pdo_sqlite/config.m4 b/ext/pdo_sqlite/config.m4 index b2b70a503..0a7d0fe82 100644 --- a/ext/pdo_sqlite/config.m4 +++ b/ext/pdo_sqlite/config.m4 @@ -4,8 +4,8 @@ dnl vim:et:sw=2:ts=2: PHP_ARG_WITH(pdo-sqlite, for sqlite 3 support for PDO, [ --without-pdo-sqlite[=DIR] - PDO: sqlite 3 support. DIR is the sqlite base - install directory [BUNDLED]], $PHP_PDO) + PDO: sqlite 3 support. DIR is the sqlite base + install directory [BUNDLED]], $PHP_PDO) if test "$PHP_PDO_SQLITE" != "no"; then diff --git a/ext/pdo_sqlite/tests/pdo_sqlite_createfunction_002.phpt b/ext/pdo_sqlite/tests/pdo_sqlite_createfunction_002.phpt new file mode 100644 index 000000000..a1d890ac1 --- /dev/null +++ b/ext/pdo_sqlite/tests/pdo_sqlite_createfunction_002.phpt @@ -0,0 +1,17 @@ +--TEST-- +PDO_sqlite: Testing sqliteCreateFunction() produces warning when +un-callable function passed +--CREDITS-- +Chris MacPherson chris@kombine.co.uk +--SKIPIF-- +<?php if (!extension_loaded('pdo_sqlite')) print 'skip not loaded'; ?> +--FILE-- +<?php + +$db = new PDO( 'sqlite::memory:'); + +$db->sqliteCreateFunction('bar-alias', 'bar'); + +?> +--EXPECTF-- +Warning: PDO::sqliteCreateFunction(): function 'bar' is not callable in %s on line %d diff --git a/ext/pgsql/config.m4 b/ext/pgsql/config.m4 index bddb77a15..13837bd83 100644 --- a/ext/pgsql/config.m4 +++ b/ext/pgsql/config.m4 @@ -3,7 +3,7 @@ dnl $Id$ dnl PHP_ARG_WITH(pgsql,for PostgreSQL support, -[ --with-pgsql[=DIR] Include PostgreSQL support. DIR is the PostgreSQL +[ --with-pgsql[=DIR] Include PostgreSQL support. DIR is the PostgreSQL base install directory or the path to pg_config]) if test "$PHP_PGSQL" != "no"; then diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c index 128c2894f..f0e1780a7 100644 --- a/ext/pgsql/pgsql.c +++ b/ext/pgsql/pgsql.c @@ -914,6 +914,82 @@ static void _free_result(zend_rsrc_list_entry *rsrc TSRMLS_DC) } /* }}} */ + +static int _php_pgsql_detect_identifier_escape(const char *identifier, size_t len) +{ + size_t i; + + /* Handle edge case. Cannot be a escaped string */ + if (len <= 2) { + return FAILURE; + } + /* Detect double qoutes */ + if (identifier[0] == '"' && identifier[len-1] == '"') { + /* Detect wrong format of " inside of escaped string */ + for (i = 1; i < len-1; i++) { + if (identifier[i] == '"' && (identifier[++i] != '"' || i == len-1)) { + return FAILURE; + } + } + } else { + return FAILURE; + } + /* Escaped properly */ + return SUCCESS; +} + +#if !HAVE_PQESCAPELITERAL +/* {{{ _php_pgsql_escape_identifier + * Since PQescapeIdentifier() is unavailable (PostgreSQL 9.0 <), idenfifers + * should be escaped by pgsql module. + * Note: this function does not care for encoding. Therefore users should not + * use this with SJIS/BIG5 etc. (i.e. Encoding base injection may possible with + * before PostgreSQL 9.0) + */ +static char *_php_pgsql_escape_identifier(const char *field, size_t field_len) +{ + ulong field_escaped_len = field_len*2 + 3; + ulong i, j = 0; + char *field_escaped; + + field_escaped = (char *)malloc(field_escaped_len); + field_escaped[j++] = '"'; + for (i = 0; i < field_len; i++) { + if (field[i] == '"') { + field_escaped[j++] = '"'; + field_escaped[j++] = '"'; + } else { + field_escaped[j++] = field[i]; + } + } + field_escaped[j++] = '"'; + field_escaped[j] = '\0'; + return field_escaped; +} +/* }}} */ +#endif + +/* {{{ _php_pgsql_strndup, no strndup should be used */ +static char *_php_pgsql_strndup(const char *s, size_t len) +{ + char *new; + + if (NULL == s) { + return (char *)NULL; + } + + new = (char *) malloc(len + 1); + + if (NULL == new) { + return (char *)NULL; + } + + new[len] = '\0'; + + return memmove(new, s, len); +} +/* }}} */ + /* {{{ PHP_INI */ PHP_INI_BEGIN() @@ -4274,7 +4350,6 @@ static void php_pgsql_escape_internal(INTERNAL_FUNCTION_PARAMETERS, int escape_l char *from = NULL, *to = NULL, *tmp = NULL; zval *pgsql_link = NULL; PGconn *pgsql; - int to_len; int from_len; int id = -1; @@ -4295,12 +4370,13 @@ static void php_pgsql_escape_internal(INTERNAL_FUNCTION_PARAMETERS, int escape_l } if (pgsql_link == NULL && id == -1) { + php_error_docref(NULL TSRMLS_CC, E_WARNING,"Cannot get default pgsql link"); RETURN_FALSE; } ZEND_FETCH_RESOURCE2(pgsql, PGconn *, &pgsql_link, id, "PostgreSQL link", le_link, le_plink); if (pgsql == NULL) { - php_error_docref(NULL TSRMLS_CC, E_WARNING,"Cannot get default pgsql link"); + php_error_docref(NULL TSRMLS_CC, E_WARNING,"Cannot get pgsql link"); RETURN_FALSE; } #ifdef HAVE_PQESCAPELITERAL @@ -5015,8 +5091,9 @@ PHP_PGSQL_API int php_pgsql_meta_data(PGconn *pg_link, const char *table_name, z { PGresult *pg_result; char *src, *tmp_name, *tmp_name2 = NULL; + char *escaped; smart_str querystr = {0}; - int new_len; + size_t new_len; int i, num_rows; zval *elem; @@ -5038,20 +5115,29 @@ PHP_PGSQL_API int php_pgsql_meta_data(PGconn *pg_link, const char *table_name, z "SELECT a.attname, a.attnum, t.typname, a.attlen, a.attnotnull, a.atthasdef, a.attndims, t.typtype = 'e' " "FROM pg_class as c, pg_attribute a, pg_type t, pg_namespace n " "WHERE a.attnum > 0 AND a.attrelid = c.oid AND c.relname = '"); - tmp_name2 = php_addslashes(tmp_name2, strlen(tmp_name2), &new_len, 0 TSRMLS_CC); - smart_str_appendl(&querystr, tmp_name2, new_len); - + escaped = (char *)safe_emalloc(strlen(tmp_name2), 2, 1); +#if HAVE_PQESCAPE_CONN + new_len = PQescapeStringConn(pg_link, escaped, tmp_name2, strlen(tmp_name2), NULL); +#else + new_len = PQescapeString(escaped, tmp_name2, strlen(tmp_name2)); +#endif + smart_str_appends(&querystr, escaped); + efree(escaped); + smart_str_appends(&querystr, "' AND c.relnamespace = n.oid AND n.nspname = '"); - tmp_name = php_addslashes(tmp_name, strlen(tmp_name), &new_len, 0 TSRMLS_CC); - smart_str_appendl(&querystr, tmp_name, new_len); + escaped = (char *)safe_emalloc(strlen(tmp_name), 2, 1); +#if HAVE_PQESCAPE_CONN + new_len = PQescapeStringConn(pg_link, escaped, tmp_name, strlen(tmp_name), NULL); +#else + new_len = PQescapeString(escaped, tmp_name, strlen(tmp_name)); +#endif + smart_str_appends(&querystr, escaped); + efree(escaped); smart_str_appends(&querystr, "' AND a.atttypid = t.oid ORDER BY a.attnum;"); smart_str_0(&querystr); - - efree(tmp_name2); - efree(tmp_name); - efree(src); - + efree(src); + pg_result = PQexec(pg_link, querystr.c); if (PQresultStatus(pg_result) != PGRES_TUPLES_OK || (num_rows = PQntuples(pg_result)) == 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Table '%s' doesn't exists", table_name); @@ -5274,6 +5360,7 @@ static int php_pgsql_add_quotes(zval *src, zend_bool should_free TSRMLS_DC) assert(Z_TYPE_P(src) == IS_STRING); assert(should_free == 1 || should_free == 0); + smart_str_appendc(&str, 'E'); smart_str_appendc(&str, '\''); smart_str_appendl(&str, Z_STRVAL_P(src), Z_STRLEN_P(src)); smart_str_appendc(&str, '\''); @@ -5314,7 +5401,7 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con uint field_len = -1; ulong num_idx = -1; zval *meta, **def, **type, **not_null, **has_default, **is_enum, **val, *new_val; - int new_len, key_type, err = 0, skip_field; + int key_type, err = 0, skip_field; php_pgsql_data_type data_type; assert(pg_link != NULL); @@ -5327,6 +5414,8 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con } MAKE_STD_ZVAL(meta); array_init(meta); + +/* table_name is escaped by php_pgsql_meta_data */ if (php_pgsql_meta_data(pg_link, table_name, meta TSRMLS_CC) == FAILURE) { zval_dtor(meta); FREE_ZVAL(meta); @@ -5338,7 +5427,7 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con skip_field = 0; new_val = NULL; - if ((key_type = zend_hash_get_current_key_ex(Z_ARRVAL_P(values), &field, &field_len, &num_idx, 0, &pos)) == HASH_KEY_NON_EXISTANT) { + if ((key_type = zend_hash_get_current_key_ex(Z_ARRVAL_P(values), &field, &field_len, &num_idx, 0, &pos)) == HASH_KEY_NON_EXISTENT) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to get array key type"); err = 1; } @@ -5346,7 +5435,7 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con php_error_docref(NULL TSRMLS_CC, E_WARNING, "Accepts only string key for values"); err = 1; } - if (!err && key_type == HASH_KEY_NON_EXISTANT) { + if (!err && key_type == HASH_KEY_NON_EXISTENT) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Accepts only string key for values"); err = 1; } @@ -5539,15 +5628,15 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con } else { Z_TYPE_P(new_val) = IS_STRING; -#if HAVE_PQESCAPE +#if HAVE_PQESCAPE_CONN { char *tmp; - tmp = (char *)safe_emalloc(Z_STRLEN_PP(val), 2, 1); - Z_STRLEN_P(new_val) = (int)PQescapeString(tmp, Z_STRVAL_PP(val), Z_STRLEN_PP(val)); + tmp = (char *)safe_emalloc(Z_STRLEN_PP(val), 2, 1); + Z_STRLEN_P(new_val) = (int)PQescapeStringConn(pg_link, tmp, Z_STRVAL_PP(val), Z_STRLEN_PP(val), NULL); Z_STRVAL_P(new_val) = tmp; } #else - Z_STRVAL_P(new_val) = php_addslashes(Z_STRVAL_PP(val), Z_STRLEN_PP(val), &Z_STRLEN_P(new_val), 0 TSRMLS_CC); + Z_STRVAL_P(new_val) = (int)PQescapeString(Z_STRVAL_PP(val), Z_STRLEN_PP(val), &Z_STRLEN_P(new_val), 0 TSRMLS_CC); #endif php_pgsql_add_quotes(new_val, 1 TSRMLS_CC); } @@ -5833,6 +5922,7 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con else { unsigned char *tmp; size_t to_len; + smart_str s = {0}; #ifdef HAVE_PQESCAPE_BYTEA_CONN tmp = PQescapeByteaConn(pg_link, Z_STRVAL_PP(val), Z_STRLEN_PP(val), &to_len); #else @@ -5844,7 +5934,11 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con memcpy(Z_STRVAL_P(new_val), tmp, to_len); PQfreemem(tmp); php_pgsql_add_quotes(new_val, 1 TSRMLS_CC); - + smart_str_appendl(&s, Z_STRVAL_P(new_val), Z_STRLEN_P(new_val)); + smart_str_0(&s); + efree(Z_STRVAL_P(new_val)); + Z_STRVAL_P(new_val) = s.c; + Z_STRLEN_P(new_val) = s.len; } break; @@ -5929,11 +6023,22 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con FREE_ZVAL(new_val); break; /* break out for() */ } + /* If field is NULL and HAS DEFAULT, should be skipped */ if (!skip_field) { - /* If field is NULL and HAS DEFAULT, should be skipped */ - field = php_addslashes(field, strlen(field), &new_len, 0 TSRMLS_CC); - add_assoc_zval(result, field, new_val); - efree(field); + char *escaped; + size_t field_len = strlen(field); + + if (_php_pgsql_detect_identifier_escape(field, field_len) == SUCCESS) { + escaped = _php_pgsql_strndup(field, field_len); + } else { +#if HAVE_PQESCAPELITERAL + escaped = PQescapeIdentifier(pg_link, field, field_len); +#else + escaped = _php_pgsql_escape_identifier(field, field_len); +#endif + } + add_assoc_zval(result, escaped, new_val); + free(escaped); } } /* for */ zval_dtor(meta); @@ -6008,6 +6113,45 @@ static int do_exec(smart_str *querystr, int expect, PGconn *pg_link, ulong opt T return -1; } +static inline void build_tablename(smart_str *querystr, PGconn *pg_link, const char *table) +{ + char *table_copy, *escaped, *token, *tmp; + size_t len; + + /* schame.table should be "schame"."table" */ + table_copy = estrdup(table); + token = php_strtok_r(table_copy, ".", &tmp); + len = strlen(token); + if (_php_pgsql_detect_identifier_escape(token, len) == SUCCESS) { + escaped = _php_pgsql_strndup(token, len); + } else { +#if HAVE_PQESCAPELITERAL + escaped = PQescapeIdentifier(pg_link, token, len); +#else + escaped = _php_pgsql_escape_identifier(token, len); +#endif + } + smart_str_appends(querystr, escaped); + free(escaped); + if (tmp && *tmp) { + len = strlen(tmp); + /* "schema"."table" format */ + if (_php_pgsql_detect_identifier_escape(tmp, len) == SUCCESS) { + escaped = _php_pgsql_strndup(tmp, len); + } else { +#if HAVE_PQESCAPELITERAL + escaped = PQescapeIdentifier(pg_link, tmp, len); +#else + escaped = _php_pgsql_escape_identifier(tmp, len); +#endif + } + smart_str_appendc(querystr, '.'); + smart_str_appends(querystr, escaped); + free(escaped); + } + efree(table_copy); +} + /* {{{ php_pgsql_insert */ PHP_PGSQL_API int php_pgsql_insert(PGconn *pg_link, const char *table, zval *var_array, ulong opt, char **sql TSRMLS_DC) @@ -6027,7 +6171,7 @@ PHP_PGSQL_API int php_pgsql_insert(PGconn *pg_link, const char *table, zval *var if (zend_hash_num_elements(Z_ARRVAL_P(var_array)) == 0) { smart_str_appends(&querystr, "INSERT INTO "); - smart_str_appends(&querystr, table); + build_tablename(&querystr, pg_link, table); smart_str_appends(&querystr, " DEFAULT VALUES"); goto no_values; @@ -6042,14 +6186,14 @@ PHP_PGSQL_API int php_pgsql_insert(PGconn *pg_link, const char *table, zval *var } var_array = converted; } - + smart_str_appends(&querystr, "INSERT INTO "); - smart_str_appends(&querystr, table); + build_tablename(&querystr, pg_link, table); smart_str_appends(&querystr, " ("); - + zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(var_array), &pos); while ((key_type = zend_hash_get_current_key_ex(Z_ARRVAL_P(var_array), &fld, - &fld_len, &num_idx, 0, &pos)) != HASH_KEY_NON_EXISTANT) { + &fld_len, &num_idx, 0, &pos)) != HASH_KEY_NON_EXISTENT) { if (key_type == HASH_KEY_IS_LONG) { php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Expects associative array for values to be inserted"); goto cleanup; @@ -6233,7 +6377,7 @@ PHP_PGSQL_API int php_pgsql_update(PGconn *pg_link, const char *table, zval *var } smart_str_appends(&querystr, "UPDATE "); - smart_str_appends(&querystr, table); + build_tablename(&querystr, pg_link, table); smart_str_appends(&querystr, " SET "); if (build_assignment_string(&querystr, Z_ARRVAL_P(var_array), 0, ",", 1 TSRMLS_CC)) @@ -6334,7 +6478,7 @@ PHP_PGSQL_API int php_pgsql_delete(PGconn *pg_link, const char *table, zval *ids } smart_str_appends(&querystr, "DELETE FROM "); - smart_str_appends(&querystr, table); + build_tablename(&querystr, pg_link, table); smart_str_appends(&querystr, " WHERE "); if (build_assignment_string(&querystr, Z_ARRVAL_P(ids_array), 1, " AND ", sizeof(" AND ")-1 TSRMLS_CC)) @@ -6470,7 +6614,7 @@ PHP_PGSQL_API int php_pgsql_select(PGconn *pg_link, const char *table, zval *ids } smart_str_appends(&querystr, "SELECT * FROM "); - smart_str_appends(&querystr, table); + build_tablename(&querystr, pg_link, table); smart_str_appends(&querystr, " WHERE "); if (build_assignment_string(&querystr, Z_ARRVAL_P(ids_array), 1, " AND ", sizeof(" AND ")-1 TSRMLS_CC)) diff --git a/ext/pgsql/tests/09notice.phpt b/ext/pgsql/tests/09notice.phpt index 316706916..67ef262fc 100644 --- a/ext/pgsql/tests/09notice.phpt +++ b/ext/pgsql/tests/09notice.phpt @@ -10,7 +10,7 @@ _skip_lc_messages(); ?> --INI-- pgsql.log_notice=1 -pgsql.ignore_notices=0 +pgsql.ignore_notice=0 --FILE-- <?php include 'config.inc'; diff --git a/ext/pgsql/tests/10pg_convert.phpt b/ext/pgsql/tests/10pg_convert.phpt index fde4c67d3..adc2756e2 100644 --- a/ext/pgsql/tests/10pg_convert.phpt +++ b/ext/pgsql/tests/10pg_convert.phpt @@ -20,10 +20,10 @@ var_dump($converted); ?> --EXPECT-- array(3) { - ["num"]=> + [""num""]=> string(4) "1234" - ["str"]=> - string(5) "'AAA'" - ["bin"]=> - string(5) "'BBB'" -} + [""str""]=> + string(6) "E'AAA'" + [""bin""]=> + string(6) "E'BBB'" +}
\ No newline at end of file diff --git a/ext/pgsql/tests/10pg_convert_9.phpt b/ext/pgsql/tests/10pg_convert_9.phpt index bb2e7e6d2..827c96250 100644 --- a/ext/pgsql/tests/10pg_convert_9.phpt +++ b/ext/pgsql/tests/10pg_convert_9.phpt @@ -21,10 +21,10 @@ var_dump($converted); ?> --EXPECT-- array(3) { - ["num"]=> + [""num""]=> string(4) "1234" - ["str"]=> - string(5) "'AAA'" - ["bin"]=> - string(11) "'\\x424242'" -} + [""str""]=> + string(6) "E'AAA'" + [""bin""]=> + string(12) "E'\\x424242'" +}
\ No newline at end of file diff --git a/ext/pgsql/tests/12pg_insert.phpt b/ext/pgsql/tests/12pg_insert.phpt index 66304944b..9fd0dd1e3 100644 --- a/ext/pgsql/tests/12pg_insert.phpt +++ b/ext/pgsql/tests/12pg_insert.phpt @@ -20,5 +20,5 @@ echo pg_insert($db, $table_name, $fields, PGSQL_DML_STRING)."\n"; echo "Ok\n"; ?> --EXPECT-- -INSERT INTO php_pgsql_test (num,str,bin) VALUES (1234,'AAA','BBB'); -Ok +INSERT INTO "php_pgsql_test" ("num","str","bin") VALUES (1234,E'AAA',E'BBB'); +Ok
\ No newline at end of file diff --git a/ext/pgsql/tests/12pg_insert_9.phpt b/ext/pgsql/tests/12pg_insert_9.phpt index 8afae0df9..329364ad6 100644 --- a/ext/pgsql/tests/12pg_insert_9.phpt +++ b/ext/pgsql/tests/12pg_insert_9.phpt @@ -22,5 +22,5 @@ echo pg_insert($db, $table_name, $fields, PGSQL_DML_STRING)."\n"; echo "Ok\n"; ?> --EXPECT-- -INSERT INTO php_pgsql_test (num,str,bin) VALUES (1234,'AAA','\\x424242'); -Ok +INSERT INTO "php_pgsql_test" ("num","str","bin") VALUES (1234,E'AAA',E'\\x424242'); +Ok
\ No newline at end of file diff --git a/ext/pgsql/tests/13pg_select.phpt b/ext/pgsql/tests/13pg_select.phpt index f1504a8b1..db2ca06bf 100644 --- a/ext/pgsql/tests/13pg_select.phpt +++ b/ext/pgsql/tests/13pg_select.phpt @@ -33,5 +33,5 @@ array(1) { string(3) "BBB" } } -SELECT * FROM php_pgsql_test WHERE num=1234; +SELECT * FROM "php_pgsql_test" WHERE "num"=1234; Ok diff --git a/ext/pgsql/tests/13pg_select_9.phpt b/ext/pgsql/tests/13pg_select_9.phpt index 422c461b6..67adc9d21 100644 --- a/ext/pgsql/tests/13pg_select_9.phpt +++ b/ext/pgsql/tests/13pg_select_9.phpt @@ -35,5 +35,5 @@ array(1) { string(8) "\x424242" } } -SELECT * FROM php_pgsql_test WHERE num=1234; -Ok +SELECT * FROM "php_pgsql_test" WHERE "num"=1234; +Ok
\ No newline at end of file diff --git a/ext/pgsql/tests/14pg_update.phpt b/ext/pgsql/tests/14pg_update.phpt index 3260f2b73..347cac944 100644 --- a/ext/pgsql/tests/14pg_update.phpt +++ b/ext/pgsql/tests/14pg_update.phpt @@ -21,5 +21,5 @@ echo pg_update($db, $table_name, $fields, $ids, PGSQL_DML_STRING)."\n"; echo "Ok\n"; ?> --EXPECT-- -UPDATE php_pgsql_test SET num=1234,str='ABC',bin='XYZ' WHERE num=1234; -Ok +UPDATE "php_pgsql_test" SET "num"=1234,"str"=E'ABC',"bin"=E'XYZ' WHERE "num"=1234; +Ok
\ No newline at end of file diff --git a/ext/pgsql/tests/14pg_update_9.phpt b/ext/pgsql/tests/14pg_update_9.phpt index bc5cf673e..e766c1f38 100644 --- a/ext/pgsql/tests/14pg_update_9.phpt +++ b/ext/pgsql/tests/14pg_update_9.phpt @@ -23,5 +23,5 @@ echo pg_update($db, $table_name, $fields, $ids, PGSQL_DML_STRING)."\n"; echo "Ok\n"; ?> --EXPECT-- -UPDATE php_pgsql_test SET num=1234,str='ABC',bin='\\x58595a' WHERE num=1234; -Ok +UPDATE "php_pgsql_test" SET "num"=1234,"str"=E'ABC',"bin"=E'\\x58595a' WHERE "num"=1234; +Ok
\ No newline at end of file diff --git a/ext/pgsql/tests/80_bug32223.phpt b/ext/pgsql/tests/80_bug32223.phpt index 573742c6e..cad5fb3a1 100644 --- a/ext/pgsql/tests/80_bug32223.phpt +++ b/ext/pgsql/tests/80_bug32223.phpt @@ -15,6 +15,8 @@ end; ' LANGUAGE plpgsql;"); if (!$res) die('skip PLPGSQL not available'); ?> +--INI-- +pgsql.ignore_notice=0 --FILE-- <?php diff --git a/ext/pgsql/tests/80_bug32223b.phpt b/ext/pgsql/tests/80_bug32223b.phpt index aada3f01b..e79685c43 100644 --- a/ext/pgsql/tests/80_bug32223b.phpt +++ b/ext/pgsql/tests/80_bug32223b.phpt @@ -15,6 +15,8 @@ end; ' LANGUAGE plpgsql;"); if (!$res) die('skip PLPGSQL not available'); ?> +--INI-- +pgsql.ignore_notice=0 --FILE-- <?php diff --git a/ext/pgsql/tests/bug47199.phpt b/ext/pgsql/tests/bug47199.phpt index 5bfac0b1b..faa787fd5 100644 --- a/ext/pgsql/tests/bug47199.phpt +++ b/ext/pgsql/tests/bug47199.phpt @@ -52,8 +52,8 @@ array(2) { string(1) "2" } } -DELETE FROM test_47199 WHERE null_field IS NULL AND not_null_field=2; -UPDATE test_47199 SET null_field=NULL,not_null_field=0 WHERE not_null_field=1 AND null_field IS NULL; +DELETE FROM "test_47199" WHERE "null_field" IS NULL AND "not_null_field"=2; +UPDATE "test_47199" SET "null_field"=NULL,"not_null_field"=0 WHERE "not_null_field"=1 AND "null_field" IS NULL; array(1) { [0]=> array(2) { diff --git a/ext/pgsql/tests/bug64609.phpt b/ext/pgsql/tests/bug64609.phpt index 0df63012d..72fac7648 100644 --- a/ext/pgsql/tests/bug64609.phpt +++ b/ext/pgsql/tests/bug64609.phpt @@ -25,6 +25,6 @@ var_dump($converted); ?> --EXPECT-- array(1) { - ["a"]=> - string(4) "'ok'" -} + [""a""]=> + string(5) "E'ok'" +}
\ No newline at end of file diff --git a/ext/pgsql/tests/config.inc b/ext/pgsql/tests/config.inc index 2b5f05a71..d4bbb3382 100644 --- a/ext/pgsql/tests/config.inc +++ b/ext/pgsql/tests/config.inc @@ -2,7 +2,7 @@ // These vars are used to connect db and create test table. // values can be set to meet your environment -$conn_str = "host=localhost dbname=test"; // connection string +$conn_str = "host=localhost dbname=test port=5432"; // connection string $table_name = "php_pgsql_test"; // test table that should be exist $num_test_record = 1000; // Number of records to create diff --git a/ext/pgsql/tests/pg_delete_001.phpt b/ext/pgsql/tests/pg_delete_001.phpt index abb65be14..a98c95dc4 100644 --- a/ext/pgsql/tests/pg_delete_001.phpt +++ b/ext/pgsql/tests/pg_delete_001.phpt @@ -45,8 +45,8 @@ pg_query('DROP SCHEMA phptests'); ?> --EXPECTF-- -string(37) "DELETE FROM foo WHERE id=1 AND id2=2;" -string(46) "DELETE FROM phptests.foo WHERE id=2 AND id2=3;" +string(43) "DELETE FROM "foo" WHERE "id"=1 AND "id2"=2;" +string(54) "DELETE FROM "phptests"."foo" WHERE "id"=2 AND "id2"=3;" array(2) { [0]=> array(2) { diff --git a/ext/pgsql/tests/pg_insert_001.phpt b/ext/pgsql/tests/pg_insert_001.phpt index 7d2721918..626d4d0f8 100644 --- a/ext/pgsql/tests/pg_insert_001.phpt +++ b/ext/pgsql/tests/pg_insert_001.phpt @@ -28,7 +28,7 @@ pg_query('DROP SCHEMA phptests'); --EXPECTF-- Warning: pg_insert(): Table 'foo' doesn't exists in %s on line %d -string(47) "INSERT INTO phptests.foo (id,id2) VALUES (1,2);" +string(55) "INSERT INTO "phptests"."foo" ("id","id2") VALUES (1,2);" array(1) { [0]=> array(2) { diff --git a/ext/pgsql/tests/pg_update_001.phpt b/ext/pgsql/tests/pg_update_001.phpt index 95fa69256..60db35c15 100644 --- a/ext/pgsql/tests/pg_update_001.phpt +++ b/ext/pgsql/tests/pg_update_001.phpt @@ -35,8 +35,8 @@ pg_query('DROP SCHEMA phptests'); ?> --EXPECT-- -string(32) "UPDATE foo SET id=10 WHERE id=1;" -string(43) "UPDATE phptests.foo SET id=100 WHERE id2=2;" +string(38) "UPDATE "foo" SET "id"=10 WHERE "id"=1;" +string(51) "UPDATE "phptests"."foo" SET "id"=100 WHERE "id2"=2;" array(2) { ["id"]=> string(2) "10" diff --git a/ext/phar/dirstream.c b/ext/phar/dirstream.c index 277d058ea..c29ca9d96 100644 --- a/ext/phar/dirstream.c +++ b/ext/phar/dirstream.c @@ -103,7 +103,7 @@ static size_t phar_dir_read(php_stream *stream, char *buf, size_t count TSRMLS_D return 0; } - if (HASH_KEY_NON_EXISTANT == zend_hash_get_current_key_ex(data, &key, &keylen, &unused, 0, NULL)) { + if (HASH_KEY_NON_EXISTENT == zend_hash_get_current_key_ex(data, &key, &keylen, &unused, 0, NULL)) { return 0; } @@ -211,7 +211,7 @@ static php_stream *phar_make_dirstream(char *dir, HashTable *manifest TSRMLS_DC) zend_hash_internal_pointer_reset(manifest); while (FAILURE != zend_hash_has_more_elements(manifest)) { - if (HASH_KEY_NON_EXISTANT == zend_hash_get_current_key_ex(manifest, &key, &keylen, &unused, 0, NULL)) { + if (HASH_KEY_NON_EXISTENT == zend_hash_get_current_key_ex(manifest, &key, &keylen, &unused, 0, NULL)) { break; } @@ -403,7 +403,7 @@ php_stream *phar_wrapper_open_dir(php_stream_wrapper *wrapper, char *path, char /* search for directory */ zend_hash_internal_pointer_reset(&phar->manifest); while (FAILURE != zend_hash_has_more_elements(&phar->manifest)) { - if (HASH_KEY_NON_EXISTANT != + if (HASH_KEY_NON_EXISTENT != zend_hash_get_current_key_ex( &phar->manifest, &key, &keylen, &unused, 0, NULL)) { PHAR_STR(key, str_key); @@ -637,7 +637,7 @@ int phar_wrapper_rmdir(php_stream_wrapper *wrapper, char *url, int options, php_ if (!entry->is_deleted) { for (zend_hash_internal_pointer_reset(&phar->manifest); - HASH_KEY_NON_EXISTANT != zend_hash_get_current_key_ex(&phar->manifest, &key, &key_len, &unused, 0, NULL); + HASH_KEY_NON_EXISTENT != zend_hash_get_current_key_ex(&phar->manifest, &key, &key_len, &unused, 0, NULL); zend_hash_move_forward(&phar->manifest)) { PHAR_STR(key, str_key); @@ -658,7 +658,7 @@ int phar_wrapper_rmdir(php_stream_wrapper *wrapper, char *url, int options, php_ } for (zend_hash_internal_pointer_reset(&phar->virtual_dirs); - HASH_KEY_NON_EXISTANT != zend_hash_get_current_key_ex(&phar->virtual_dirs, &key, &key_len, &unused, 0, NULL); + HASH_KEY_NON_EXISTENT != zend_hash_get_current_key_ex(&phar->virtual_dirs, &key, &key_len, &unused, 0, NULL); zend_hash_move_forward(&phar->virtual_dirs)) { PHAR_STR(key, str_key); diff --git a/ext/phar/phar.c b/ext/phar/phar.c index c5042cc34..ec8e5fbde 100644 --- a/ext/phar/phar.c +++ b/ext/phar/phar.c @@ -1964,7 +1964,7 @@ woohoo: zend_hash_internal_pointer_reset(&(PHAR_GLOBALS->phar_fname_map)); while (FAILURE != zend_hash_has_more_elements(&(PHAR_GLOBALS->phar_fname_map))) { - if (HASH_KEY_NON_EXISTANT == zend_hash_get_current_key_ex(&(PHAR_GLOBALS->phar_fname_map), &key, &keylen, &unused, 0, NULL)) { + if (HASH_KEY_NON_EXISTENT == zend_hash_get_current_key_ex(&(PHAR_GLOBALS->phar_fname_map), &key, &keylen, &unused, 0, NULL)) { break; } @@ -1994,7 +1994,7 @@ woohoo: zend_hash_internal_pointer_reset(&cached_phars); while (FAILURE != zend_hash_has_more_elements(&cached_phars)) { - if (HASH_KEY_NON_EXISTANT == zend_hash_get_current_key_ex(&cached_phars, &key, &keylen, &unused, 0, NULL)) { + if (HASH_KEY_NON_EXISTENT == zend_hash_get_current_key_ex(&cached_phars, &key, &keylen, &unused, 0, NULL)) { break; } @@ -2579,6 +2579,7 @@ int phar_flush(phar_archive_data *phar, char *user_stub, long len, int convert, php_serialize_data_t metadata_hash; smart_str main_metadata_str = {0}; int free_user_stub, free_fp = 1, free_ufp = 1; + int manifest_hack = 0; if (phar->is_persistent) { if (error) { @@ -2930,6 +2931,12 @@ int phar_flush(phar_archive_data *phar, char *user_stub, long len, int convert, manifest_len = offset + phar->alias_len + sizeof(manifest) + main_metadata_str.len; phar_set_32(manifest, manifest_len); + /* Hack - see bug #65028, add padding byte to the end of the manifest */ + if(manifest[0] == '\r' || manifest[0] == '\n') { + manifest_len++; + phar_set_32(manifest, manifest_len); + manifest_hack = 1; + } phar_set_32(manifest+4, new_manifest_count); if (has_dirs) { *(manifest + 8) = (unsigned char) (((PHAR_API_VERSION) >> 8) & 0xFF); @@ -3054,6 +3061,22 @@ int phar_flush(phar_archive_data *phar, char *user_stub, long len, int convert, return EOF; } } + /* Hack - see bug #65028, add padding byte to the end of the manifest */ + if(manifest_hack) { + if(1 != php_stream_write(newfile, manifest, 1)) { + if (closeoldfile) { + php_stream_close(oldfile); + } + + php_stream_close(newfile); + + if (error) { + spprintf(error, 0, "unable to write manifest padding byte"); + } + + return EOF; + } + } /* now copy the actual file data to the new phar */ offset = php_stream_tell(newfile); diff --git a/ext/phar/stream.c b/ext/phar/stream.c index 924138d8f..401d81e10 100644 --- a/ext/phar/stream.c +++ b/ext/phar/stream.c @@ -635,7 +635,7 @@ static int phar_wrapper_stat(php_stream_wrapper *wrapper, char *url, int flags, zend_hash_internal_pointer_reset_ex(&phar->mounted_dirs, &pos); while (FAILURE != zend_hash_has_more_elements_ex(&phar->mounted_dirs, &pos)) { - if (HASH_KEY_NON_EXISTANT == zend_hash_get_current_key_ex(&phar->mounted_dirs, &key, &keylen, &unused, 0, &pos)) { + if (HASH_KEY_NON_EXISTENT == zend_hash_get_current_key_ex(&phar->mounted_dirs, &key, &keylen, &unused, 0, &pos)) { break; } PHAR_STR(key, str_key); @@ -918,7 +918,7 @@ static int phar_wrapper_rename(php_stream_wrapper *wrapper, char *url_from, char uint to_len = strlen(resource_to->path+1); for (zend_hash_internal_pointer_reset(&phar->manifest); - HASH_KEY_NON_EXISTANT != (key_type = zend_hash_get_current_key_ex(&phar->manifest, &key, &key_len, &unused, 0, NULL)) && + HASH_KEY_NON_EXISTENT != (key_type = zend_hash_get_current_key_ex(&phar->manifest, &key, &key_len, &unused, 0, NULL)) && SUCCESS == zend_hash_get_current_data(&phar->manifest, (void **) &entry); zend_hash_move_forward(&phar->manifest)) { @@ -952,7 +952,7 @@ static int phar_wrapper_rename(php_stream_wrapper *wrapper, char *url_from, char } for (zend_hash_internal_pointer_reset(&phar->virtual_dirs); - HASH_KEY_NON_EXISTANT != (key_type = zend_hash_get_current_key_ex(&phar->virtual_dirs, &key, &key_len, &unused, 0, NULL)); + HASH_KEY_NON_EXISTENT != (key_type = zend_hash_get_current_key_ex(&phar->virtual_dirs, &key, &key_len, &unused, 0, NULL)); zend_hash_move_forward(&phar->virtual_dirs)) { PHAR_STR(key, str_key); @@ -979,7 +979,7 @@ static int phar_wrapper_rename(php_stream_wrapper *wrapper, char *url_from, char } for (zend_hash_internal_pointer_reset(&phar->mounted_dirs); - HASH_KEY_NON_EXISTANT != (key_type = zend_hash_get_current_key_ex(&phar->mounted_dirs, &key, &key_len, &unused, 0, NULL)) && + HASH_KEY_NON_EXISTENT != (key_type = zend_hash_get_current_key_ex(&phar->mounted_dirs, &key, &key_len, &unused, 0, NULL)) && SUCCESS == zend_hash_get_current_data(&phar->mounted_dirs, (void **) &entry); zend_hash_move_forward(&phar->mounted_dirs)) { diff --git a/ext/phar/tests/bug65028.phpt b/ext/phar/tests/bug65028.phpt new file mode 100644 index 000000000..74273b850 --- /dev/null +++ b/ext/phar/tests/bug65028.phpt @@ -0,0 +1,156 @@ +--TEST-- +Phar - test specific manifest length +--INI-- +phar.readonly=0 +--SKIPIF-- +<?php if (!extension_loaded("phar")) die("skip"); ?> +--FILE-- +<?php + +$files = array( + "lib/widgets/Widgets.php", + "lib/events/FormBeginEventArgs.php", + "lib/events/FormEndEventArgs.php", + "lib/Core.php", + "lib/database/MySqlDatabase.php", + "lib/utils/DateUtil.php", + "js/global.js", + "files/_emptyDirectory", + "files/search/schema.xml", + "vendor/Fusonic/Linq/Internal/WhereIterator.php", + "vendor/Fusonic/Linq/Internal/SelectManyIterator.php", + "vendor/Fusonic/Linq/Internal/SelectIterator.php", + "vendor/Fusonic/Linq/Internal/DiffIterator.php", + "vendor/Fusonic/Linq/Internal/GroupIterator.php", + "vendor/Fusonic/Linq/Internal/DistinctIterator.php", + "vendor/Fusonic/Linq/Internal/LinqHelper.php", + "vendor/Fusonic/Linq/Internal/OrderIterator.php", + "vendor/Fusonic/Linq/Internal/IntersectIterator.php", + "vendor/Fusonic/Linq/GroupedLinq.php", + "vendor/Fusonic/Linq.php", + "vendor/Fusonic/UI/Widgets/Forms/FormBegin.php", + "vendor/Fusonic/UI/Widgets/Forms/FormSectionBuilder.php", + "vendor/Fusonic/UI/Widgets/Forms/AutoSelect.php", + "vendor/Fusonic/UI/Widgets/Forms/ControlGroup.php", + "vendor/Fusonic/UI/Widgets/Forms/FormEnd.php", + "vendor/Fusonic/UI/Widgets/WidgetBase.php", + "modules/calendar/ajax/calendarGetInvitedUsersContentAjaxHandler.php", + "modules/calendar/js/calendarAppointmentForm.js", + "modules/calendar/misc/calendarAppointment.php", + "modules/calendar/pages/forms/calendarAppointmentForm.php", + "modules/calendar/setup/config.xml", + "modules/cmt/js/cmtMicroCommentsWidget.js", + "modules/cmt/setup/config.xml", + "modules/meta/misc/metaContentHelper.php", + "modules/meta/setup/config.xml", + "modules/brd/misc/brdPostStreamFormatter.php", + "modules/brd/misc/brdPost.php", + "modules/brd/setup/config/streamContents.xml", + "modules/brd/setup/resources/lang/en.xml", + "modules/brd/setup/resources/lang/de.xml", + "modules/brd/setup/config.xml", + "modules/auth/misc/authLoginService.php", + "modules/auth/setup/config.xml", + "modules/bwd/cache/bwdWordCacheCreator.php", + "modules/bwd/bwd.php", + "modules/bwd/setup/config.xml", + "modules/nws/templates/pages/forms/nwsNewsForm.tpl", + "modules/nws/templates/pages/nwsShowNewsPage.tpl", + "modules/nws/pages/forms/nwsNewsForm.php", + "modules/nws/pages/nwsShowNewsPage.php", + "modules/nws/setup/config.xml", + "modules/gmp/cache/gmpMarkersCacheCreator.php", + "modules/gmp/select/gmpMapContentSelect.php", + "modules/gmp/templates/gmpShowAppointmentPage.tpl", + "modules/gmp/templates/gmpShowLinkPage.tpl", + "modules/gmp/setup/config.xml", + "modules/mul/cache/mulVideoPortalCacheCreator.php", + "modules/mul/misc/mulPermissionHelper.php", + "modules/mul/templates/widgets/mulFileEmbedWidget_Video_Flv.tpl", + "modules/mul/setup/config/mulUploadVideoPortalMatches.xml", + "modules/mul/setup/config.xml", + "modules/cat/select/catCategorySelect.php", + "modules/cat/misc/catCategory.php", + "modules/cat/templates/pages/forms/catCategoryForm.tpl", + "modules/cat/pages/forms/catEditCategoryForm.php", + "modules/cat/pages/forms/catAddCategoryForm.php", + "modules/cat/setup/config.xml", + "modules/sty/events/styPageShowEventHandler.php", + "modules/sty/misc/styBox.php", + "modules/sty/templates/pages/forms/styLayoutForm.tpl", + "modules/sty/templates/pages/forms/styBoxForm.tpl", + "modules/sty/templates/pages/forms/styVariantForm.tpl", + "modules/sty/setup/resources/lang/en.xml", + "modules/sty/setup/resources/lang/de.xml", + "modules/sty/setup/config.xml", + "modules/reg/misc/regRegistrationHelper.php", + "modules/reg/setup/config.xml", + "modules/not/misc/notEmailNotificationProvider.php", + "modules/not/setup/config.xml", + "modules/styfusonic/setup/config.xml", + "modules/sys/ajax/sysUserAutoSuggestSelectAjaxHandler.php", + "modules/sys/js/sysUserAutoSuggestSelect.js", + "modules/sys/select/sysPermissionSelect.php", + "modules/sys/misc/sysHtaccessConfigWriter.php", + "modules/sys/misc/sysUserRepository.php", + "modules/sys/setup/resources/lang/en.xml", + "modules/sys/setup/resources/lang/de.xml", + "modules/sys/setup/config.xml", + "modules/igr/boxes/igrGreatestEntriesBoxTab.php", + "modules/igr/boxes/igrTopRatedEntriesBoxTab.php", + "modules/igr/setup/config.xml", + "modules/rat/ajax/ratRateAjaxHandler.php", + "modules/rat/ajax/ratUnlikeAjaxHandler.php", + "modules/rat/setup/config.xml", + "modules/search/select/searchModuleSelect.php", + "modules/search/select/searchOrderSelect.php", + "modules/search/misc/searchResultFormatter.php", + "modules/search/misc/searchProviderSolr.php", + "modules/search/misc/searchProviderLucene.php", + "modules/search/misc/searchResultItem.php", + "modules/search/misc/searchProviderBase.php", + "modules/search/misc/searchIProvider.php", + "modules/search/templates/misc/searchResultFormatter.tpl", + "modules/search/templates/pages/searchIndexPage.tpl", + "modules/search/templates/pages/forms/searchSearchForm.tpl", + "modules/search/pages/forms/searchSearchForm.php", + "modules/search/css/searchResultFormatter.css", + "modules/search/setup/config/sysSettings.xml", + "modules/search/setup/resources/lang/en.xml", + "modules/search/setup/resources/lang/de.xml", + "modules/search/setup/config.xml", + "style/Fusonic/40components.css", + "style/_emptyDirectory", + "index.php", +// "a", // This will make the test pass +); + +// Create Phar with the filenames above +$phar = new Phar(__DIR__ . "/bug65028.phar"); +foreach($files as $file) +{ + $phar->addFromString($file, ""); +} + +// Copy phar +copy(__DIR__ . "/bug65028.phar", __DIR__ . "/bug65028-copy.phar"); + +// Open phar +try +{ + $phar = new Phar(__DIR__ . "/bug65028-copy.phar"); + echo "No exception thrown.\n"; +} +catch(UnexpectedValueException $ex) +{ + echo "Exception thrown: " . $ex->getMessage() . "\n"; +} +?> +--CLEAN-- +<?php +@unlink(__DIR__ . "/bug65028.phar"); +@unlink(__DIR__ . "/bug65028-copy.phar"); +?> +--EXPECT-- +No exception thrown. + diff --git a/ext/phar/util.c b/ext/phar/util.c index 898d8bd4b..8348a4787 100644 --- a/ext/phar/util.c +++ b/ext/phar/util.c @@ -1554,7 +1554,7 @@ phar_entry_info *phar_get_entry_info_dir(phar_archive_data *phar, char *path, in zend_hash_internal_pointer_reset(&phar->mounted_dirs); while (FAILURE != zend_hash_has_more_elements(&phar->mounted_dirs)) { - if (HASH_KEY_NON_EXISTANT == zend_hash_get_current_key_ex(&phar->mounted_dirs, &key, &keylen, &unused, 0, NULL)) { + if (HASH_KEY_NON_EXISTENT == zend_hash_get_current_key_ex(&phar->mounted_dirs, &key, &keylen, &unused, 0, NULL)) { break; } diff --git a/ext/posix/tests/posix_ctermid.phpt b/ext/posix/tests/posix_ctermid.phpt index f77da00aa..551ed7304 100644 --- a/ext/posix/tests/posix_ctermid.phpt +++ b/ext/posix/tests/posix_ctermid.phpt @@ -13,7 +13,7 @@ PHP Testfest Berlin 2009-05-10 } // needed because of #ifdef HAVE_CTERMID in posix.c if (!function_exists('posix_ctermid')) { - die('SKIP - Fuction posix_ctermid() not available'); + die('SKIP - Function posix_ctermid() not available'); } ?> --FILE-- diff --git a/ext/pspell/config.m4 b/ext/pspell/config.m4 index 67e5b2760..481a9ae89 100644 --- a/ext/pspell/config.m4 +++ b/ext/pspell/config.m4 @@ -3,7 +3,7 @@ dnl $Id$ dnl PHP_ARG_WITH(pspell,for PSPELL support, -[ --with-pspell[=DIR] Include PSPELL support. +[ --with-pspell[=DIR] Include PSPELL support. GNU Aspell version 0.50.0 or higher required]) if test "$PHP_PSPELL" != "no"; then diff --git a/ext/readline/config.m4 b/ext/readline/config.m4 index b1cb0b67e..0a00370fc 100644 --- a/ext/readline/config.m4 +++ b/ext/readline/config.m4 @@ -3,11 +3,11 @@ dnl $Id$ dnl PHP_ARG_WITH(libedit,for libedit readline replacement, -[ --with-libedit[=DIR] Include libedit readline replacement (CLI/CGI only)]) +[ --with-libedit[=DIR] Include libedit readline replacement (CLI/CGI only)]) if test "$PHP_LIBEDIT" = "no"; then PHP_ARG_WITH(readline,for readline support, - [ --with-readline[=DIR] Include readline support (CLI/CGI only)]) + [ --with-readline[=DIR] Include readline support (CLI/CGI only)]) else dnl "register" the --with-readline option to preven invalid "unknown configure option" warning php_with_readline=no diff --git a/ext/recode/config.m4 b/ext/recode/config.m4 index 8df4cfc41..7f394d046 100644 --- a/ext/recode/config.m4 +++ b/ext/recode/config.m4 @@ -3,7 +3,7 @@ dnl $Id$ dnl PHP_ARG_WITH(recode,for recode support, -[ --with-recode[=DIR] Include recode support]) +[ --with-recode[=DIR] Include recode support]) if test "$PHP_RECODE" != "no"; then RECODE_LIST="$PHP_RECODE /usr/local /usr /opt" diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index b65ccaa26..b1f7484f2 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -5259,7 +5259,7 @@ ZEND_METHOD(reflection_extension, getVersion) /* }}} */ /* {{{ proto public ReflectionFunction[] ReflectionExtension::getFunctions() - Returns an array of this extension's fuctions */ + Returns an array of this extension's functions */ ZEND_METHOD(reflection_extension, getFunctions) { reflection_object *intern; diff --git a/ext/session/mod_files.c b/ext/session/mod_files.c index 053c617de..e5733b44f 100644 --- a/ext/session/mod_files.c +++ b/ext/session/mod_files.c @@ -61,40 +61,9 @@ typedef struct { } ps_files; ps_module ps_mod_files = { - PS_MOD(files) + PS_MOD_SID(files) }; -/* If you change the logic here, please also update the error message in - * ps_files_open() appropriately */ -static int ps_files_valid_key(const char *key) -{ - size_t len; - const char *p; - char c; - int ret = 1; - - for (p = key; (c = *p); p++) { - /* valid characters are a..z,A..Z,0..9 */ - if (!((c >= 'a' && c <= 'z') - || (c >= 'A' && c <= 'Z') - || (c >= '0' && c <= '9') - || c == ',' - || c == '-')) { - ret = 0; - break; - } - } - - len = p - key; - - /* Somewhat arbitrary length limit here, but should be way more than - anyone needs and avoids file-level warnings later on if we exceed MAX_PATH */ - if (len == 0 || len > 128) { - ret = 0; - } - - return ret; -} static char *ps_files_path_create(char *buf, size_t buflen, ps_files *data, const char *key) { @@ -155,11 +124,11 @@ static void ps_files_open(ps_files *data, const char *key TSRMLS_DC) ps_files_close(data); - if (!ps_files_valid_key(key)) { + if (php_session_valid_key(key) == FAILURE) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "The session id is too long or contains illegal characters, valid characters are a-z, A-Z, 0-9 and '-,'"); - PS(invalid_session_id) = 1; return; } + if (!ps_files_path_create(buf, sizeof(buf), data, key)) { return; } @@ -253,6 +222,21 @@ static int ps_files_cleanup_dir(const char *dirname, int maxlifetime TSRMLS_DC) return (nrdels); } +static int ps_files_key_exists(ps_files *data, const char *key TSRMLS_DC) +{ + char buf[MAXPATHLEN]; + struct stat sbuf; + + if (!key || !ps_files_path_create(buf, sizeof(buf), data, key)) { + return FAILURE; + } + if (VCWD_STAT(buf, &sbuf)) { + return FAILURE; + } + return SUCCESS; +} + + #define PS_FILES_DATA ps_files *data = PS_GET_MOD_DATA() PS_OPEN_FUNC(files) @@ -342,6 +326,24 @@ PS_READ_FUNC(files) struct stat sbuf; PS_FILES_DATA; + /* If strict mode, check session id existence */ + if (PS(use_strict_mode) && + ps_files_key_exists(data, key TSRMLS_CC) == FAILURE) { + /* key points to PS(id), but cannot change here. */ + if (key) { + efree(PS(id)); + PS(id) = NULL; + } + PS(id) = PS(mod)->s_create_sid((void **)&data, NULL TSRMLS_CC); + if (!PS(id)) { + return FAILURE; + } + php_session_reset_id(TSRMLS_C); + if (PS(use_cookies)) { + PS(send_cookie) = 1; + } + } + ps_files_open(data, key TSRMLS_CC); if (data->fd < 0) { return FAILURE; @@ -454,6 +456,30 @@ PS_GC_FUNC(files) return SUCCESS; } +PS_CREATE_SID_FUNC(files) +{ + char *sid; + int maxfail = 3; + PS_FILES_DATA; + + do { + sid = php_session_create_id((void **)&data, newlen TSRMLS_CC); + /* Check collision */ + if (data && ps_files_key_exists(data, sid TSRMLS_CC) == SUCCESS) { + if (sid) { + efree(sid); + sid = NULL; + } + if (!(maxfail--)) { + return NULL; + } + } + } while(!sid); + + return sid; +} + + /* * Local variables: * tab-width: 4 diff --git a/ext/session/mod_files.h b/ext/session/mod_files.h index c97d168b1..94cbd6d02 100644 --- a/ext/session/mod_files.h +++ b/ext/session/mod_files.h @@ -24,6 +24,6 @@ extern ps_module ps_mod_files; #define ps_files_ptr &ps_mod_files -PS_FUNCS(files); +PS_FUNCS_SID(files); #endif diff --git a/ext/session/mod_mm.c b/ext/session/mod_mm.c index e0d16d192..69c0da7bd 100644 --- a/ext/session/mod_mm.c +++ b/ext/session/mod_mm.c @@ -124,7 +124,7 @@ static ps_sd *ps_sd_new(ps_mm *data, const char *key) if (!sd) { TSRMLS_FETCH(); - php_error_docref(NULL TSRMLS_CC, E_WARNING, "mm_malloc failed, avail %d, err %s", mm_available(data->mm), mm_error()); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "mm_malloc failed, avail %ld, err %s", mm_available(data->mm), mm_error()); return NULL; } @@ -208,8 +208,22 @@ static ps_sd *ps_sd_lookup(ps_mm *data, const char *key, int rw) return ret; } +static int ps_mm_key_exists(ps_mm *data, const char *key TSRMLS_DC) +{ + ps_sd *sd; + + if (!key) { + return FAILURE; + } + sd = ps_sd_lookup(data, key, 0); + if (sd) { + return SUCCESS; + } + return FAILURE; +} + ps_module ps_mod_mm = { - PS_MOD(mm) + PS_MOD_SID(mm) }; #define PS_MM_DATA ps_mm *data = PS_GET_MOD_DATA() @@ -341,6 +355,24 @@ PS_READ_FUNC(mm) mm_lock(data->mm, MM_LOCK_RD); + /* If there is an ID and strict mode, verify existence */ + if (PS(use_strict_mode) + && ps_mm_key_exists(data, key TSRMLS_CC) == FAILURE) { + /* key points to PS(id), but cannot change here. */ + if (key) { + efree(PS(id)); + PS(id) = NULL; + } + PS(id) = PS(mod)->s_create_sid((void **)&data, NULL TSRMLS_CC); + if (!PS(id)) { + return FAILURE; + } + php_session_reset_id(TSRMLS_C); + if (PS(use_cookies)) { + PS(send_cookie) = 1; + } + } + sd = ps_sd_lookup(data, key, 0); if (sd) { *vallen = sd->datalen; @@ -444,6 +476,29 @@ PS_GC_FUNC(mm) return SUCCESS; } +PS_CREATE_SID_FUNC(mm) +{ + char *sid; + int maxfail = 3; + PS_MM_DATA; + + do { + sid = php_session_create_id((void **)&data, newlen TSRMLS_CC); + /* Check collision */ + if (ps_mm_key_exists(data, sid TSRMLS_CC) == SUCCESS) { + if (sid) { + efree(sid); + sid = NULL; + } + if (!(maxfail--)) { + return NULL; + } + } + } while(!sid); + + return sid; +} + #endif /* diff --git a/ext/session/php_session.h b/ext/session/php_session.h index 1dd5b1a1a..e8e79f0fa 100644 --- a/ext/session/php_session.h +++ b/ext/session/php_session.h @@ -29,6 +29,9 @@ #define PHP_SESSION_API 20020330 +/* To check php_session_valid_key()/php_session_reset_id() */ +#define PHP_SESSION_STRICT 1 + #define PS_OPEN_ARGS void **mod_data, const char *save_path, const char *session_name TSRMLS_DC #define PS_CLOSE_ARGS void **mod_data TSRMLS_DC #define PS_READ_ARGS void **mod_data, const char *key, char **val, int *vallen TSRMLS_DC @@ -75,7 +78,7 @@ typedef struct ps_module_struct { #x, ps_open_##x, ps_close_##x, ps_read_##x, ps_write_##x, \ ps_delete_##x, ps_gc_##x, php_session_create_id -/* SID enabled module handler definitions */ +/* SID creation enabled module handler definitions */ #define PS_FUNCS_SID(x) \ PS_OPEN_FUNC(x); \ PS_CLOSE_FUNC(x); \ @@ -175,6 +178,8 @@ typedef struct _php_ps_globals { smart_str rfc1867_name; /* session.upload_progress.name */ long rfc1867_freq; /* session.upload_progress.freq */ double rfc1867_min_freq; /* session.upload_progress.min_freq */ + + zend_bool use_strict_mode; /* whether or not PHP accepts unknown session ids */ } php_ps_globals; typedef php_ps_globals zend_ps_globals; @@ -230,6 +235,9 @@ PHPAPI void php_session_start(TSRMLS_D); PHPAPI ps_module *_php_find_ps_module(char *name TSRMLS_DC); PHPAPI const ps_serializer *_php_find_ps_serializer(char *name TSRMLS_DC); +PHPAPI int php_session_valid_key(const char *key); +PHPAPI void php_session_reset_id(TSRMLS_D); + #define PS_ADD_VARL(name,namelen) do { \ php_add_session_var(name, namelen TSRMLS_CC); \ } while (0) @@ -254,7 +262,7 @@ PHPAPI const ps_serializer *_php_find_ps_serializer(char *name TSRMLS_DC); int key_type; \ \ for (zend_hash_internal_pointer_reset(_ht); \ - (key_type = zend_hash_get_current_key_ex(_ht, &key, &key_length, &num_key, 0, NULL)) != HASH_KEY_NON_EXISTANT; \ + (key_type = zend_hash_get_current_key_ex(_ht, &key, &key_length, &num_key, 0, NULL)) != HASH_KEY_NON_EXISTENT; \ zend_hash_move_forward(_ht)) { \ if (key_type == HASH_KEY_IS_LONG) { \ php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Skipping numeric key %ld", num_key); \ diff --git a/ext/session/session.c b/ext/session/session.c index e992f31d2..7c6672de5 100644 --- a/ext/session/session.c +++ b/ext/session/session.c @@ -86,6 +86,8 @@ zend_class_entry *php_session_id_iface_entry; return FAILURE; \ } +static void php_session_send_cookie(TSRMLS_D); + /* Dispatched by RINIT and by php_session_destroy */ static inline void php_rinit_session_globals(TSRMLS_D) /* {{{ */ { @@ -126,7 +128,7 @@ static int php_session_destroy(TSRMLS_D) /* {{{ */ return FAILURE; } - if (PS(mod)->s_destroy(&PS(mod_data), PS(id) TSRMLS_CC) == FAILURE) { + if (PS(id) && PS(mod)->s_destroy(&PS(mod_data), PS(id) TSRMLS_CC) == FAILURE) { retval = FAILURE; php_error_docref(NULL TSRMLS_CC, E_WARNING, "Session object destruction failed"); } @@ -284,7 +286,7 @@ PHPAPI char *php_session_create_id(PS_CREATE_SID_ARGS) /* {{{ */ PHP_MD5_CTX md5_context; PHP_SHA1_CTX sha1_context; #if defined(HAVE_HASH_EXT) && !defined(COMPILE_DL_HASH) - void *hash_context; + void *hash_context = NULL; #endif unsigned char *digest; int digest_len; @@ -344,7 +346,7 @@ PHPAPI char *php_session_create_id(PS_CREATE_SID_ARGS) /* {{{ */ unsigned char rbuf[2048]; size_t toread = PS(entropy_length); - if (php_win32_get_random_bytes(rbuf, (size_t) toread) == SUCCESS){ + if (php_win32_get_random_bytes(rbuf, MIN(toread, sizeof(rbuf))) == SUCCESS){ switch (PS(hash_func)) { case PS_HASH_FUNC_MD5: @@ -428,17 +430,45 @@ PHPAPI char *php_session_create_id(PS_CREATE_SID_ARGS) /* {{{ */ } /* }}} */ -static void php_session_initialize(TSRMLS_D) /* {{{ */ +/* Default session id char validation function allowed by ps_modules. + * If you change the logic here, please also update the error message in + * ps_modules appropriately */ +PHPAPI int php_session_valid_key(const char *key) /* {{{ */ { - char *val; - int vallen; + size_t len; + const char *p; + char c; + int ret = SUCCESS; + + for (p = key; (c = *p); p++) { + /* valid characters are a..z,A..Z,0..9 */ + if (!((c >= 'a' && c <= 'z') + || (c >= 'A' && c <= 'Z') + || (c >= '0' && c <= '9') + || c == ',' + || c == '-')) { + ret = FAILURE; + break; + } + } - /* check session name for invalid characters */ - if (PS(id) && strpbrk(PS(id), "\r\n\t <>'\"\\")) { - efree(PS(id)); - PS(id) = NULL; + len = p - key; + + /* Somewhat arbitrary length limit here, but should be way more than + anyone needs and avoids file-level warnings later on if we exceed MAX_PATH */ + if (len == 0 || len > 128) { + ret = FAILURE; } + return ret; +} +/* }}} */ + +static void php_session_initialize(TSRMLS_D) /* {{{ */ +{ + char *val = NULL; + int vallen; + if (!PS(mod)) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "No storage module chosen - failed to initialize session"); return; @@ -452,28 +482,38 @@ static void php_session_initialize(TSRMLS_D) /* {{{ */ /* If there is no ID, use session module to create one */ if (!PS(id)) { -new_session: PS(id) = PS(mod)->s_create_sid(&PS(mod_data), NULL TSRMLS_CC); + if (!PS(id)) { + php_error_docref(NULL TSRMLS_CC, E_ERROR, "Failed to create session ID: %s (path: %s)", PS(mod)->s_name, PS(save_path)); + return; + } if (PS(use_cookies)) { PS(send_cookie) = 1; } } + php_session_reset_id(TSRMLS_C); + PS(session_status) = php_session_active; + /* Read data */ - /* Question: if you create a SID here, should you also try to read data? - * I'm not sure, but while not doing so will remove one session operation - * it could prove usefull for those sites which wish to have "default" - * session information. */ php_session_track_init(TSRMLS_C); - PS(invalid_session_id) = 0; - if (PS(mod)->s_read(&PS(mod_data), PS(id), &val, &vallen TSRMLS_CC) == SUCCESS) { + if (PS(mod)->s_read(&PS(mod_data), PS(id), &val, &vallen TSRMLS_CC) == FAILURE) { + /* Some broken save handler implementation returns FAILURE for non-existent session ID */ + /* It's better to rase error for this, but disabled error for better compatibility */ + /* + php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Failed to read session data: %s (path: %s)", PS(mod)->s_name, PS(save_path)); + */ + } + if (val) { php_session_decode(val, vallen TSRMLS_CC); efree(val); - } else if (PS(invalid_session_id)) { /* address instances where the session read fails due to an invalid id */ - PS(invalid_session_id) = 0; - efree(PS(id)); - PS(id) = NULL; - goto new_session; + } + + if (!PS(use_cookies) && PS(send_cookie)) { + if (PS(use_trans_sid) && !PS(use_only_cookies)) { + PS(apply_trans_sid) = 1; + } + PS(send_cookie) = 0; } } /* }}} */ @@ -736,7 +776,7 @@ PHP_INI_BEGIN() STD_PHP_INI_ENTRY("session.save_path", "", PHP_INI_ALL, OnUpdateSaveDir,save_path, php_ps_globals, ps_globals) STD_PHP_INI_ENTRY("session.name", "PHPSESSID", PHP_INI_ALL, OnUpdateName, session_name, php_ps_globals, ps_globals) PHP_INI_ENTRY("session.save_handler", "files", PHP_INI_ALL, OnUpdateSaveHandler) - STD_PHP_INI_BOOLEAN("session.auto_start", "0", PHP_INI_ALL, OnUpdateBool, auto_start, php_ps_globals, ps_globals) + STD_PHP_INI_BOOLEAN("session.auto_start", "0", PHP_INI_PERDIR, OnUpdateBool, auto_start, php_ps_globals, ps_globals) STD_PHP_INI_ENTRY("session.gc_probability", "1", PHP_INI_ALL, OnUpdateLong, gc_probability, php_ps_globals, ps_globals) STD_PHP_INI_ENTRY("session.gc_divisor", "100", PHP_INI_ALL, OnUpdateLong, gc_divisor, php_ps_globals, ps_globals) STD_PHP_INI_ENTRY("session.gc_maxlifetime", "1440", PHP_INI_ALL, OnUpdateLong, gc_maxlifetime, php_ps_globals, ps_globals) @@ -748,6 +788,7 @@ PHP_INI_BEGIN() STD_PHP_INI_BOOLEAN("session.cookie_httponly", "", PHP_INI_ALL, OnUpdateBool, cookie_httponly, php_ps_globals, ps_globals) STD_PHP_INI_BOOLEAN("session.use_cookies", "1", PHP_INI_ALL, OnUpdateBool, use_cookies, php_ps_globals, ps_globals) STD_PHP_INI_BOOLEAN("session.use_only_cookies", "1", PHP_INI_ALL, OnUpdateBool, use_only_cookies, php_ps_globals, ps_globals) + STD_PHP_INI_BOOLEAN("session.use_strict_mode", "0", PHP_INI_ALL, OnUpdateBool, use_strict_mode, php_ps_globals, ps_globals) STD_PHP_INI_ENTRY("session.referer_check", "", PHP_INI_ALL, OnUpdateString, extern_referer_chk, php_ps_globals, ps_globals) #if HAVE_DEV_URANDOM STD_PHP_INI_ENTRY("session.entropy_file", "/dev/urandom", PHP_INI_ALL, OnUpdateString, entropy_file, php_ps_globals, ps_globals) @@ -1297,10 +1338,15 @@ PHPAPI const ps_serializer *_php_find_ps_serializer(char *name TSRMLS_DC) /* {{{ convert_to_string((*ppid)); \ PS(id) = estrndup(Z_STRVAL_PP(ppid), Z_STRLEN_PP(ppid)) -static void php_session_reset_id(TSRMLS_D) /* {{{ */ +PHPAPI void php_session_reset_id(TSRMLS_D) /* {{{ */ { int module_number = PS(module_number); + if (!PS(id)) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot set session ID - session ID is not initialized"); + return; + } + if (PS(use_cookies) && PS(send_cookie)) { php_session_send_cookie(TSRMLS_C); PS(send_cookie) = 0; @@ -1447,19 +1493,14 @@ PHPAPI void php_session_start(TSRMLS_D) /* {{{ */ } } - php_session_initialize(TSRMLS_C); - - if (!PS(use_cookies) && PS(send_cookie)) { - if (PS(use_trans_sid) && !PS(use_only_cookies)) { - PS(apply_trans_sid) = 1; - } - PS(send_cookie) = 0; + /* Finally check session id for dangarous characters + * Security note: session id may be embedded in HTML pages.*/ + if (PS(id) && strpbrk(PS(id), "\r\n\t <>'\"\\")) { + efree(PS(id)); + PS(id) = NULL; } - php_session_reset_id(TSRMLS_C); - - PS(session_status) = php_session_active; - + php_session_initialize(TSRMLS_C); php_session_cache_limiter(TSRMLS_C); if ((PS(mod_data) || PS(mod_user_implemented)) && PS(gc_probability) > 0) { @@ -1775,9 +1816,9 @@ static PHP_FUNCTION(session_save_path) static PHP_FUNCTION(session_id) { char *name = NULL; - int name_len; + int name_len, argc = ZEND_NUM_ARGS(); - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &name, &name_len) == FAILURE) { + if (zend_parse_parameters(argc TSRMLS_CC, "|s", &name, &name_len) == FAILURE) { return; } @@ -1822,11 +1863,13 @@ static PHP_FUNCTION(session_regenerate_id) } PS(id) = PS(mod)->s_create_sid(&PS(mod_data), NULL TSRMLS_CC); - - PS(send_cookie) = 1; - php_session_reset_id(TSRMLS_C); - - RETURN_TRUE; + if (PS(id)) { + PS(send_cookie) = 1; + php_session_reset_id(TSRMLS_C); + RETURN_TRUE; + } else { + PS(id) = STR_EMPTY_ALLOC(); + } } RETURN_FALSE; } diff --git a/ext/session/tests/003.phpt b/ext/session/tests/003.phpt index 03c3b9576..8725f06a6 100644 --- a/ext/session/tests/003.phpt +++ b/ext/session/tests/003.phpt @@ -4,6 +4,7 @@ session object deserialization <?php include('skipif.inc'); ?> --INI-- session.use_cookies=0 +session.use_strict_mode=0 session.cache_limiter= session.serialize_handler=php session.save_handler=files diff --git a/ext/session/tests/004.phpt b/ext/session/tests/004.phpt index aeb2c8b36..4547c6557 100644 --- a/ext/session/tests/004.phpt +++ b/ext/session/tests/004.phpt @@ -4,6 +4,7 @@ session_set_save_handler test <?php include('skipif.inc'); ?> --INI-- session.use_cookies=0 +session.use_strict_mode=0 session.cache_limiter= session.name=PHPSESSID session.serialize_handler=php diff --git a/ext/session/tests/005.phpt b/ext/session/tests/005.phpt index a970e6b71..796d9c377 100644 --- a/ext/session/tests/005.phpt +++ b/ext/session/tests/005.phpt @@ -4,6 +4,7 @@ custom save handler, multiple session_start()s, complex data structure test. <?php include('skipif.inc'); ?> --INI-- session.use_cookies=0 +session.use_strict_mode=0 session.cache_limiter= session.name=PHPSESSID session.serialize_handler=php diff --git a/ext/session/tests/006.phpt b/ext/session/tests/006.phpt index 03fca1038..dba6894c7 100644 --- a/ext/session/tests/006.phpt +++ b/ext/session/tests/006.phpt @@ -4,6 +4,7 @@ correct instantiation of references between variables in sessions <?php include('skipif.inc'); ?> --INI-- session.use_cookies=0 +session.use_strict_mode=0 session.cache_limiter= session.serialize_handler=php session.save_handler=files diff --git a/ext/session/tests/009.phpt b/ext/session/tests/009.phpt index d73bc238c..6d8d11c33 100644 --- a/ext/session/tests/009.phpt +++ b/ext/session/tests/009.phpt @@ -4,6 +4,7 @@ unset($_SESSION["name"]); test <?php include('skipif.inc'); ?> --INI-- session.use_cookies=0 +session.use_strict_mode=0 session.cache_limiter= session.serialize_handler=php session.save_handler=files diff --git a/ext/session/tests/012.phpt b/ext/session/tests/012.phpt index 870801127..c555d2ca1 100644 --- a/ext/session/tests/012.phpt +++ b/ext/session/tests/012.phpt @@ -4,6 +4,7 @@ registering $_SESSION should not segfault <?php include('skipif.inc'); ?> --INI-- session.use_cookies=0 +session.use_strict_mode=0 session.cache_limiter= session.serialize_handler=php session.save_handler=files diff --git a/ext/session/tests/013.phpt b/ext/session/tests/013.phpt index 8d0f284b1..32909eb58 100644 --- a/ext/session/tests/013.phpt +++ b/ext/session/tests/013.phpt @@ -4,6 +4,7 @@ redefining SID should not cause warnings <?php include('skipif.inc'); ?> --INI-- session.use_cookies=0 +session.use_strict_mode=0 session.cache_limiter= session.serialize_handler=php session.save_handler=files diff --git a/ext/session/tests/014.phpt b/ext/session/tests/014.phpt index 73bc28ea6..cbf22b142 100644 --- a/ext/session/tests/014.phpt +++ b/ext/session/tests/014.phpt @@ -5,6 +5,7 @@ a script should not be able to modify session.use_trans_sid --INI-- session.use_trans_sid=0 session.use_cookies=0 +session.use_strict_mode=0 session.cache_limiter= session.name=PHPSESSID session.serialize_handler=php diff --git a/ext/session/tests/015.phpt b/ext/session/tests/015.phpt index 7d7b73734..527b86bc1 100644 --- a/ext/session/tests/015.phpt +++ b/ext/session/tests/015.phpt @@ -6,6 +6,7 @@ use_trans_sid should not affect SID session.use_trans_sid=1 session.use_cookies=0 session.use_only_cookies=0 +session.use_strict_mode=0 session.cache_limiter= arg_separator.output=& session.name=PHPSESSID diff --git a/ext/session/tests/016.phpt b/ext/session/tests/016.phpt index 83703294a..0e368e2f8 100644 --- a/ext/session/tests/016.phpt +++ b/ext/session/tests/016.phpt @@ -16,10 +16,11 @@ session.serialize_handler=php <?php error_reporting(E_ALL); -@session_start(); +session_start(); $HTTP_SESSION_VARS["test"] = 1; -@session_write_close(); +session_write_close(); print "I live\n"; ?> ---EXPECT-- +--EXPECTF-- +Warning: session_write_close(): Failed to write session data (files). Please verify that the current setting of session.save_path is correct (123;:/really\completely:::/invalid;;,23123;213) in %s on line %d I live diff --git a/ext/session/tests/018.phpt b/ext/session/tests/018.phpt index def1f419c..5ec132b34 100644 --- a/ext/session/tests/018.phpt +++ b/ext/session/tests/018.phpt @@ -5,6 +5,7 @@ rewriter correctly handles attribute names which contain dashes --INI-- session.use_cookies=0 session.use_only_cookies=0 +session.use_strict_mode=0 session.cache_limiter= session.use_trans_sid=1 session.name=PHPSESSID diff --git a/ext/session/tests/019.phpt b/ext/session/tests/019.phpt index 3ee8ccd42..0f06add5a 100644 --- a/ext/session/tests/019.phpt +++ b/ext/session/tests/019.phpt @@ -4,6 +4,7 @@ serializing references test case using globals <?php include('skipif.inc'); ?> --INI-- session.use_cookies=0 +session.use_strict_mode=0 session.cache_limiter= session.serialize_handler=php session.save_handler=files diff --git a/ext/session/tests/020.phpt b/ext/session/tests/020.phpt index f43bac5d1..267e52191 100644 --- a/ext/session/tests/020.phpt +++ b/ext/session/tests/020.phpt @@ -1,10 +1,11 @@ --TEST-- -rewriter uses arg_seperator.output for modifying URLs +rewriter uses arg_separator.output for modifying URLs --SKIPIF-- <?php include('skipif.inc'); ?> --INI-- session.use_cookies=0 session.use_only_cookies=0 +session.use_strict_mode=0 session.cache_limiter= session.use_trans_sid=1 arg_separator.output="&" diff --git a/ext/session/tests/021.phpt b/ext/session/tests/021.phpt index 1ad3c5d5f..e19997289 100644 --- a/ext/session/tests/021.phpt +++ b/ext/session/tests/021.phpt @@ -5,6 +5,7 @@ rewriter handles form and fieldset tags correctly --INI-- session.use_cookies=0 session.use_only_cookies=0 +session.use_strict_mode=0 session.cache_limiter= session.use_trans_sid=1 url_rewriter.tags="a=href,area=href,frame=src,input=src,form=,fieldset=" diff --git a/ext/session/tests/023.phpt b/ext/session/tests/023.phpt index 42b1e5b1b..592b4a8c3 100644 --- a/ext/session/tests/023.phpt +++ b/ext/session/tests/023.phpt @@ -4,6 +4,7 @@ session object deserialization <?php include('skipif.inc'); ?> --INI-- session.use_cookies=0 +session.use_strict_mode=0 session.cache_limiter= session.serialize_handler=php session.save_handler=files diff --git a/ext/session/tests/024.phpt b/ext/session/tests/024.phpt index 2ad26067a..2b273e2b2 100644 --- a/ext/session/tests/024.phpt +++ b/ext/session/tests/024.phpt @@ -4,6 +4,7 @@ session_set_save_handler test <?php include('skipif.inc'); ?> --INI-- session.use_cookies=0 +session.use_strict_mode=0 session.cache_limiter= session.name=PHPSESSID session.serialize_handler=php diff --git a/ext/session/tests/025.phpt b/ext/session/tests/025.phpt index 4fd095f81..a9ad8fb64 100644 --- a/ext/session/tests/025.phpt +++ b/ext/session/tests/025.phpt @@ -4,6 +4,7 @@ custom save handler, multiple session_start()s, complex data structure test. <?php include('skipif.inc'); ?> --INI-- session.use_cookies=0 +session.use_strict_mode=0 session.cache_limiter= session.name=PHPSESSID session.serialize_handler=php diff --git a/ext/session/tests/026.phpt b/ext/session/tests/026.phpt index 06c135d04..44f0ae0ec 100644 --- a/ext/session/tests/026.phpt +++ b/ext/session/tests/026.phpt @@ -4,6 +4,7 @@ correct instantiation of references between variables in sessions <?php include('skipif.inc'); ?> --INI-- session.use_cookies=0 +session.use_strict_mode=0 session.cache_limiter= session.serialize_handler=php session.save_handler=files diff --git a/ext/session/tests/027.phpt b/ext/session/tests/027.phpt index 600a992f7..63828522f 100644 --- a/ext/session/tests/027.phpt +++ b/ext/session/tests/027.phpt @@ -4,6 +4,7 @@ unset($_SESSION["name"]); should work <?php include('skipif.inc'); ?> --INI-- session.use_cookies=0 +session.use_strict_mode=0 session.cache_limiter= session.serialize_handler=php session.save_handler=files diff --git a/ext/session/tests/030.phpt b/ext/session/tests/030.phpt index 8d0f284b1..32909eb58 100644 --- a/ext/session/tests/030.phpt +++ b/ext/session/tests/030.phpt @@ -4,6 +4,7 @@ redefining SID should not cause warnings <?php include('skipif.inc'); ?> --INI-- session.use_cookies=0 +session.use_strict_mode=0 session.cache_limiter= session.serialize_handler=php session.save_handler=files diff --git a/ext/session/tests/bug41600.phpt b/ext/session/tests/bug41600.phpt index 690347ac8..79d5e1284 100644 --- a/ext/session/tests/bug41600.phpt +++ b/ext/session/tests/bug41600.phpt @@ -5,6 +5,7 @@ Bug #41600 (url rewriter tags doesn't work with namespaced tags) --INI-- session.use_cookies=0 session.use_only_cookies=0 +session.use_strict_mode=0 session.cache_limiter= session.use_trans_sid=1 arg_separator.output="&" diff --git a/ext/session/tests/bug60634.phpt b/ext/session/tests/bug60634.phpt index 2ec0c26c1..e2dfd15b3 100644 --- a/ext/session/tests/bug60634.phpt +++ b/ext/session/tests/bug60634.phpt @@ -1,7 +1,5 @@ --TEST-- Bug #60634 (Segmentation fault when trying to die() in SessionHandler::write()) ---XFAIL-- -Long term low priority bug, working on it --INI-- session.save_path= session.name=PHPSESSID @@ -44,3 +42,4 @@ echo "um, hi\n"; ?> --EXPECTF-- write: goodbye cruel world +close: goodbye cruel world diff --git a/ext/session/tests/bug60634_error_1.phpt b/ext/session/tests/bug60634_error_1.phpt index 3b6e394ee..e41592f18 100644 --- a/ext/session/tests/bug60634_error_1.phpt +++ b/ext/session/tests/bug60634_error_1.phpt @@ -1,7 +1,5 @@ --TEST-- Bug #60634 (Segmentation fault when trying to die() in SessionHandler::write()) - fatal error in write during exec ---XFAIL-- -Long term low priority bug, working on it --INI-- session.save_path= session.name=PHPSESSID @@ -47,3 +45,4 @@ echo "um, hi\n"; write: goodbye cruel world Fatal error: Call to undefined function undefined_function() in %s on line %d +close: goodbye cruel world diff --git a/ext/session/tests/bug60634_error_2.phpt b/ext/session/tests/bug60634_error_2.phpt index 265fb303f..7c50948ba 100644 --- a/ext/session/tests/bug60634_error_2.phpt +++ b/ext/session/tests/bug60634_error_2.phpt @@ -1,7 +1,5 @@ --TEST-- Bug #60634 (Segmentation fault when trying to die() in SessionHandler::write()) - exception in write during exec ---XFAIL-- -Long term low priority bug, working on it --INI-- session.save_path= session.name=PHPSESSID @@ -47,3 +45,8 @@ echo "um, hi\n"; write: goodbye cruel world Fatal error: Uncaught exception 'Exception' in %s +Stack trace: +#0 [internal function]: write('%s', '') +#1 %s(%d): session_write_close() +#2 {main} + thrown in %s on line %d diff --git a/ext/session/tests/bug60634_error_3.phpt b/ext/session/tests/bug60634_error_3.phpt index b2004d68b..4a508a4d8 100644 --- a/ext/session/tests/bug60634_error_3.phpt +++ b/ext/session/tests/bug60634_error_3.phpt @@ -1,7 +1,5 @@ --TEST-- Bug #60634 (Segmentation fault when trying to die() in SessionHandler::write()) - fatal error in write after exec ---XFAIL-- -Long term low priority bug, working on it --INI-- session.save_path= session.name=PHPSESSID @@ -46,3 +44,4 @@ session_start(); write: goodbye cruel world Fatal error: Call to undefined function undefined_function() in %s on line %d +close: goodbye cruel world diff --git a/ext/session/tests/bug60634_error_4.phpt b/ext/session/tests/bug60634_error_4.phpt index 60bc0dcf5..f21d077b5 100644 --- a/ext/session/tests/bug60634_error_4.phpt +++ b/ext/session/tests/bug60634_error_4.phpt @@ -1,7 +1,5 @@ --TEST-- Bug #60634 (Segmentation fault when trying to die() in SessionHandler::write()) - exception in write after exec ---XFAIL-- -Long term low priority bug, working on it --INI-- session.save_path= session.name=PHPSESSID @@ -46,3 +44,8 @@ session_start(); write: goodbye cruel world Fatal error: Uncaught exception 'Exception' in %s +Stack trace: +#0 [internal function]: write('%s', '') +#1 {main} + thrown in %s on line %d +close: goodbye cruel world diff --git a/ext/session/tests/rfc1867_sid_invalid.phpt b/ext/session/tests/rfc1867_sid_invalid.phpt index b28a2e341..4dd8f1f97 100644 --- a/ext/session/tests/rfc1867_sid_invalid.phpt +++ b/ext/session/tests/rfc1867_sid_invalid.phpt @@ -46,6 +46,16 @@ session_destroy(); ?> --EXPECTF-- Warning: Unknown: The session id is too long or contains illegal characters, valid characters are a-z, A-Z, 0-9 and '-,' in Unknown on line 0 + +Warning: Unknown: The session id is too long or contains illegal characters, valid characters are a-z, A-Z, 0-9 and '-,' in Unknown on line 0 + +Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct () in Unknown on line 0 + +Warning: Unknown: The session id is too long or contains illegal characters, valid characters are a-z, A-Z, 0-9 and '-,' in Unknown on line 0 + +Warning: Unknown: The session id is too long or contains illegal characters, valid characters are a-z, A-Z, 0-9 and '-,' in Unknown on line 0 + +Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct () in Unknown on line 0 string(%d) "%s" bool(true) array(2) { diff --git a/ext/session/tests/session_commit_variation4.phpt b/ext/session/tests/session_commit_variation4.phpt index 57f42539d..69854a6cf 100644 --- a/ext/session/tests/session_commit_variation4.phpt +++ b/ext/session/tests/session_commit_variation4.phpt @@ -2,6 +2,8 @@ Test session_commit() function : variation --SKIPIF-- <?php include('skipif.inc'); ?> +--INI-- +session.use_strict_mode=0 --FILE-- <?php diff --git a/ext/session/tests/session_save_path_variation2.phpt b/ext/session/tests/session_save_path_variation2.phpt index 6b0848031..dff070100 100644 --- a/ext/session/tests/session_save_path_variation2.phpt +++ b/ext/session/tests/session_save_path_variation2.phpt @@ -32,7 +32,7 @@ ob_end_flush(); *** Testing session_save_path() : variation *** string(5) "/blah" -Warning: session_start(): open(%s, O_RDWR) failed: No such file or directory (2) in %s on line %d +Warning: session_start(): open(/blah/%s, O_RDWR) failed: No such file or directory (2) in %s on line %d bool(true) string(5) "/blah" bool(true) diff --git a/ext/session/tests/session_save_path_variation5.phpt b/ext/session/tests/session_save_path_variation5.phpt index 5407b5e15..c015dcc95 100644 --- a/ext/session/tests/session_save_path_variation5.phpt +++ b/ext/session/tests/session_save_path_variation5.phpt @@ -9,7 +9,6 @@ if(substr(PHP_OS, 0, 3) == "WIN") session.save_handler=files session.save_path= session.name=PHPSESSID -open_basedir=. --FILE-- <?php @@ -25,7 +24,7 @@ $directory = dirname(__FILE__); $sessions = ($directory."/sessions"); chdir($directory); - +ini_set('open_basedir', '.'); // Delete the existing directory if (file_exists($sessions) === TRUE) { @rmdir($sessions); diff --git a/ext/session/tests/session_set_save_handler_error2.phpt b/ext/session/tests/session_set_save_handler_error2.phpt index 03ba3b04d..1f2a8b9e6 100644 --- a/ext/session/tests/session_set_save_handler_error2.phpt +++ b/ext/session/tests/session_set_save_handler_error2.phpt @@ -2,6 +2,8 @@ Test session_set_save_handler() function : error functionality --SKIPIF-- <?php include('skipif.inc'); ?> +--INI-- +error_reporting=0 --FILE-- <?php diff --git a/ext/session/tests/session_set_save_handler_error3.phpt b/ext/session/tests/session_set_save_handler_error3.phpt index 446ef7b75..cb07b0d8d 100644 --- a/ext/session/tests/session_set_save_handler_error3.phpt +++ b/ext/session/tests/session_set_save_handler_error3.phpt @@ -40,4 +40,3 @@ Stack trace: #1 %s(%d): session_start() #2 {main} thrown in %s on line %d - diff --git a/ext/session/tests/session_set_save_handler_error4.phpt b/ext/session/tests/session_set_save_handler_error4.phpt index 4debde5b0..d286f07d9 100644 --- a/ext/session/tests/session_set_save_handler_error4.phpt +++ b/ext/session/tests/session_set_save_handler_error4.phpt @@ -39,4 +39,3 @@ Warning: session_set_save_handler(): Argument 4 is not a valid callback in %s on Warning: session_set_save_handler(): Argument 5 is not a valid callback in %s on line %d Warning: session_set_save_handler(): Argument 6 is not a valid callback in %s on line %d - diff --git a/ext/session/tests/session_write_close_variation4.phpt b/ext/session/tests/session_write_close_variation4.phpt index 249c1555c..9076dcf4a 100644 --- a/ext/session/tests/session_write_close_variation4.phpt +++ b/ext/session/tests/session_write_close_variation4.phpt @@ -2,6 +2,8 @@ Test session_write_close() function : variation --SKIPIF-- <?php include('skipif.inc'); ?> +--INI-- +session.use_strict_mode=0 --FILE-- <?php diff --git a/ext/simplexml/config.m4 b/ext/simplexml/config.m4 index 2145e23d8..387a24ea2 100644 --- a/ext/simplexml/config.m4 +++ b/ext/simplexml/config.m4 @@ -6,7 +6,7 @@ PHP_ARG_ENABLE(simplexml, whether to enable SimpleXML support, if test -z "$PHP_LIBXML_DIR"; then PHP_ARG_WITH(libxml-dir, libxml2 install dir, - [ --with-libxml-dir=DIR SimpleXML: libxml2 install prefix], no, no) + [ --with-libxml-dir=DIR SimpleXML: libxml2 install prefix], no, no) fi if test "$PHP_SIMPLEXML" != "no"; then diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c index e7c2f2984..eba46b909 100644 --- a/ext/simplexml/simplexml.c +++ b/ext/simplexml/simplexml.c @@ -1070,7 +1070,7 @@ static HashTable * sxe_get_prop_hash(zval *object, int is_debug TSRMLS_DC) /* {{ int namelen; int test; char use_iter; - zval *iter_data; + zval *iter_data = NULL; use_iter = 0; diff --git a/ext/snmp/config.m4 b/ext/snmp/config.m4 index 9c0b82f77..dd7a3bf68 100644 --- a/ext/snmp/config.m4 +++ b/ext/snmp/config.m4 @@ -3,7 +3,7 @@ dnl $Id$ dnl PHP_ARG_WITH(snmp,for SNMP support, -[ --with-snmp[=DIR] Include SNMP support]) +[ --with-snmp[=DIR] Include SNMP support]) PHP_ARG_WITH(openssl-dir,OpenSSL dir for SNMP, [ --with-openssl-dir[=DIR] SNMP: openssl install prefix], no, no) diff --git a/ext/snmp/snmp.c b/ext/snmp/snmp.c index 186aeb5cd..4e2510afc 100644 --- a/ext/snmp/snmp.c +++ b/ext/snmp/snmp.c @@ -514,7 +514,7 @@ static zend_object_value php_snmp_object_new(zend_class_entry *class_type TSRMLS static void php_snmp_error(zval *object, const char *docref TSRMLS_DC, int type, const char *format, ...) { va_list args; - php_snmp_object *snmp_object; + php_snmp_object *snmp_object = NULL; if (object) { snmp_object = (php_snmp_object *)zend_object_store_get_object(object TSRMLS_CC); diff --git a/ext/soap/config.m4 b/ext/soap/config.m4 index 8acad8dee..7fa8c6f0e 100644 --- a/ext/soap/config.m4 +++ b/ext/soap/config.m4 @@ -6,7 +6,7 @@ PHP_ARG_ENABLE(soap, whether to enable SOAP support, if test -z "$PHP_LIBXML_DIR"; then PHP_ARG_WITH(libxml-dir, libxml2 install dir, - [ --with-libxml-dir=DIR SOAP: libxml2 install prefix], no, no) + [ --with-libxml-dir=DIR SOAP: libxml2 install prefix], no, no) fi if test "$PHP_SOAP" != "no"; then diff --git a/ext/soap/php_schema.c b/ext/soap/php_schema.c index 7d2e12974..25bb17727 100644 --- a/ext/soap/php_schema.c +++ b/ext/soap/php_schema.c @@ -1081,6 +1081,14 @@ static int schema_group(sdlPtr sdl, xmlAttrPtr tns, xmlNodePtr groupType, sdlTyp nsptr = xmlSearchNs(groupType->doc, groupType, BAD_CAST(ns)); if (nsptr != NULL) { smart_str_appends(&key, (char*)nsptr->href); + } else { + xmlAttrPtr ns = get_attribute(groupType->properties, "targetNamespace"); + if (ns == NULL) { + ns = tns; + } + if (ns) { + smart_str_appends(&key, (char*)ns->children->content); + } } smart_str_appendc(&key, ':'); smart_str_appends(&key, type); @@ -1509,6 +1517,14 @@ static int schema_element(sdlPtr sdl, xmlAttrPtr tns, xmlNodePtr element, sdlTyp if (nsptr != NULL) { smart_str_appends(&nscat, (char*)nsptr->href); newType->namens = estrdup((char*)nsptr->href); + } else { + xmlAttrPtr ns = get_attribute(attrs, "targetNamespace"); + if (ns == NULL) { + ns = tns; + } + if (ns) { + smart_str_appends(&nscat, (char*)ns->children->content); + } } smart_str_appendc(&nscat, ':'); smart_str_appends(&nscat, type); @@ -1735,6 +1751,14 @@ static int schema_attribute(sdlPtr sdl, xmlAttrPtr tns, xmlNodePtr attrType, sdl if (nsptr != NULL) { smart_str_appends(&key, (char*)nsptr->href); newAttr->namens = estrdup((char*)nsptr->href); + } else { + xmlAttrPtr ns = get_attribute(attrType->properties, "targetNamespace"); + if (ns == NULL) { + ns = tns; + } + if (ns) { + smart_str_appends(&key, (char*)ns->children->content); + } } smart_str_appendc(&key, ':'); smart_str_appends(&key, attr_name); @@ -2036,13 +2060,31 @@ static void copy_extra_attribute(void *attribute) } } +static void* schema_find_by_ref(HashTable *ht, char *ref) +{ + void **tmp; + + if (zend_hash_find(ht, ref, strlen(ref)+1, (void**)&tmp) == SUCCESS) { + return tmp; + } else { + ref = strrchr(ref, ':'); + if (ref) { + if (zend_hash_find(ht, ref, strlen(ref)+1, (void**)&tmp) == SUCCESS) { + return tmp; + } + } + } + return NULL; +} + static void schema_attribute_fixup(sdlCtx *ctx, sdlAttributePtr attr) { sdlAttributePtr *tmp; if (attr->ref != NULL) { if (ctx->attributes != NULL) { - if (zend_hash_find(ctx->attributes, attr->ref, strlen(attr->ref)+1, (void**)&tmp) == SUCCESS) { + tmp = (sdlAttributePtr*)schema_find_by_ref(ctx->attributes, attr->ref); + if (tmp) { schema_attribute_fixup(ctx, *tmp); if ((*tmp)->name != NULL && attr->name == NULL) { attr->name = estrdup((*tmp)->name); @@ -2092,7 +2134,8 @@ static void schema_attributegroup_fixup(sdlCtx *ctx, sdlAttributePtr attr, HashT if (attr->ref != NULL) { if (ctx->attributeGroups != NULL) { - if (zend_hash_find(ctx->attributeGroups, attr->ref, strlen(attr->ref)+1, (void**)&tmp) == SUCCESS) { + tmp = (sdlTypePtr*)schema_find_by_ref(ctx->attributeGroups, attr->ref); + if (tmp) { if ((*tmp)->attributes) { zend_hash_internal_pointer_reset((*tmp)->attributes); while (zend_hash_get_current_data((*tmp)->attributes,(void**)&tmp_attr) == SUCCESS) { @@ -2149,7 +2192,7 @@ static void schema_content_model_fixup(sdlCtx *ctx, sdlContentModelPtr model) model->kind = XSD_CONTENT_GROUP; model->u.group = (*tmp); } else { - soap_error0(E_ERROR, "Parsing Schema: unresolved group 'ref' attribute"); + soap_error1(E_ERROR, "Parsing Schema: unresolved group 'ref' attribute '%s'", model->u.group_ref); } break; } @@ -2193,7 +2236,8 @@ static void schema_type_fixup(sdlCtx *ctx, sdlTypePtr type) if (type->ref != NULL) { if (ctx->sdl->elements != NULL) { - if (zend_hash_find(ctx->sdl->elements, type->ref, strlen(type->ref)+1, (void**)&tmp) == SUCCESS) { + tmp = (sdlTypePtr*)schema_find_by_ref(ctx->sdl->elements, type->ref); + if (tmp) { type->kind = (*tmp)->kind; type->encode = (*tmp)->encode; if ((*tmp)->nillable) { @@ -2209,7 +2253,7 @@ static void schema_type_fixup(sdlCtx *ctx, sdlTypePtr type) } else if (strcmp(type->ref, SCHEMA_NAMESPACE ":schema") == 0) { type->encode = get_conversion(XSD_ANYXML); } else { - soap_error0(E_ERROR, "Parsing Schema: unresolved element 'ref' attribute"); + soap_error1(E_ERROR, "Parsing Schema: unresolved element 'ref' attribute '%s'", type->ref); } } efree(type->ref); diff --git a/ext/soap/soap.c b/ext/soap/soap.c index 88aec53f4..00e80efbc 100644 --- a/ext/soap/soap.c +++ b/ext/soap/soap.c @@ -3669,7 +3669,44 @@ ignore_header: return function; } -static int serialize_response_call2(xmlNodePtr body, sdlFunctionPtr function, char *function_name, char *uri, zval *ret, int version, int main TSRMLS_DC) +static void set_soap_header_attributes(xmlNodePtr h, HashTable *ht, int version) +{ + zval **tmp; + + if (zend_hash_find(ht, "mustUnderstand", sizeof("mustUnderstand"), (void**)&tmp) == SUCCESS && + Z_TYPE_PP(tmp) == IS_BOOL && Z_LVAL_PP(tmp)) { + if (version == SOAP_1_1) { + xmlSetProp(h, BAD_CAST(SOAP_1_1_ENV_NS_PREFIX":mustUnderstand"), BAD_CAST("1")); + } else { + xmlSetProp(h, BAD_CAST(SOAP_1_2_ENV_NS_PREFIX":mustUnderstand"), BAD_CAST("true")); + } + } + if (zend_hash_find(ht, "actor", sizeof("actor"), (void**)&tmp) == SUCCESS) { + if (Z_TYPE_PP(tmp) == IS_STRING) { + if (version == SOAP_1_1) { + xmlSetProp(h, BAD_CAST(SOAP_1_1_ENV_NS_PREFIX":actor"), BAD_CAST(Z_STRVAL_PP(tmp))); + } else { + xmlSetProp(h, BAD_CAST(SOAP_1_2_ENV_NS_PREFIX":role"), BAD_CAST(Z_STRVAL_PP(tmp))); + } + } else if (Z_TYPE_PP(tmp) == IS_LONG) { + if (version == SOAP_1_1) { + if (Z_LVAL_PP(tmp) == SOAP_ACTOR_NEXT) { + xmlSetProp(h, BAD_CAST(SOAP_1_1_ENV_NS_PREFIX":actor"), BAD_CAST(SOAP_1_1_ACTOR_NEXT)); + } + } else { + if (Z_LVAL_PP(tmp) == SOAP_ACTOR_NEXT) { + xmlSetProp(h, BAD_CAST(SOAP_1_2_ENV_NS_PREFIX":role"), BAD_CAST(SOAP_1_2_ACTOR_NEXT)); + } else if (Z_LVAL_PP(tmp) == SOAP_ACTOR_NONE) { + xmlSetProp(h, BAD_CAST(SOAP_1_2_ENV_NS_PREFIX":role"), BAD_CAST(SOAP_1_2_ACTOR_NONE)); + } else if (Z_LVAL_PP(tmp) == SOAP_ACTOR_UNLIMATERECEIVER) { + xmlSetProp(h, BAD_CAST(SOAP_1_2_ENV_NS_PREFIX":role"), BAD_CAST(SOAP_1_2_ACTOR_UNLIMATERECEIVER)); + } + } + } + } +} + +static int serialize_response_call2(xmlNodePtr body, sdlFunctionPtr function, char *function_name, char *uri, zval *ret, int version, int main, xmlNodePtr *node TSRMLS_DC) { xmlNodePtr method = NULL, param; sdlParamPtr parameter = NULL; @@ -3769,6 +3806,9 @@ static int serialize_response_call2(xmlNodePtr body, sdlFunctionPtr function, ch if (use == SOAP_ENCODED && version == SOAP_1_2 && method != NULL) { xmlSetNsProp(method, body->ns, BAD_CAST("encodingStyle"), BAD_CAST(SOAP_1_2_ENC_NAMESPACE)); } + if (node) { + *node = method; + } return use; } @@ -3850,7 +3890,7 @@ static xmlDocPtr serialize_response_call(sdlFunctionPtr function, char *function } if (headers->function) { - if (serialize_response_call2(head, headers->function, Z_STRVAL(headers->function_name), uri, hdr_ret, version, 0 TSRMLS_CC) == SOAP_ENCODED) { + if (serialize_response_call2(head, headers->function, Z_STRVAL(headers->function_name), uri, hdr_ret, version, 0, NULL TSRMLS_CC) == SOAP_ENCODED) { use = SOAP_ENCODED; } } else { @@ -4036,15 +4076,15 @@ static xmlDocPtr serialize_response_call(sdlFunctionPtr function, char *function zval *hdr_ret = &h->retval; char *hdr_ns = h->hdr?h->hdr->ns:NULL; char *hdr_name = Z_STRVAL(h->function_name); - + HashTable *ht = NULL; if (Z_TYPE(h->retval) == IS_OBJECT && instanceof_function(Z_OBJCE(h->retval), soap_header_class_entry TSRMLS_CC)) { - HashTable* ht = Z_OBJPROP(h->retval); zval **tmp; sdlSoapBindingFunctionHeaderPtr *hdr; smart_str key = {0}; + ht = Z_OBJPROP(h->retval); if (zend_hash_find(ht, "namespace", sizeof("namespace"), (void**)&tmp) == SUCCESS && Z_TYPE_PP(tmp) == IS_STRING) { smart_str_appendl(&key, Z_STRVAL_PP(tmp), Z_STRLEN_PP(tmp)); @@ -4075,9 +4115,14 @@ static xmlDocPtr serialize_response_call(sdlFunctionPtr function, char *function } if (h->function) { - if (serialize_response_call2(head, h->function, Z_STRVAL(h->function_name), uri, hdr_ret, version, 0 TSRMLS_CC) == SOAP_ENCODED) { + xmlNodePtr xmlHdr = NULL; + + if (serialize_response_call2(head, h->function, Z_STRVAL(h->function_name), uri, hdr_ret, version, 0, &xmlHdr TSRMLS_CC) == SOAP_ENCODED) { use = SOAP_ENCODED; } + if (ht) { + set_soap_header_attributes(xmlHdr, ht, version); + } } else { xmlNodePtr xmlHdr = master_to_xml(hdr_enc, hdr_ret, hdr_use, head TSRMLS_CC); if (hdr_name) { @@ -4087,6 +4132,9 @@ static xmlDocPtr serialize_response_call(sdlFunctionPtr function, char *function xmlNsPtr nsptr = encode_add_ns(xmlHdr,hdr_ns); xmlSetNs(xmlHdr, nsptr); } + if (ht) { + set_soap_header_attributes(xmlHdr, ht, version); + } } } h = h->next; @@ -4100,7 +4148,7 @@ static xmlDocPtr serialize_response_call(sdlFunctionPtr function, char *function body = xmlNewChild(envelope, ns, BAD_CAST("Body"), NULL); - if (serialize_response_call2(body, function, function_name, uri, ret, version, 1 TSRMLS_CC) == SOAP_ENCODED) { + if (serialize_response_call2(body, function, function_name, uri, ret, version, 1, NULL TSRMLS_CC) == SOAP_ENCODED) { use = SOAP_ENCODED; } @@ -4292,38 +4340,7 @@ static xmlDocPtr serialize_function_call(zval *this_ptr, sdlFunctionPtr function } nsptr = encode_add_ns(h, Z_STRVAL_PP(ns)); xmlSetNs(h, nsptr); - - if (zend_hash_find(ht, "mustUnderstand", sizeof("mustUnderstand"), (void**)&tmp) == SUCCESS && - Z_TYPE_PP(tmp) == IS_BOOL && Z_LVAL_PP(tmp)) { - if (version == SOAP_1_1) { - xmlSetProp(h, BAD_CAST(SOAP_1_1_ENV_NS_PREFIX":mustUnderstand"), BAD_CAST("1")); - } else { - xmlSetProp(h, BAD_CAST(SOAP_1_2_ENV_NS_PREFIX":mustUnderstand"), BAD_CAST("true")); - } - } - if (zend_hash_find(ht, "actor", sizeof("actor"), (void**)&tmp) == SUCCESS) { - if (Z_TYPE_PP(tmp) == IS_STRING) { - if (version == SOAP_1_1) { - xmlSetProp(h, BAD_CAST(SOAP_1_1_ENV_NS_PREFIX":actor"), BAD_CAST(Z_STRVAL_PP(tmp))); - } else { - xmlSetProp(h, BAD_CAST(SOAP_1_2_ENV_NS_PREFIX":role"), BAD_CAST(Z_STRVAL_PP(tmp))); - } - } else if (Z_TYPE_PP(tmp) == IS_LONG) { - if (version == SOAP_1_1) { - if (Z_LVAL_PP(tmp) == SOAP_ACTOR_NEXT) { - xmlSetProp(h, BAD_CAST(SOAP_1_1_ENV_NS_PREFIX":actor"), BAD_CAST(SOAP_1_1_ACTOR_NEXT)); - } - } else { - if (Z_LVAL_PP(tmp) == SOAP_ACTOR_NEXT) { - xmlSetProp(h, BAD_CAST(SOAP_1_2_ENV_NS_PREFIX":role"), BAD_CAST(SOAP_1_2_ACTOR_NEXT)); - } else if (Z_LVAL_PP(tmp) == SOAP_ACTOR_NONE) { - xmlSetProp(h, BAD_CAST(SOAP_1_2_ENV_NS_PREFIX":role"), BAD_CAST(SOAP_1_2_ACTOR_NONE)); - } else if (Z_LVAL_PP(tmp) == SOAP_ACTOR_UNLIMATERECEIVER) { - xmlSetProp(h, BAD_CAST(SOAP_1_2_ENV_NS_PREFIX":role"), BAD_CAST(SOAP_1_2_ACTOR_UNLIMATERECEIVER)); - } - } - } - } + set_soap_header_attributes(h, ht, version); } zend_hash_move_forward(soap_headers); } diff --git a/ext/soap/tests/bugs/bug28985.phpt b/ext/soap/tests/bugs/bug28985.phpt index 5134cbf09..73ff899c3 100644 --- a/ext/soap/tests/bugs/bug28985.phpt +++ b/ext/soap/tests/bugs/bug28985.phpt @@ -44,7 +44,7 @@ array(42) { string iUserPassword; }" [8]=> - string(86) "struct MGCodeLibelle { + string(87) "struct MGCodeLibelle { string Code; string Libelle; boolean Default; @@ -203,4 +203,4 @@ array(42) { string(76) "struct GetEnvironnementResponse { MGEnvironnement GetEnvironnementResult; }" -}
\ No newline at end of file +} diff --git a/ext/soap/tests/bugs/bug65018.phpt b/ext/soap/tests/bugs/bug65018.phpt new file mode 100644 index 000000000..bbb9b5e42 --- /dev/null +++ b/ext/soap/tests/bugs/bug65018.phpt @@ -0,0 +1,28 @@ +--TEST-- +Bug #65018 (SoapHeader problems with SoapServer) +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php + class Tool{ + public function TOKEN($id){ + return new SoapHeader('namespace1', 'TOKEN', $id, true); + } + public function Method(){} + } + + $input = $input = + '<?xml version="1.0"?>'.PHP_EOL. + '<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="namespace1"'. + ' xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'. + ' xmlns:xsd="http://www.w3.org/2001/XMLSchema">'. + '<SOAP-ENV:Header><ns1:TOKEN soapenv:mustUnderstand="1">abc</ns1:TOKEN></SOAP-ENV:Header>'. + '<SOAP-ENV:Body><ns1:Method /></SOAP-ENV:Body></SOAP-ENV:Envelope>'; + + $soap = new SoapServer(null, array('uri' => '127.0.0.1')); + $soap->setClass('Tool'); + $soap->handle($input); +?> +--EXPECT-- +<?xml version="1.0" encoding="UTF-8"?> +<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="namespace1" xmlns:ns2="127.0.0.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Header><ns1:TOKEN SOAP-ENV:mustUnderstand="1">abc</ns1:TOKEN></SOAP-ENV:Header><SOAP-ENV:Body><ns2:MethodResponse><return xsi:nil="true"/></ns2:MethodResponse></SOAP-ENV:Body></SOAP-ENV:Envelope> diff --git a/ext/spl/internal/splobjectstorage.inc b/ext/spl/internal/splobjectstorage.inc index fa164066c..ffc6c9948 100644 --- a/ext/spl/internal/splobjectstorage.inc +++ b/ext/spl/internal/splobjectstorage.inc @@ -16,7 +16,7 @@ * @since PHP 5.1.2 * * This container allows to store objects uniquly without the need to compare - * them one by one. This is only possible internally. The code represenation + * them one by one. This is only possible internally. The code representation * here therefore has a complexity of O(n) while the actual implementation has * complexity O(1). */ diff --git a/ext/spl/php_spl.c b/ext/spl/php_spl.c index 35f4e5056..716990d80 100644 --- a/ext/spl/php_spl.c +++ b/ext/spl/php_spl.c @@ -743,8 +743,17 @@ PHP_FUNCTION(spl_autoload_functions) } add_next_index_string(tmp, alfi->func_ptr->common.function_name, 1); add_next_index_zval(return_value, tmp); - } else - add_next_index_string(return_value, alfi->func_ptr->common.function_name, 1); + } else { + if (strncmp(alfi->func_ptr->common.function_name, "__lambda_func", sizeof("__lambda_func") - 1)) { + add_next_index_string(return_value, alfi->func_ptr->common.function_name, 1); + } else { + char *key; + uint len; + long dummy; + zend_hash_get_current_key_ex(SPL_G(autoload_functions), &key, &len, &dummy, 0, &function_pos); + add_next_index_stringl(return_value, key, len - 1, 1); + } + } zend_hash_move_forward_ex(SPL_G(autoload_functions), &function_pos); } @@ -791,7 +800,7 @@ PHPAPI void php_spl_object_hash(zval *obj, char *result TSRMLS_DC) /* {{{*/ hash_handle = SPL_G(hash_mask_handle)^(intptr_t)Z_OBJ_HANDLE_P(obj); hash_handlers = SPL_G(hash_mask_handlers)^(intptr_t)Z_OBJ_HT_P(obj); - spprintf(&hex, 32, "%016x%016x", hash_handle, hash_handlers); + spprintf(&hex, 32, "%016lx%016lx", hash_handle, hash_handlers); strlcpy(result, hex, 33); efree(hex); diff --git a/ext/spl/spl.php b/ext/spl/spl.php index fdffda368..3638a5a2b 100755 --- a/ext/spl/spl.php +++ b/ext/spl/spl.php @@ -260,7 +260,7 @@ class Exception /** The exception message */ protected $message; - /** The string represenations as generated during construction */ + /** The string representations as generated during construction */ private $string; /** The code passed to the constructor */ @@ -336,7 +336,7 @@ class Exception { } - /** @return string represenation of exception + /** @return string representation of exception */ public function __toString() { diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c index ed13b8e57..ca8076a95 100644 --- a/ext/spl/spl_array.c +++ b/ext/spl/spl_array.c @@ -166,7 +166,7 @@ zend_object_iterator *spl_array_get_iterator(zend_class_entry *ce, zval *object, /* {{{ spl_array_object_new_ex */ static zend_object_value spl_array_object_new_ex(zend_class_entry *class_type, spl_array_object **obj, zval *orig, int clone_orig TSRMLS_DC) { - zend_object_value retval; + zend_object_value retval = {0}; spl_array_object *intern; zval *tmp; zend_class_entry * parent = class_type; @@ -1646,7 +1646,7 @@ SPL_METHOD(Array, getChildren) return; } if (instanceof_function(Z_OBJCE_PP(entry), Z_OBJCE_P(getThis()) TSRMLS_CC)) { - RETURN_ZVAL(*entry, 0, 0); + RETURN_ZVAL(*entry, 1, 0); } } diff --git a/ext/spl/spl_dllist.c b/ext/spl/spl_dllist.c index aa462dfd7..273bc7506 100644 --- a/ext/spl/spl_dllist.c +++ b/ext/spl/spl_dllist.c @@ -368,7 +368,7 @@ zend_object_iterator *spl_dllist_get_iterator(zend_class_entry *ce, zval *object static zend_object_value spl_dllist_object_new_ex(zend_class_entry *class_type, spl_dllist_object **obj, zval *orig, int clone_orig TSRMLS_DC) /* {{{ */ { - zend_object_value retval; + zend_object_value retval = {0}; spl_dllist_object *intern; zend_class_entry *parent = class_type; int inherited = 0; diff --git a/ext/spl/spl_iterators.c b/ext/spl/spl_iterators.c index 25b8b4c12..30532756c 100644 --- a/ext/spl/spl_iterators.c +++ b/ext/spl/spl_iterators.c @@ -117,6 +117,7 @@ typedef struct _spl_recursive_it_object { zend_function *nextElement; zend_class_entry *ce; smart_str prefix[6]; + smart_str postfix[1]; } spl_recursive_it_object; typedef struct _spl_recursive_it_iterator { @@ -886,6 +887,8 @@ static void spl_RecursiveIteratorIterator_free_storage(void *_object TSRMLS_DC) smart_str_free(&object->prefix[4]); smart_str_free(&object->prefix[5]); + smart_str_free(&object->postfix[0]); + efree(object); } /* }}} */ @@ -906,6 +909,8 @@ static zend_object_value spl_RecursiveIteratorIterator_new_ex(zend_class_entry * smart_str_appendl(&intern->prefix[3], "|-", 2); smart_str_appendl(&intern->prefix[4], "\\-", 2); smart_str_appendl(&intern->prefix[5], "", 0); + + smart_str_appendl(&intern->postfix[0], "", 0); } zend_object_std_init(&intern->std, class_type TSRMLS_CC); @@ -1025,7 +1030,7 @@ static void spl_recursive_tree_iterator_get_entry(spl_recursive_it_object * obje static void spl_recursive_tree_iterator_get_postfix(spl_recursive_it_object * object, zval * return_value TSRMLS_DC) { - RETVAL_STRINGL("", 0, 1); + RETVAL_STRINGL(object->postfix[0].c, object->postfix[0].len, 1); } /* {{{ proto void RecursiveTreeIterator::__construct(RecursiveIterator|IteratorAggregate it [, int flags = RTIT_BYPASS_KEY [, int cit_flags = CIT_CATCH_GET_CHILD [, mode = RIT_SELF_FIRST ]]]) throws InvalidArgumentException @@ -1068,6 +1073,22 @@ SPL_METHOD(RecursiveTreeIterator, getPrefix) spl_recursive_tree_iterator_get_prefix(object, return_value TSRMLS_CC); } /* }}} */ +/* {{{ proto void RecursiveTreeIterator::setPostfix(string prefix) + Sets postfix as used in getPostfix() */ +SPL_METHOD(RecursiveTreeIterator, setPostfix) +{ + spl_recursive_it_object *object = (spl_recursive_it_object*)zend_object_store_get_object(getThis() TSRMLS_CC); + char* postfix; + int postfix_len; + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &postfix, &postfix_len) == FAILURE) { + return; + } + + smart_str_free(&object->postfix[0]); + smart_str_appendl(&object->postfix[0], postfix, postfix_len); +} /* }}} */ + /* {{{ proto string RecursiveTreeIterator::getEntry() Returns the string presentation built for current element */ SPL_METHOD(RecursiveTreeIterator, getEntry) @@ -1235,6 +1256,7 @@ static const zend_function_entry spl_funcs_RecursiveTreeIterator[] = { SPL_ME(RecursiveTreeIterator, getPrefix, arginfo_recursive_it_void, ZEND_ACC_PUBLIC) SPL_ME(RecursiveTreeIterator, setPrefixPart, arginfo_recursive_tree_it_setPrefixPart, ZEND_ACC_PUBLIC) SPL_ME(RecursiveTreeIterator, getEntry, arginfo_recursive_it_void, ZEND_ACC_PUBLIC) + SPL_ME(RecursiveTreeIterator, setPostfix, arginfo_recursive_it_void, ZEND_ACC_PUBLIC) SPL_ME(RecursiveTreeIterator, getPostfix, arginfo_recursive_it_void, ZEND_ACC_PUBLIC) PHP_FE_END }; diff --git a/ext/spl/tests/bug61697.phpt b/ext/spl/tests/bug61697.phpt index d95caef97..064aaa2e2 100644 --- a/ext/spl/tests/bug61697.phpt +++ b/ext/spl/tests/bug61697.phpt @@ -1,7 +1,5 @@ --TEST-- Bug #61697 (spl_autoload_functions returns lambda functions incorrectly) ---XFAIL-- -Bug #61697 not fixed yet --FILE-- <?php diff --git a/ext/spl/tests/bug63680.phpt b/ext/spl/tests/bug63680.phpt index 3a20c4bb1..0b5c35dc7 100644 --- a/ext/spl/tests/bug63680.phpt +++ b/ext/spl/tests/bug63680.phpt @@ -1,5 +1,7 @@ --TEST-- Bug #63680 (Memleak in splfixedarray with cycle reference) +--INI-- +zend.enable_gc=1 --FILE-- <?php function dummy() { diff --git a/ext/spl/tests/bug65328.phpt b/ext/spl/tests/bug65328.phpt new file mode 100644 index 000000000..32e6c24fa --- /dev/null +++ b/ext/spl/tests/bug65328.phpt @@ -0,0 +1,348 @@ +--TEST-- +Bug #65328 (Segfault when getting SplStack object Value) +--FILE-- +<?php +/** + * @author AlexanderC + */ + +class Tree +{ + /** + * @var Node + */ + protected $head; + + /** + * @param Node $head + */ + public function __construct(Node $head = null) + { + $this->head = $head ? : new Node('HEAD'); + } + + /** + * @return Node + */ + public function getHead() + { + return $this->head; + } + + /** + * @param mixed $uid + * @return Node|bool + */ + public function find($uid) + { + $iterator = $this->getIterator(); + + /** @var Node $node */ + foreach($iterator as $node) { + if($node->getUid() === $uid) { + return $node; + } + } + + return false; + } + + /** + * @param mixed $uid + * @return \SplStack + */ + public function & findAll($uid) + { + $result = new \SplStack(); + + /** @var Node $node */ + foreach($this->getIterator() as $node) { + if($node->getUid() == $uid) { + $result->push($node); + } + } + + return $result; + } + + /** + * @return \RecursiveIteratorIterator + */ + public function getIterator() + { + return new \RecursiveIteratorIterator( + $this->head->getChildren(), + \RecursiveIteratorIterator::SELF_FIRST + ); + } +} + +class Node extends \RecursiveArrayIterator implements \Countable +{ + /** + * @var array + */ + protected $children = []; + + /** + * @var Node + */ + protected $parent; + + /** + * @var mixed + */ + protected $data; + + /** + * @var mixed + */ + protected $uid; + + /** + * @var int + */ + protected $index = 0; + + /** + * @var bool + */ + protected $assureUnique; + + /** + * @param mixed $data + * @param mixed $uid + * @param Node $parent + * @param bool $assureUnique + */ + public function __construct($data, $uid = null, Node $parent = null, $assureUnique = false) + { + if(null !== $parent) { + $this->parent = $parent; + } + + $this->data = $data; + $this->uid = $uid ? : uniqid(sha1(serialize($data)), true); + $this->assureUnique = $assureUnique; + } + + /** + * @param mixed $uid + */ + public function setUid($uid) + { + $this->uid = $uid; + } + + /** + * @return mixed + */ + public function getUid() + { + return $this->uid; + } + + /** + * @param Node $child + */ + public function addChild(Node $child) + { + $child->setParent($this); + $this->children[] = $child; + } + + /** + * @param array $children + */ + public function setChildren(array $children) + { + $this->children = $children; + } + + /** + * @return array + */ + public function getChildrenArray() + { + return $this->children; + } + + /** + * @param mixed $data + */ + public function setData($data) + { + $this->data = $data; + } + + /** + * @return mixed + */ + public function getData() + { + return $this->data; + } + + /** + * @param Node $parent + * @throws \RuntimeException + */ + public function setParent(Node $parent) + { + if(true === $this->assureUnique && !self::checkUnique($parent, $this->uid)) { + throw new \RuntimeException("Node uid is not unique in assigned node tree"); + } + + $this->parent = $parent; + } + + /** + * @param Node $node + * @param mixed $uid + * @return bool + */ + protected static function checkUnique(Node $node, $uid) + { + $headNode = $node; + do { + $headNode = $node; + } while($node = $node->getParent()); + + $tree = new Tree($headNode); + + return !$tree->find($uid); + } + + /** + * @return \IJsonRPC\Helpers\Tree\Node + */ + public function getParent() + { + return $this->parent; + } + + /** + * @return Node + */ + public function current() + { + return $this->children[$this->index]; + } + + /** + * @return scalar + */ + public function key() + { + return $this->index; + } + + /** + * @return void + */ + public function next() + { + ++$this->index; + } + + /** + * @return void + */ + public function rewind() + { + $this->index = 0; + } + + /** + * @return bool + */ + public function valid() + { + return array_key_exists($this->index, $this->children); + } + + /** + * @return int + */ + public function count() + { + return count($this->children); + } + + /** + * @return bool + */ + public function hasChildren() + { + return !empty($this->children); + } + + /** + * @return \RecursiveArrayIterator + */ + public function getChildren() + { + return new \RecursiveArrayIterator($this->children); + } +} + +$tree = new Tree(); +$node1 = new Node('value1', 1); +$tree->getHead()->addChild($node1); +$node2 = new Node('value2', 2); +$node1->addChild($node2); + +print_r($tree->findAll(2)->offsetGet(0)); +--EXPECTF-- +Node Object +( + [children:protected] => Array + ( + ) + + [parent:protected] => Node Object + ( + [children:protected] => Array + ( + [0] => Node Object + *RECURSION* + ) + + [parent:protected] => Node Object + ( + [children:protected] => Array + ( + [0] => Node Object + *RECURSION* + ) + + [parent:protected] => + [data:protected] => HEAD + [uid:protected] => %s + [index:protected] => 0 + [assureUnique:protected] => + [storage:ArrayIterator:private] => Array + ( + ) + + ) + + [data:protected] => value1 + [uid:protected] => 1 + [index:protected] => 1 + [assureUnique:protected] => + [storage:ArrayIterator:private] => Array + ( + ) + + ) + + [data:protected] => value2 + [uid:protected] => 2 + [index:protected] => 0 + [assureUnique:protected] => + [storage:ArrayIterator:private] => Array + ( + ) + +) diff --git a/ext/spl/tests/recursive_tree_iterator_setpostfix.phpt b/ext/spl/tests/recursive_tree_iterator_setpostfix.phpt new file mode 100644 index 000000000..d59e278fd --- /dev/null +++ b/ext/spl/tests/recursive_tree_iterator_setpostfix.phpt @@ -0,0 +1,88 @@ +--TEST-- +SPL: RecursiveTreeIterator::setPostfix() +--CREDITS-- +Joshua Thijssen (jthijssen@noxlogic.nl) +--FILE-- +<?php + +$arr = array( + 0 => array( + "a", + 1, + ), + "a" => array( + 2, + "b", + 3 => array( + 4, + "c", + ), + "3" => array( + 4, + "c", + ), + ), +); + +$it = new RecursiveArrayIterator($arr); +$it = new RecursiveTreeIterator($it); + +echo "----\n"; +echo $it->getPostfix(); +echo "\n\n"; + +echo "----\n"; +$it->setPostfix("POSTFIX"); +echo $it->getPostfix(); +echo "\n\n"; + +echo "----\n"; +foreach($it as $k => $v) { + echo "[$k] => $v\n"; +} + +echo "----\n"; +$it->setPostfix(""); +echo $it->getPostfix(); +echo "\n\n"; + +echo "----\n"; +foreach($it as $k => $v) { + echo "[$k] => $v\n"; +} + + + +?> +===DONE=== +--EXPECTF-- +---- + + +---- +POSTFIX + +---- +[0] => |-ArrayPOSTFIX +[0] => | |-aPOSTFIX +[1] => | \-1POSTFIX +[a] => \-ArrayPOSTFIX +[0] => |-2POSTFIX +[1] => |-bPOSTFIX +[3] => \-ArrayPOSTFIX +[0] => |-4POSTFIX +[1] => \-cPOSTFIX +---- + + +---- +[0] => |-Array +[0] => | |-a +[1] => | \-1 +[a] => \-Array +[0] => |-2 +[1] => |-b +[3] => \-Array +[0] => |-4 +[1] => \-c +===DONE=== diff --git a/ext/spl/tests/spl_priorityqeue_insert_two_params_error.phpt b/ext/spl/tests/spl_priorityqeue_insert_two_params_error.phpt index 659ffb4bc..076c68771 100644 --- a/ext/spl/tests/spl_priorityqeue_insert_two_params_error.phpt +++ b/ext/spl/tests/spl_priorityqeue_insert_two_params_error.phpt @@ -1,5 +1,5 @@ --TEST-- -SPL: priorityQueue paramter test on insert method +SPL: priorityQueue parameter test on insert method --CREDITS-- Sean Burlington www.practicalweb.co.uk TestFest London May 2009 diff --git a/ext/sqlite3/config0.m4 b/ext/sqlite3/config0.m4 index 1365def03..6959a6f91 100644 --- a/ext/sqlite3/config0.m4 +++ b/ext/sqlite3/config0.m4 @@ -3,7 +3,7 @@ dnl config.m4 for extension sqlite3 dnl vim:et:ts=2:sw=2 PHP_ARG_WITH(sqlite3, whether to enable the SQLite3 extension, -[ --without-sqlite3[=DIR] Do not include SQLite3 support. DIR is the prefix to +[ --without-sqlite3[=DIR] Do not include SQLite3 support. DIR is the prefix to SQLite3 installation directory.], yes) if test $PHP_SQLITE3 != "no"; then diff --git a/ext/sqlite3/libsqlite/sqlite3.c b/ext/sqlite3/libsqlite/sqlite3.c index ccd12771e..6d013b675 100644 --- a/ext/sqlite3/libsqlite/sqlite3.c +++ b/ext/sqlite3/libsqlite/sqlite3.c @@ -12731,7 +12731,7 @@ struct VdbeFunc { */ struct sqlite3_context { FuncDef *pFunc; /* Pointer to function information. MUST BE FIRST */ - VdbeFunc *pVdbeFunc; /* Auxilary data, if created. */ + VdbeFunc *pVdbeFunc; /* Auxiliary data, if created. */ Mem s; /* The return value is stored here */ Mem *pMem; /* Memory cell used to store aggregate context */ int isError; /* Error code returned by the function. */ @@ -44929,7 +44929,7 @@ SQLITE_PRIVATE int sqlite3WalOpen( } /* -** Change the size to which the WAL file is trucated on each reset. +** Change the size to which the WAL file is truncated on each reset. */ SQLITE_PRIVATE void sqlite3WalLimit(Wal *pWal, i64 iLimit){ if( pWal ) pWal->mxWalSize = iLimit; @@ -59355,7 +59355,7 @@ static int vdbeCommit(sqlite3 *db, Vdbe *p){ /* The complex case - There is a multi-file write-transaction active. ** This requires a master journal file to ensure the transaction is - ** committed atomicly. + ** committed atomically. */ #ifndef SQLITE_OMIT_DISKIO else{ @@ -61383,7 +61383,7 @@ SQLITE_API void *sqlite3_aggregate_context(sqlite3_context *p, int nByte){ } /* -** Return the auxilary data pointer, if any, for the iArg'th argument to +** Return the auxiliary data pointer, if any, for the iArg'th argument to ** the user-function defined by pCtx. */ SQLITE_API void *sqlite3_get_auxdata(sqlite3_context *pCtx, int iArg){ @@ -61398,7 +61398,7 @@ SQLITE_API void *sqlite3_get_auxdata(sqlite3_context *pCtx, int iArg){ } /* -** Set the auxilary data pointer and delete function, for the iArg'th +** Set the auxiliary data pointer and delete function, for the iArg'th ** argument to the user-function defined by pCtx. Any previous value is ** deleted by calling the delete function specified when it was set. */ @@ -63408,7 +63408,7 @@ SQLITE_PRIVATE int sqlite3VdbeExec( } #endif - /* On any opcode with the "out2-prerelase" tag, free any + /* On any opcode with the "out2-prerelease" tag, free any ** external allocations out of mem[p2] and set mem[p2] to be ** an undefined integer. Opcodes will either fill in the integer ** value or convert mem[p2] to a different type. diff --git a/ext/standard/array.c b/ext/standard/array.c index 4f5209e2f..51972033e 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -3030,8 +3030,8 @@ static void php_array_intersect(INTERNAL_FUNCTION_PARAMETERS, int behavior, int char *param_spec; zend_fcall_info fci1, fci2; zend_fcall_info_cache fci1_cache = empty_fcall_info_cache, fci2_cache = empty_fcall_info_cache; - zend_fcall_info *fci_key, *fci_data; - zend_fcall_info_cache *fci_key_cache, *fci_data_cache; + zend_fcall_info *fci_key = NULL, *fci_data; + zend_fcall_info_cache *fci_key_cache = NULL, *fci_data_cache; PHP_ARRAY_CMP_FUNC_VARS; int (*intersect_key_compare_func)(const void *, const void * TSRMLS_DC); @@ -3448,8 +3448,8 @@ static void php_array_diff(INTERNAL_FUNCTION_PARAMETERS, int behavior, int data_ char *param_spec; zend_fcall_info fci1, fci2; zend_fcall_info_cache fci1_cache = empty_fcall_info_cache, fci2_cache = empty_fcall_info_cache; - zend_fcall_info *fci_key, *fci_data; - zend_fcall_info_cache *fci_key_cache, *fci_data_cache; + zend_fcall_info *fci_key = NULL, *fci_data; + zend_fcall_info_cache *fci_key_cache = NULL, *fci_data_cache; PHP_ARRAY_CMP_FUNC_VARS; int (*diff_key_compare_func)(const void *, const void * TSRMLS_DC); @@ -4017,7 +4017,7 @@ PHP_FUNCTION(array_rand) /* We can't use zend_hash_index_find() because the array may have string keys or gaps. */ zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(input), &pos); - while (num_req && (key_type = zend_hash_get_current_key_ex(Z_ARRVAL_P(input), &string_key, &string_key_len, &num_key, 0, &pos)) != HASH_KEY_NON_EXISTANT) { + while (num_req && (key_type = zend_hash_get_current_key_ex(Z_ARRVAL_P(input), &string_key, &string_key_len, &num_key, 0, &pos)) != HASH_KEY_NON_EXISTENT) { randval = php_rand(TSRMLS_C); @@ -4053,7 +4053,6 @@ PHP_FUNCTION(array_sum) **entry, entry_n; HashPosition pos; - double dval; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a", &input) == FAILURE) { return; @@ -4071,17 +4070,7 @@ PHP_FUNCTION(array_sum) entry_n = **entry; zval_copy_ctor(&entry_n); convert_scalar_to_number(&entry_n TSRMLS_CC); - - if (Z_TYPE(entry_n) == IS_LONG && Z_TYPE_P(return_value) == IS_LONG) { - dval = (double)Z_LVAL_P(return_value) + (double)Z_LVAL(entry_n); - if ( (double)LONG_MIN <= dval && dval <= (double)LONG_MAX ) { - Z_LVAL_P(return_value) += Z_LVAL(entry_n); - continue; - } - } - convert_to_double(return_value); - convert_to_double(&entry_n); - Z_DVAL_P(return_value) += Z_DVAL(entry_n); + fast_add_function(return_value, return_value, &entry_n TSRMLS_CC); } } /* }}} */ diff --git a/ext/standard/html.c b/ext/standard/html.c index 414fa65c9..b4d9ba109 100644 --- a/ext/standard/html.c +++ b/ext/standard/html.c @@ -1221,8 +1221,8 @@ PHPAPI char *php_escape_html_entities_ex(unsigned char *old, size_t oldlen, size const enc_to_uni *to_uni_table = NULL; const entity_ht *inv_map = NULL; /* used for !double_encode */ /* only used if flags includes ENT_HTML_IGNORE_ERRORS or ENT_HTML_SUBSTITUTE_DISALLOWED_CHARS */ - const unsigned char *replacement; - size_t replacement_len; + const unsigned char *replacement = NULL; + size_t replacement_len = 0; if (all) { /* replace with all named entities */ if (CHARSET_PARTIAL_SUPPORT(charset)) { @@ -1596,7 +1596,7 @@ PHP_FUNCTION(get_html_translation_table) flags = ENT_COMPAT; int doctype; entity_table_opt entity_table; - const enc_to_uni *to_uni_table; + const enc_to_uni *to_uni_table = NULL; char *charset_hint = NULL; int charset_hint_len; enum entity_charset charset; diff --git a/ext/standard/http.c b/ext/standard/http.c index 547df5218..f9b802195 100644 --- a/ext/standard/http.c +++ b/ext/standard/http.c @@ -56,7 +56,7 @@ PHPAPI int php_url_encode_hash_ex(HashTable *ht, smart_str *formstr, arg_sep_len = strlen(arg_sep); for (zend_hash_internal_pointer_reset(ht); - (key_type = zend_hash_get_current_key_ex(ht, &key, &key_len, &idx, 0, NULL)) != HASH_KEY_NON_EXISTANT; + (key_type = zend_hash_get_current_key_ex(ht, &key, &key_len, &idx, 0, NULL)) != HASH_KEY_NON_EXISTENT; zend_hash_move_forward(ht) ) { if (key_type == HASH_KEY_IS_STRING && key_len && key[key_len-1] == '\0') { diff --git a/ext/standard/pack.c b/ext/standard/pack.c index 6e9489318..3f525a793 100644 --- a/ext/standard/pack.c +++ b/ext/standard/pack.c @@ -514,7 +514,7 @@ static long php_unpack(char *data, int size, int issigned, int *map) /* unpack() is based on Perl's unpack(), but is modified a bit from there. * Rather than depending on error-prone ordered lists or syntactically - * unpleasant pass-by-reference, we return an object with named paramters + * unpleasant pass-by-reference, we return an object with named parameters * (like *_fetch_object()). Syntax is "f[repeat]name/...", where "f" is the * formatter char (like pack()), "[repeat]" is the optional repeater argument, * and "name" is the name of the variable to use. diff --git a/ext/standard/proc_open.c b/ext/standard/proc_open.c index 4e39a40be..d78ca9976 100644 --- a/ext/standard/proc_open.c +++ b/ext/standard/proc_open.c @@ -172,7 +172,7 @@ static php_process_env_t _php_array_to_envp(zval *environment, int is_persistent #endif p += el_len + 1; break; - case HASH_KEY_NON_EXISTANT: + case HASH_KEY_NON_EXISTENT: break; } } diff --git a/ext/standard/streamsfuncs.c b/ext/standard/streamsfuncs.c index f487763b9..0610ecfc4 100644 --- a/ext/standard/streamsfuncs.c +++ b/ext/standard/streamsfuncs.c @@ -583,7 +583,7 @@ PHP_FUNCTION(stream_get_wrappers) HashPosition pos; array_init(return_value); for (zend_hash_internal_pointer_reset_ex(url_stream_wrappers_hash, &pos); - (key_flags = zend_hash_get_current_key_ex(url_stream_wrappers_hash, &stream_protocol, &stream_protocol_len, &num_key, 0, &pos)) != HASH_KEY_NON_EXISTANT; + (key_flags = zend_hash_get_current_key_ex(url_stream_wrappers_hash, &stream_protocol, &stream_protocol_len, &num_key, 0, &pos)) != HASH_KEY_NON_EXISTENT; zend_hash_move_forward_ex(url_stream_wrappers_hash, &pos)) { if (key_flags == HASH_KEY_IS_STRING) { add_next_index_stringl(return_value, stream_protocol, stream_protocol_len - 1, 1); @@ -668,7 +668,7 @@ static int stream_array_from_fd_set(zval *stream_array, fd_set *fds TSRMLS_DC) type = zend_hash_get_current_key_ex(Z_ARRVAL_P(stream_array), &key, &key_len, &num_ind, 0, NULL); - if (type == HASH_KEY_NON_EXISTANT || + if (type == HASH_KEY_NON_EXISTENT || zend_hash_get_current_data(Z_ARRVAL_P(stream_array), (void **) &elem) == FAILURE) { continue; /* should not happen */ } diff --git a/ext/standard/string.c b/ext/standard/string.c index 6a67efbd7..b9d7427eb 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -3204,7 +3204,7 @@ static void php_similar_str(const char *txt1, int len1, const char *txt2, int le static int php_similar_char(const char *txt1, int len1, const char *txt2, int len2) { int sum; - int pos1, pos2, max; + int pos1 = 0, pos2 = 0, max; php_similar_str(txt1, len1, txt2, len2, &pos1, &pos2, &max); if ((sum = max)) { @@ -4564,7 +4564,7 @@ PHPAPI size_t php_strip_tags_ex(char *rbuf, int len, int *stateptr, char *allow, char *tbuf, *buf, *p, *tp, *rp, c, lc; int br, i=0, depth=0, in_q = 0; int state = 0, pos; - char *allow_free; + char *allow_free = NULL; if (stateptr) state = *stateptr; diff --git a/ext/standard/tests/array/array_count_values_variation.phpt b/ext/standard/tests/array/array_count_values_variation.phpt index 89d7f37b1..1d614b452 100644 --- a/ext/standard/tests/array/array_count_values_variation.phpt +++ b/ext/standard/tests/array/array_count_values_variation.phpt @@ -1,5 +1,5 @@ --TEST-- -Test array_count_values() function : Test all normal paramter variations +Test array_count_values() function : Test all normal parameter variations --FILE-- <?php /* Prototype : proto array array_count_values(array input) @@ -9,7 +9,7 @@ Test array_count_values() function : Test all normal paramter variations */ /* - * Test behaviour with paramter variations + * Test behaviour with parameter variations */ echo "*** Testing array_count_values() : parameter variations ***\n"; diff --git a/ext/standard/tests/array/bug65304.phpt b/ext/standard/tests/array/bug65304.phpt new file mode 100644 index 000000000..e5c9dfc5e --- /dev/null +++ b/ext/standard/tests/array/bug65304.phpt @@ -0,0 +1,10 @@ +--TEST-- +Bug #65304 (Use of max int in array_sum) +--FILE-- +<?php +var_dump(array_sum(array(PHP_INT_MAX, 1))); +var_dump(PHP_INT_MAX + 1); +?> +--EXPECTF-- +float(%s) +float(%s) diff --git a/ext/standard/tests/file/chmod_basic-win32.phpt b/ext/standard/tests/file/chmod_basic-win32.phpt index ca224f7d1..31d44c80a 100644 --- a/ext/standard/tests/file/chmod_basic-win32.phpt +++ b/ext/standard/tests/file/chmod_basic-win32.phpt @@ -1,5 +1,5 @@ --TEST-- -chmod() basic fuctionality +chmod() basic functionality --SKIPIF-- <?php if (substr(PHP_OS, 0, 3) != 'WIN') { diff --git a/ext/standard/tests/file/chmod_basic.phpt b/ext/standard/tests/file/chmod_basic.phpt index 582f273d4..fc983074f 100644 --- a/ext/standard/tests/file/chmod_basic.phpt +++ b/ext/standard/tests/file/chmod_basic.phpt @@ -1,5 +1,5 @@ --TEST-- -chmod() basic fuctionality +chmod() basic functionality --SKIPIF-- <?php if (substr(PHP_OS, 0, 3) == 'WIN') { diff --git a/ext/standard/tests/file/file_get_contents_error001.phpt b/ext/standard/tests/file/file_get_contents_error001.phpt index 127901ad7..a347d9d3d 100644 --- a/ext/standard/tests/file/file_get_contents_error001.phpt +++ b/ext/standard/tests/file/file_get_contents_error001.phpt @@ -10,6 +10,7 @@ display_errors=false if (getenv("SKIP_SLOW_TESTS")) die("skip slow test"); if (!function_exists("file_get_contents")) die ("skip file_get_contents function is not found"); + if (getenv("SKIP_ONLINE_TESTS")) die("skip online test"); ?> --FILE-- <?php diff --git a/ext/standard/tests/network/ip2long_variation2_x64.phpt b/ext/standard/tests/network/ip2long_variation2_x64.phpt index d4b62fbca..a6fde5bdd 100644 --- a/ext/standard/tests/network/ip2long_variation2_x64.phpt +++ b/ext/standard/tests/network/ip2long_variation2_x64.phpt @@ -1,13 +1,21 @@ --TEST-- Test ip2long() function : usage variation 2, 64 bit --SKIPIF-- -<?php if(PHP_INT_SIZE != 8) {die('skip 64 bit only');} ?> +<?php +/* from man inet_pton : + All numbers supplied as ``parts'' in a `.' notation may be decimal, octal, or hexadecimal, as specified + in the C language (i.e., a leading 0x or 0X implies hexadecimal; otherwise, a leading 0 implies octal; + otherwise, the number is interpreted as decimal). +*/ +if(PHP_OS == 'Darwin') die("skip - inet_pton behaves differently on Darwin"); +if(PHP_INT_SIZE != 8) {die('skip 64 bit only');} +?> --FILE-- <?php /* Prototype : int ip2long(string ip_address) - * Description: Converts a string containing an (IPv4) Internet Protocol dotted address into a proper address + * Description: Converts a string containing an (IPv4) Internet Protocol dotted address into a proper address * Source code: ext/standard/basic_functions.c - * Alias to functions: + * Alias to functions: */ $ips = array( diff --git a/ext/standard/tests/strings/lcfirst.phpt b/ext/standard/tests/strings/lcfirst.phpt Binary files differindex 4c5bec898..e603f4bbf 100644 --- a/ext/standard/tests/strings/lcfirst.phpt +++ b/ext/standard/tests/strings/lcfirst.phpt diff --git a/ext/standard/tests/strings/str_replace.phpt b/ext/standard/tests/strings/str_replace.phpt index 830378b9a..15c1c8e53 100644 --- a/ext/standard/tests/strings/str_replace.phpt +++ b/ext/standard/tests/strings/str_replace.phpt @@ -120,7 +120,7 @@ var_dump($count); echo "\n-- Testing objects --\n"; /* we get "Catchable fatal error: saying Object of class could not be converted to string" by default, when an object is passed instead of string: -The error can be avoided by chosing the __toString magix method as follows: */ +The error can be avoided by choosing the __toString magix method as follows: */ class subject { diff --git a/ext/standard/tests/strings/str_replace_variation3.phpt b/ext/standard/tests/strings/str_replace_variation3.phpt index 9b19153fa..7b46f8b28 100644 --- a/ext/standard/tests/strings/str_replace_variation3.phpt +++ b/ext/standard/tests/strings/str_replace_variation3.phpt @@ -33,7 +33,7 @@ var_dump($count); echo "\n-- Testing objects --\n"; /* we get "Catchable fatal error: saying Object of class could not be converted to string" by default, when an object is passed instead of string: -The error can be avoided by chosing the __toString magix method as follows: */ +The error can be avoided by choosing the __toString magix method as follows: */ class subject { diff --git a/ext/standard/tests/strings/strcasecmp.phpt b/ext/standard/tests/strings/strcasecmp.phpt Binary files differindex 33694f987..b3452cfd7 100644 --- a/ext/standard/tests/strings/strcasecmp.phpt +++ b/ext/standard/tests/strings/strcasecmp.phpt diff --git a/ext/standard/tests/strings/strcmp.phpt b/ext/standard/tests/strings/strcmp.phpt Binary files differindex 069388011..e77ed6e46 100644 --- a/ext/standard/tests/strings/strcmp.phpt +++ b/ext/standard/tests/strings/strcmp.phpt diff --git a/ext/standard/tests/strings/strlen.phpt b/ext/standard/tests/strings/strlen.phpt Binary files differindex 5a1114d5c..df39f2469 100644 --- a/ext/standard/tests/strings/strlen.phpt +++ b/ext/standard/tests/strings/strlen.phpt diff --git a/ext/standard/tests/strings/strpos.phpt b/ext/standard/tests/strings/strpos.phpt Binary files differindex 9b44584ee..44785ef6c 100644 --- a/ext/standard/tests/strings/strpos.phpt +++ b/ext/standard/tests/strings/strpos.phpt diff --git a/ext/standard/tests/strings/strstr.phpt b/ext/standard/tests/strings/strstr.phpt Binary files differindex b135258f8..bdedb7e9f 100644 --- a/ext/standard/tests/strings/strstr.phpt +++ b/ext/standard/tests/strings/strstr.phpt diff --git a/ext/standard/tests/strings/ucfirst.phpt b/ext/standard/tests/strings/ucfirst.phpt Binary files differindex bae40955d..468f7f034 100644 --- a/ext/standard/tests/strings/ucfirst.phpt +++ b/ext/standard/tests/strings/ucfirst.phpt diff --git a/ext/standard/url_scanner_ex.c b/ext/standard/url_scanner_ex.c index 3a1f3abeb..57d5e3479 100644 --- a/ext/standard/url_scanner_ex.c +++ b/ext/standard/url_scanner_ex.c @@ -955,7 +955,7 @@ static void php_url_scanner_output_handler(char *output, uint output_len, char * PHPAPI int php_url_scanner_add_var(char *name, int name_len, char *value, int value_len, int urlencode TSRMLS_DC) { - char *encoded; + char *encoded = NULL; int encoded_len; smart_str val; diff --git a/ext/standard/url_scanner_ex.re b/ext/standard/url_scanner_ex.re index f0dee8ebc..ecacb76f9 100644 --- a/ext/standard/url_scanner_ex.re +++ b/ext/standard/url_scanner_ex.re @@ -463,7 +463,7 @@ static void php_url_scanner_output_handler(char *output, uint output_len, char * PHPAPI int php_url_scanner_add_var(char *name, int name_len, char *value, int value_len, int urlencode TSRMLS_DC) { - char *encoded; + char *encoded = NULL; int encoded_len; smart_str val; diff --git a/ext/standard/user_filters.c b/ext/standard/user_filters.c index b44be124a..1e5c38a37 100644 --- a/ext/standard/user_filters.c +++ b/ext/standard/user_filters.c @@ -559,7 +559,7 @@ PHP_FUNCTION(stream_get_filters) if (filters_hash) { for(zend_hash_internal_pointer_reset(filters_hash); - (key_flags = zend_hash_get_current_key_ex(filters_hash, &filter_name, &filter_name_len, &num_key, 0, NULL)) != HASH_KEY_NON_EXISTANT; + (key_flags = zend_hash_get_current_key_ex(filters_hash, &filter_name, &filter_name_len, &num_key, 0, NULL)) != HASH_KEY_NON_EXISTENT; zend_hash_move_forward(filters_hash)) if (key_flags == HASH_KEY_IS_STRING) { add_next_index_stringl(return_value, filter_name, filter_name_len - 1, 1); diff --git a/ext/standard/var.c b/ext/standard/var.c index f76a14cfa..cd868bb50 100644 --- a/ext/standard/var.c +++ b/ext/standard/var.c @@ -649,7 +649,7 @@ static void php_var_serialize_class(smart_str *buf, zval *struc, zval *retval_pt for (;; zend_hash_move_forward_ex(HASH_OF(retval_ptr), &pos)) { i = zend_hash_get_current_key_ex(HASH_OF(retval_ptr), &key, NULL, &index, 0, &pos); - if (i == HASH_KEY_NON_EXISTANT) { + if (i == HASH_KEY_NON_EXISTENT) { break; } @@ -860,7 +860,7 @@ static void php_var_serialize_intern(smart_str *buf, zval *struc, HashTable *var zend_hash_internal_pointer_reset_ex(myht, &pos); for (;; zend_hash_move_forward_ex(myht, &pos)) { i = zend_hash_get_current_key_ex(myht, &key, &key_len, &index, 0, &pos); - if (i == HASH_KEY_NON_EXISTANT) { + if (i == HASH_KEY_NON_EXISTENT) { break; } if (incomplete_class && strcmp(key, MAGIC_MEMBER) == 0) { diff --git a/ext/sybase_ct/config.m4 b/ext/sybase_ct/config.m4 index 81df1f312..276fe1267 100644 --- a/ext/sybase_ct/config.m4 +++ b/ext/sybase_ct/config.m4 @@ -3,7 +3,7 @@ dnl $Id$ dnl PHP_ARG_WITH(sybase-ct, for Sybase-CT support, -[ --with-sybase-ct[=DIR] Include Sybase-CT support. DIR is the Sybase home +[ --with-sybase-ct[=DIR] Include Sybase-CT support. DIR is the Sybase home directory [/home/sybase]]) if test "$PHP_SYBASE_CT" != "no"; then diff --git a/ext/tidy/config.m4 b/ext/tidy/config.m4 index 675498c8c..102f6a827 100644 --- a/ext/tidy/config.m4 +++ b/ext/tidy/config.m4 @@ -3,7 +3,7 @@ dnl $Id$ dnl PHP_ARG_WITH(tidy,for TIDY support, -[ --with-tidy[=DIR] Include TIDY support]) +[ --with-tidy[=DIR] Include TIDY support]) if test "$PHP_TIDY" != "no"; then diff --git a/ext/tidy/tidy.c b/ext/tidy/tidy.c index 5cfb16456..c3b9d8c34 100644 --- a/ext/tidy/tidy.c +++ b/ext/tidy/tidy.c @@ -1443,7 +1443,7 @@ static PHP_FUNCTION(tidy_get_config) /* }}} */ /* {{{ proto int tidy_get_status() - Get status of specfied document. */ + Get status of specified document. */ static PHP_FUNCTION(tidy_get_status) { TIDY_FETCH_OBJECT; diff --git a/ext/wddx/config.m4 b/ext/wddx/config.m4 index 2b02a92aa..8f933d490 100644 --- a/ext/wddx/config.m4 +++ b/ext/wddx/config.m4 @@ -7,11 +7,11 @@ PHP_ARG_ENABLE(wddx,whether to enable WDDX support, if test -z "$PHP_LIBXML_DIR"; then PHP_ARG_WITH(libxml-dir, libxml2 install dir, - [ --with-libxml-dir=DIR WDDX: libxml2 install prefix], no, no) + [ --with-libxml-dir=DIR WDDX: libxml2 install prefix], no, no) fi PHP_ARG_WITH(libexpat-dir, libexpat dir for WDDX, -[ --with-libexpat-dir=DIR WDDX: libexpat dir for XMLRPC-EPI (deprecated)],no,no) +[ --with-libexpat-dir=DIR WDDX: libexpat dir for XMLRPC-EPI (deprecated)],no,no) if test "$PHP_WDDX" != "no"; then diff --git a/ext/xml/config.m4 b/ext/xml/config.m4 index 65f22915b..ebfc0471e 100644 --- a/ext/xml/config.m4 +++ b/ext/xml/config.m4 @@ -7,11 +7,11 @@ PHP_ARG_ENABLE(xml,whether to enable XML support, if test -z "$PHP_LIBXML_DIR"; then PHP_ARG_WITH(libxml-dir, libxml2 install dir, - [ --with-libxml-dir=DIR XML: libxml2 install prefix], no, no) + [ --with-libxml-dir=DIR XML: libxml2 install prefix], no, no) fi PHP_ARG_WITH(libexpat-dir, libexpat install dir, -[ --with-libexpat-dir=DIR XML: libexpat install prefix (deprecated)], no, no) +[ --with-libexpat-dir=DIR XML: libexpat install prefix (deprecated)], no, no) if test "$PHP_XML" != "no"; then diff --git a/ext/xmlreader/config.m4 b/ext/xmlreader/config.m4 index 3614996fb..d346b58ee 100644 --- a/ext/xmlreader/config.m4 +++ b/ext/xmlreader/config.m4 @@ -7,7 +7,7 @@ PHP_ARG_ENABLE(xmlreader, whether to enable XMLReader support, if test -z "$PHP_LIBXML_DIR"; then PHP_ARG_WITH(libxml-dir, libxml2 install dir, - [ --with-libxml-dir=DIR XMLReader: libxml2 install prefix], no, no) + [ --with-libxml-dir=DIR XMLReader: libxml2 install prefix], no, no) fi if test "$PHP_XMLREADER" != "no"; then diff --git a/ext/xmlrpc/config.m4 b/ext/xmlrpc/config.m4 index 389d4adaf..f82016edc 100644 --- a/ext/xmlrpc/config.m4 +++ b/ext/xmlrpc/config.m4 @@ -8,18 +8,18 @@ sinclude(libxmlrpc/acinclude.m4) sinclude(libxmlrpc/xmlrpc.m4) PHP_ARG_WITH(xmlrpc, for XMLRPC-EPI support, -[ --with-xmlrpc[=DIR] Include XMLRPC-EPI support]) +[ --with-xmlrpc[=DIR] Include XMLRPC-EPI support]) if test -z "$PHP_LIBXML_DIR"; then PHP_ARG_WITH(libxml-dir, libxml2 install dir, - [ --with-libxml-dir=DIR XMLRPC-EPI: libxml2 install prefix], no, no) + [ --with-libxml-dir=DIR XMLRPC-EPI: libxml2 install prefix], no, no) fi PHP_ARG_WITH(libexpat-dir, libexpat dir for XMLRPC-EPI, -[ --with-libexpat-dir=DIR XMLRPC-EPI: libexpat dir for XMLRPC-EPI (deprecated)],no,no) +[ --with-libexpat-dir=DIR XMLRPC-EPI: libexpat dir for XMLRPC-EPI (deprecated)],no,no) PHP_ARG_WITH(iconv-dir, iconv dir for XMLRPC-EPI, -[ --with-iconv-dir=DIR XMLRPC-EPI: iconv dir for XMLRPC-EPI],no,no) +[ --with-iconv-dir=DIR XMLRPC-EPI: iconv dir for XMLRPC-EPI],no,no) if test "$PHP_XMLRPC" != "no"; then diff --git a/ext/xmlrpc/libxmlrpc/xml_to_soap.c b/ext/xmlrpc/libxmlrpc/xml_to_soap.c index 664e8b77b..ac103e061 100644 --- a/ext/xmlrpc/libxmlrpc/xml_to_soap.c +++ b/ext/xmlrpc/libxmlrpc/xml_to_soap.c @@ -279,7 +279,7 @@ XMLRPC_VALUE xml_element_to_SOAP_REQUEST_worker(XMLRPC_REQUEST request, else if (!strcmp(attr_iter->key, TOKEN_MUSTUNDERSTAND)) { b_must_understand = strchr(attr_iter->val, '1') ? 1 : 0; } - /* actor, used in conjuction with must understand. */ + /* actor, used in conjunction with must understand. */ else if (!strcmp(attr_iter->key, TOKEN_ACTOR)) { actor = attr_iter->val; } diff --git a/ext/xmlrpc/xmlrpc-epi-php.c b/ext/xmlrpc/xmlrpc-epi-php.c index 925b554a5..b73cbcfe2 100644 --- a/ext/xmlrpc/xmlrpc-epi-php.c +++ b/ext/xmlrpc/xmlrpc-epi-php.c @@ -502,7 +502,7 @@ static XMLRPC_VECTOR_TYPE determine_vector_type (HashTable *ht) } bArray = 1; last_num = num_index; - } else if (res == HASH_KEY_NON_EXISTANT) { + } else if (res == HASH_KEY_NON_EXISTENT) { break; } else if (res == HASH_KEY_IS_STRING) { if (bArray) { @@ -582,7 +582,7 @@ static XMLRPC_VALUE PHP_to_XMLRPC_worker (const char* key, zval* in_val, int dep int res = my_zend_hash_get_current_key(Z_ARRVAL_P(val_arr), &my_key, &num_index); switch (res) { - case HASH_KEY_NON_EXISTANT: + case HASH_KEY_NON_EXISTENT: break; case HASH_KEY_IS_STRING: case HASH_KEY_IS_LONG: diff --git a/ext/xmlwriter/config.m4 b/ext/xmlwriter/config.m4 index 0a5d07943..b3b98012f 100644 --- a/ext/xmlwriter/config.m4 +++ b/ext/xmlwriter/config.m4 @@ -7,7 +7,7 @@ PHP_ARG_ENABLE(xmlwriter, whether to enable XMLWriter support, if test -z "$PHP_LIBXML_DIR"; then PHP_ARG_WITH(libxml-dir, libxml2 install dir, - [ --with-libxml-dir=DIR XMLWriter: libxml2 install prefix], no, no) + [ --with-libxml-dir=DIR XMLWriter: libxml2 install prefix], no, no) fi if test "$PHP_XMLWRITER" != "no"; then diff --git a/ext/xsl/config.m4 b/ext/xsl/config.m4 index a2b16d24f..9b6f8aaa4 100644 --- a/ext/xsl/config.m4 +++ b/ext/xsl/config.m4 @@ -3,7 +3,7 @@ dnl $Id$ dnl PHP_ARG_WITH(xsl, for XSL support, -[ --with-xsl[=DIR] Include XSL support. DIR is the libxslt base +[ --with-xsl[=DIR] Include XSL support. DIR is the libxslt base install directory (libxslt >= 1.1.0 required)]) if test "$PHP_XSL" != "no"; then diff --git a/ext/xsl/xsltprocessor.c b/ext/xsl/xsltprocessor.c index 1785519c1..af11104a2 100644 --- a/ext/xsl/xsltprocessor.c +++ b/ext/xsl/xsltprocessor.c @@ -476,7 +476,7 @@ PHP_FUNCTION(xsl_xsltprocessor_import_stylesheet) static xmlDocPtr php_xsl_apply_stylesheet(zval *id, xsl_object *intern, xsltStylesheetPtr style, zval *docp TSRMLS_DC) /* {{{ */ { - xmlDocPtr newdocp; + xmlDocPtr newdocp = NULL; xmlDocPtr doc = NULL; xmlNodePtr node = NULL; xsltTransformContextPtr ctxt; diff --git a/ext/zip/config.m4 b/ext/zip/config.m4 index 85f9119f5..805d92442 100644 --- a/ext/zip/config.m4 +++ b/ext/zip/config.m4 @@ -11,7 +11,7 @@ if test -z "$PHP_ZLIB_DIR"; then fi PHP_ARG_WITH(pcre-dir, pcre install prefix, -[ --with-pcre-dir ZIP: pcre install prefix], no, no) +[ --with-pcre-dir ZIP: pcre install prefix], no, no) if test "$PHP_ZIP" != "no"; then diff --git a/ext/zip/php_zip.c b/ext/zip/php_zip.c index 37a0cdea1..7297523aa 100644 --- a/ext/zip/php_zip.c +++ b/ext/zip/php_zip.c @@ -1654,7 +1654,7 @@ static void php_zip_add_from_pattern(INTERNAL_FUNCTION_PARAMETERS, int type) /* char *path = NULL; char *remove_path = NULL; char *add_path = NULL; - int pattern_len, add_path_len, remove_path_len, path_len = 0; + int pattern_len, add_path_len = 0, remove_path_len = 0, path_len = 0; long remove_all_path = 0; long flags = 0; zval *options = NULL; diff --git a/ext/zlib/config0.m4 b/ext/zlib/config0.m4 index 25c7f4f42..ebf67cc00 100644 --- a/ext/zlib/config0.m4 +++ b/ext/zlib/config0.m4 @@ -3,7 +3,7 @@ dnl $Id$ dnl PHP_ARG_WITH(zlib,for ZLIB support, -[ --with-zlib[=DIR] Include ZLIB support (requires zlib >= 1.0.9)]) +[ --with-zlib[=DIR] Include ZLIB support (requires zlib >= 1.0.9)]) PHP_ARG_WITH(zlib-dir,if the location of ZLIB install directory is defined, [ --with-zlib-dir=<DIR> Define the location of zlib install directory], no, no) diff --git a/ext/zlib/tests/bug65391.phpt b/ext/zlib/tests/bug65391.phpt new file mode 100644 index 000000000..3ba535081 --- /dev/null +++ b/ext/zlib/tests/bug65391.phpt @@ -0,0 +1,28 @@ +--TEST-- +Bug #65391 (Unable to send vary header user-agent when ob_start('ob_gzhandler') is called) +--SKIPIF-- +<?php +extension_loaded("zlib") or die("skip need zlib"); +?> +--GET-- +dummy=1 +--FILE-- +<?php +header("Vary: Cookie"); +ob_start("ob_gzhandler"); + +// run-tests cannot test for a multiple Vary header +ob_flush(); +print_r(headers_list()); + +?> +Done +--EXPECTF-- +Array +( + [0] => X-Powered-By: PHP/%s + [1] => Vary: Cookie + [2] => Vary: Accept-Encoding +) +Done + diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c index 1a202e344..1114bc8a6 100644 --- a/ext/zlib/zlib.c +++ b/ext/zlib/zlib.c @@ -190,7 +190,7 @@ static int php_zlib_output_handler(void **handler_context, php_output_context *o if ((output_context->op & PHP_OUTPUT_HANDLER_START) && (output_context->op != (PHP_OUTPUT_HANDLER_START|PHP_OUTPUT_HANDLER_CLEAN|PHP_OUTPUT_HANDLER_FINAL)) ) { - sapi_add_header_ex(ZEND_STRL("Vary: Accept-Encoding"), 1, 1 TSRMLS_CC); + sapi_add_header_ex(ZEND_STRL("Vary: Accept-Encoding"), 1, 0 TSRMLS_CC); } return FAILURE; } @@ -220,7 +220,7 @@ static int php_zlib_output_handler(void **handler_context, php_output_context *o deflateEnd(&ctx->Z); return FAILURE; } - sapi_add_header_ex(ZEND_STRL("Vary: Accept-Encoding"), 1, 1 TSRMLS_CC); + sapi_add_header_ex(ZEND_STRL("Vary: Accept-Encoding"), 1, 0 TSRMLS_CC); php_output_handler_hook(PHP_OUTPUT_HANDLER_HOOK_IMMUTABLE, NULL TSRMLS_CC); } } @@ -478,7 +478,7 @@ static PHP_FUNCTION(ob_gzhandler) sapi_add_header_ex(ZEND_STRL("Content-Encoding: deflate"), 1, 1 TSRMLS_CC); break; } - sapi_add_header_ex(ZEND_STRL("Vary: Accept-Encoding"), 1, 1 TSRMLS_CC); + sapi_add_header_ex(ZEND_STRL("Vary: Accept-Encoding"), 1, 0 TSRMLS_CC); } if (!ZLIBG(ob_gzhandler)) { |
