From c1f597d9a13a6a4df80d9969fe7845b45bddf402 Mon Sep 17 00:00:00 2001 From: Lior Kaplan Date: Fri, 8 Apr 2016 22:38:07 +0300 Subject: [PATCH 1/8] opcache config.m4: Use = for comparison --- ext/opcache/config.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/opcache/config.m4 b/ext/opcache/config.m4 index f6e6ca94449..5a8b86c1488 100644 --- a/ext/opcache/config.m4 +++ b/ext/opcache/config.m4 @@ -359,7 +359,7 @@ AC_TRY_RUN([ AC_MSG_RESULT("yes") ], AC_MSG_RESULT("no") ) -if test "$flock_type" == "unknown"; then +if test "$flock_type" = "unknown"; then AC_MSG_ERROR([Don't know how to define struct flock on this system[,] set --enable-opcache=no]) fi From c6c44c36298d573932f153071f3bb20007924173 Mon Sep 17 00:00:00 2001 From: Lior Kaplan Date: Sat, 9 Apr 2016 15:57:57 +0300 Subject: [PATCH 2/8] Enable configure without opcache-file and huge-code-pages This doesn't chagne the default (yes for both features), but respects --disable-opcache-file and --disable-huge-code-pages configure flags if given. --- ext/opcache/config.m4 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/opcache/config.m4 b/ext/opcache/config.m4 index 657d8596918..fbb9b21c946 100644 --- a/ext/opcache/config.m4 +++ b/ext/opcache/config.m4 @@ -6,11 +6,11 @@ PHP_ARG_ENABLE(opcache, whether to enable Zend OPcache support, [ --disable-opcache Disable Zend OPcache support], yes) PHP_ARG_ENABLE(opcache-file, whether to enable file based caching, -[ --disable-opcache-file Disable file based caching], yes) +[ --disable-opcache-file Disable file based caching], yes, no) PHP_ARG_ENABLE(huge-code-pages, whether to enable copying PHP CODE pages into HUGE PAGES, [ --disable-huge-code-pages - Disable copying PHP CODE pages into HUGE PAGES], yes) + Disable copying PHP CODE pages into HUGE PAGES], yes, no) if test "$PHP_OPCACHE" != "no"; then From ef17343b3cb9195437d760ec21dcdf6004a85b67 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Sat, 9 Apr 2016 18:22:57 +0200 Subject: [PATCH 3/8] Fixed bug #66289 Locale::lookup incorrectly returns en or en_US if locale is empty --- ext/intl/locale/locale_methods.c | 6 +++++- ext/intl/tests/locale_bug66289.phpt | 27 +++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 ext/intl/tests/locale_bug66289.phpt diff --git a/ext/intl/locale/locale_methods.c b/ext/intl/locale/locale_methods.c index c47f2832015..3471ba40539 100644 --- a/ext/intl/locale/locale_methods.c +++ b/ext/intl/locale/locale_methods.c @@ -1548,7 +1548,11 @@ PHP_FUNCTION(locale_lookup) } if(loc_range_len == 0) { - loc_range = intl_locale_get_default(); + if(fallback_loc_str) { + loc_range = ZSTR_VAL(fallback_loc_str); + } else { + loc_range = intl_locale_get_default(); + } } hash_arr = Z_ARRVAL_P(arr); diff --git a/ext/intl/tests/locale_bug66289.phpt b/ext/intl/tests/locale_bug66289.phpt new file mode 100644 index 00000000000..6afd821b5a8 --- /dev/null +++ b/ext/intl/tests/locale_bug66289.phpt @@ -0,0 +1,27 @@ +--TEST-- +Bug #66289 Locale::lookup incorrectly returns en or en_US if locale is empty +--SKIPIF-- + +--FILE-- + +==DONE== +--EXPECT-- +string(5) "fr_fr" +string(5) "en_us" +string(5) "fr_fr" +string(5) "de_de" +==DONE== From e33c26659e221a14dd8406b0c0d05a29395a8b98 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Sat, 9 Apr 2016 18:52:59 +0200 Subject: [PATCH 4/8] update NEWS --- NEWS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS b/NEWS index 57faa197393..3c8130f0d66 100644 --- a/NEWS +++ b/NEWS @@ -43,6 +43,8 @@ PHP NEWS . Fixed bug #70451, #70452 (Inconsistencies in return values of IntlChar methods). (Daniel Persson) . Fixed bug #68893 (Stackoverflow in datefmt_create). (Anatol) + . Fixed bug #66289 (Locale::lookup incorrectly returns en or en_US if + locale is empty). (Anatol) - ODBC: . Fixed bug #63171 (Script hangs after max_execution_time). (Remi) From 5db4d9a71c1510921f1d5514d1e1d4bf53200eae Mon Sep 17 00:00:00 2001 From: Xinchen Hui Date: Sat, 9 Apr 2016 10:01:04 -0700 Subject: [PATCH 5/8] Fixed bug #71995 (Returning the same var twice from __sleep() produces broken serialized data) --- NEWS | 2 + ext/standard/tests/serialize/bug71995.phpt | 27 +++++++++ ext/standard/var.c | 66 +++++++++++++++------- 3 files changed, 75 insertions(+), 20 deletions(-) create mode 100644 ext/standard/tests/serialize/bug71995.phpt diff --git a/NEWS b/NEWS index 57faa197393..1c0a5cd106e 100644 --- a/NEWS +++ b/NEWS @@ -84,6 +84,8 @@ PHP NEWS . Fixed bug #52339 (SPL autoloader breaks class_exists()). (Nikita) - Standard: + . Fixed bug #71995 (Returning the same var twice from __sleep() produces + broken serialized data). (Laruence) . Fixed bug #71940 (Unserialize crushes on restore object reference). (Laruence) . Fixed bug #71969 (str_replace returns an incorrect resulting array after diff --git a/ext/standard/tests/serialize/bug71995.phpt b/ext/standard/tests/serialize/bug71995.phpt new file mode 100644 index 00000000000..0f7ac987222 --- /dev/null +++ b/ext/standard/tests/serialize/bug71995.phpt @@ -0,0 +1,27 @@ +--TEST-- +Bug #71995 (Returning the same var twice from __sleep() produces broken serialized data) +--FILE-- +b = new StdClass(); + } + public function __sleep() { + return array("b", "b"); + } +} +$a = new A(); +$s = serialize($a); +var_dump($s); +var_dump(unserialize($s)); +?> +--EXPECTF-- +Notice: serialize(): "b" is returned from __sleep multiple times in %sbug71995.php on line %d +string(39) "O:1:"A":1:{s:1:"b";O:8:"stdClass":0:{}}" +object(A)#%d (1) { + ["b"]=> + object(stdClass)#%d (0) { + } +} diff --git a/ext/standard/var.c b/ext/standard/var.c index ca621dd8a4d..acb1d40c017 100644 --- a/ext/standard/var.c +++ b/ext/standard/var.c @@ -666,6 +666,36 @@ static inline zend_bool php_var_serialize_class_name(smart_str *buf, zval *struc } /* }}} */ +static HashTable *php_var_serialize_collect_names(HashTable *src, uint32_t count, zend_bool incomplete) /* {{{ */ { + zval *val; + HashTable *ht; + zend_string *key, *name; + + ALLOC_HASHTABLE(ht); + zend_hash_init(ht, count, NULL, NULL, 0); + ZEND_HASH_FOREACH_STR_KEY_VAL(src, key, val) { + if (incomplete && strcmp(ZSTR_VAL(key), MAGIC_MEMBER) == 0) { + continue; + } + if (Z_TYPE_P(val) != IS_STRING) { + php_error_docref(NULL, E_NOTICE, + "__sleep should return an array only containing the names of instance-variables to serialize."); + } + name = zval_get_string(val); + if (zend_hash_exists(ht, name)) { + php_error_docref(NULL, E_NOTICE, + "\"%s\" is returned from __sleep multiple times", ZSTR_VAL(name)); + zend_string_release(name); + continue; + } + zend_hash_add_empty_element(ht, name); + zend_string_release(name); + } ZEND_HASH_FOREACH_END(); + + return ht; +} +/* }}} */ + static void php_var_serialize_class(smart_str *buf, zval *struc, zval *retval_ptr, php_serialize_data_t var_hash) /* {{{ */ { uint32_t count; @@ -686,37 +716,29 @@ static void php_var_serialize_class(smart_str *buf, zval *struc, zval *retval_pt } } else { count = 0; + ht = NULL; } - smart_str_append_unsigned(buf, count); - smart_str_appendl(buf, ":{", 2); - if (count > 0) { - zend_string *key; - zval *d, *val; + zval *d; zval nval, *nvalp; zend_string *name; - HashTable *propers; + HashTable *names, *propers; + + names = php_var_serialize_collect_names(ht, count, incomplete_class); + + smart_str_append_unsigned(buf, zend_hash_num_elements(names)); + smart_str_appendl(buf, ":{", 2); ZVAL_NULL(&nval); nvalp = &nval; + propers = Z_OBJPROP_P(struc); - ZEND_HASH_FOREACH_STR_KEY_VAL(ht, key, val) { - if (incomplete_class && strcmp(ZSTR_VAL(key), MAGIC_MEMBER) == 0) { - continue; - } - - if (Z_TYPE_P(val) != IS_STRING) { - php_error_docref(NULL, E_NOTICE, - "__sleep should return an array only containing the names of instance-variables to serialize."); - } - name = zval_get_string(val); - propers = Z_OBJPROP_P(struc); + ZEND_HASH_FOREACH_STR_KEY(names, name) { if ((d = zend_hash_find(propers, name)) != NULL) { if (Z_TYPE_P(d) == IS_INDIRECT) { d = Z_INDIRECT_P(d); if (Z_TYPE_P(d) == IS_UNDEF) { - zend_string_release(name); continue; } } @@ -769,10 +791,14 @@ static void php_var_serialize_class(smart_str *buf, zval *struc, zval *retval_pt php_var_serialize_intern(buf, nvalp, var_hash); } } - zend_string_release(name); } ZEND_HASH_FOREACH_END(); + smart_str_appendc(buf, '}'); + + zend_hash_destroy(names); + FREE_HASHTABLE(names); + } else { + smart_str_appendl(buf, "0:{}", 4); } - smart_str_appendc(buf, '}'); } /* }}} */ From 58ea2ad4897b74b0a11d3da8a64c557ff18b0021 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Sat, 9 Apr 2016 19:10:53 +0200 Subject: [PATCH 6/8] Fixed bug #65480 No declaration for msgformat_fix_quotes() in msgformat.c or msgformat_attr.c --- ext/intl/msgformat/msgformat.c | 1 + ext/intl/msgformat/msgformat_attr.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ext/intl/msgformat/msgformat.c b/ext/intl/msgformat/msgformat.c index e0919ec42b2..d3f8416c031 100644 --- a/ext/intl/msgformat/msgformat.c +++ b/ext/intl/msgformat/msgformat.c @@ -23,6 +23,7 @@ #include "php_intl.h" #include "msgformat_class.h" +#include "msgformat_data.h" #include "intl_convert.h" /* {{{ */ diff --git a/ext/intl/msgformat/msgformat_attr.c b/ext/intl/msgformat/msgformat_attr.c index a20a7e411d7..78eb727c611 100644 --- a/ext/intl/msgformat/msgformat_attr.c +++ b/ext/intl/msgformat/msgformat_attr.c @@ -21,11 +21,11 @@ #include "php_intl.h" #include "msgformat_class.h" #include "msgformat_attr.h" +#include "msgformat_data.h" #include "intl_convert.h" #include - /* {{{ proto string MessageFormatter::getPattern( ) * Get formatter pattern. }}} */ /* {{{ proto string msgfmt_get_pattern( MessageFormatter $mf ) From b4ab0effc76385a3e1d7cded722a27481019b481 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Sun, 10 Apr 2016 18:48:35 +0200 Subject: [PATCH 7/8] Fixed bug #71998 Function pg_insert does not insert when column type = inet --- ext/pgsql/pgsql.c | 9 +- ext/pgsql/tests/bug71998.phpt | 196 ++++++++++++++++++++++++++++++++++ 2 files changed, 202 insertions(+), 3 deletions(-) create mode 100644 ext/pgsql/tests/bug71998.phpt diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c index cb6f4cac493..21321e4a95e 100644 --- a/ext/pgsql/pgsql.c +++ b/ext/pgsql/pgsql.c @@ -6145,8 +6145,11 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con ZVAL_STRINGL(&new_val, "NULL", sizeof("NULL")-1); } else { - /* better regex? IPV6 and IPV4 */ - if (php_pgsql_convert_match(Z_STRVAL_P(val), Z_STRLEN_P(val), "^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]).){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]).){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$", 0) == FAILURE) { + /* The inet type holds an IPv4 or IPv6 host address, and optionally its subnet, all in one field. See more in the doc. + The regex might still be not perfect, but catches the most of IP variants. We might decide to remove the regex + at all though and let the server side to handle it.*/ + if (php_pgsql_convert_match(Z_STRVAL_P(val), Z_STRLEN_P(val), "^((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])(\/[0-9]{1,3})?$", 0) == FAILURE + && php_pgsql_convert_match(Z_STRVAL_P(val), Z_STRLEN_P(val), "^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))(\/[0-9]{1,3})?$", 0) == FAILURE) { err = 1; } else { @@ -6165,7 +6168,7 @@ PHP_PGSQL_API int php_pgsql_convert(PGconn *pg_link, const char *table_name, con } PGSQL_CONV_CHECK_IGNORE(); if (err) { - php_error_docref(NULL, E_NOTICE, "Expects NULL or string for '%s' (%s)", Z_STRVAL_P(type), ZSTR_VAL(field)); + php_error_docref(NULL, E_NOTICE, "Expects NULL or IPv4 or IPv6 address string for '%s' (%s)", Z_STRVAL_P(type), ZSTR_VAL(field)); } break; diff --git a/ext/pgsql/tests/bug71998.phpt b/ext/pgsql/tests/bug71998.phpt new file mode 100644 index 00000000000..b9924166f9a --- /dev/null +++ b/ext/pgsql/tests/bug71998.phpt @@ -0,0 +1,196 @@ +--TEST-- +Bug #71998 Function pg_insert does not insert when column type = inet +--SKIPIF-- + +--FILE-- + ++$i, "remote_addr" => $ip); + $r = @pg_insert($db, 'tmp_statistics', $data); + + if (!$r && in_array($ip, $bad)) { + $errors++; + //echo pg_last_error($db); + } + + //pg_query($db, "INSERT INTO tmp_statistics (id, remote_addr) VALUES (2, '127.0.0.1')"); // OK, record inserted +} + + +$r = pg_query($db, "SELECT * FROM tmp_statistics"); +while (false != ($row = pg_fetch_row($r))) { + var_dump($row); +} +echo $errors, " errors catched\n"; + +pg_query($db, "DROP TABLE tmp_statistics"); +pg_close($db); + +?> +==DONE== +--EXPECT-- +array(2) { + [0]=> + string(1) "1" + [1]=> + string(9) "127.0.0.1" +} +array(2) { + [0]=> + string(1) "2" + [1]=> + string(8) "10.0.0.1" +} +array(2) { + [0]=> + string(1) "3" + [1]=> + string(11) "192.168.1.1" +} +array(2) { + [0]=> + string(1) "4" + [1]=> + string(7) "0.0.0.0" +} +array(2) { + [0]=> + string(1) "5" + [1]=> + string(15) "255.255.255.255" +} +array(2) { + [0]=> + string(1) "6" + [1]=> + string(15) "192.168.1.35/24" +} +array(2) { + [0]=> + string(1) "7" + [1]=> + string(3) "::1" +} +array(2) { + [0]=> + string(1) "8" + [1]=> + string(10) "::10.2.3.4" +} +array(2) { + [0]=> + string(1) "9" + [1]=> + string(15) "::ffff:10.4.3.2" +} +array(2) { + [0]=> + string(2) "10" + [1]=> + string(15) "1:2:3:4:5:6:7:8" +} +array(2) { + [0]=> + string(2) "11" + [1]=> + string(15) "::ffff:10.0.0.1" +} +array(2) { + [0]=> + string(2) "12" + [1]=> + string(14) "::ffff:1.2.3.4" +} +array(2) { + [0]=> + string(2) "13" + [1]=> + string(14) "::ffff:0.0.0.0" +} +array(2) { + [0]=> + string(2) "14" + [1]=> + string(17) "1:2:3:4:5:6:77:88" +} +array(2) { + [0]=> + string(2) "15" + [1]=> + string(22) "::ffff:255.255.255.255" +} +array(2) { + [0]=> + string(2) "16" + [1]=> + string(9) "fe08::7:8" +} +array(2) { + [0]=> + string(2) "17" + [1]=> + string(39) "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff" +} +array(2) { + [0]=> + string(2) "18" + [1]=> + string(13) "::5:aef1:ffff" +} +array(2) { + [0]=> + string(2) "19" + [1]=> + string(19) "2001:4f8:3:ba::/112" +} +7 errors catched +==DONE== From 190db69109808659071d0aa9bb86c4af14a33268 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Sun, 10 Apr 2016 19:10:45 +0200 Subject: [PATCH 8/8] update NEWS --- NEWS | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/NEWS b/NEWS index 1c0a5cd106e..a46f5f0ecf5 100644 --- a/NEWS +++ b/NEWS @@ -43,6 +43,8 @@ PHP NEWS . Fixed bug #70451, #70452 (Inconsistencies in return values of IntlChar methods). (Daniel Persson) . Fixed bug #68893 (Stackoverflow in datefmt_create). (Anatol) + . Fixed bug #66289 (Locale::lookup incorrectly returns en or en_US if locale + is empty). (Anatol) - ODBC: . Fixed bug #63171 (Script hangs after max_execution_time). (Remi) @@ -70,6 +72,8 @@ PHP NEWS - Postgres: . Fixed bug #71820 (pg_fetch_object binds parameters before call constructor). (Anatol) + . Fixed bug #71998 (Function pg_insert does not insert when column + type = inet). (Anatol) - SOAP: . Fixed bug #71986 (Nested foreach assign-by-reference creates broken