From a475b2c1db3512eabfece71430cb49065f558e40 Mon Sep 17 00:00:00 2001 From: Boro Sitnikovski Date: Fri, 13 Sep 2013 02:20:19 +0200 Subject: Bug 64157 Changed error message to make sense --- ext/date/lib/parse_date.c | 2 +- ext/date/lib/parse_date.re | 2 +- ext/date/tests/bug64157.phpt | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 ext/date/tests/bug64157.phpt diff --git a/ext/date/lib/parse_date.c b/ext/date/lib/parse_date.c index 2ad4d31edb..f510a665e8 100644 --- a/ext/date/lib/parse_date.c +++ b/ext/date/lib/parse_date.c @@ -25036,7 +25036,7 @@ timelib_time *timelib_parse_from_format(char *format, char *string, int len, tim TIMELIB_CHECK_NUMBER; sec = timelib_get_nr_ex((char **) &ptr, 2, &length); if (sec == TIMELIB_UNSET || length != 2) { - add_pbf_error(s, "A two second minute could not be found", string, begin); + add_pbf_error(s, "A two digit second could not be found", string, begin); } else { s->time->s = sec; } diff --git a/ext/date/lib/parse_date.re b/ext/date/lib/parse_date.re index f874682ce6..df33508f50 100644 --- a/ext/date/lib/parse_date.re +++ b/ext/date/lib/parse_date.re @@ -2043,7 +2043,7 @@ timelib_time *timelib_parse_from_format(char *format, char *string, int len, tim TIMELIB_CHECK_NUMBER; sec = timelib_get_nr_ex((char **) &ptr, 2, &length); if (sec == TIMELIB_UNSET || length != 2) { - add_pbf_error(s, "A two second minute could not be found", string, begin); + add_pbf_error(s, "A two digit second could not be found", string, begin); } else { s->time->s = sec; } diff --git a/ext/date/tests/bug64157.phpt b/ext/date/tests/bug64157.phpt new file mode 100644 index 0000000000..fb71495430 --- /dev/null +++ b/ext/date/tests/bug64157.phpt @@ -0,0 +1,14 @@ +--TEST-- +Test for bug #64157: DateTime::createFromFormat() reports confusing error message +--CREDITS-- +Boro Sitnikovski +--INI-- +date.timezone = UTC +--FILE-- + +--EXPECT-- +A two digit second could not be found -- cgit v1.2.1 From c0afe829e33c5f5690c6967a102148984836d5aa Mon Sep 17 00:00:00 2001 From: David Soria Parra Date: Mon, 16 Sep 2013 03:48:34 +0200 Subject: News for bugfix #64157 --- NEWS | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/NEWS b/NEWS index e05b24042b..c7d5e030f3 100644 --- a/NEWS +++ b/NEWS @@ -6,6 +6,10 @@ PHP NEWS . Fixed bug #65633 (built-in server treat some http headers as case-sensitive). (Adam) +- Datetime: + . Fixed bug #64157 (DateTime::createFromFormat() reports confusing error + message). (Boro Sitnikovski) + ?? ??? 2013, PHP 5.4.20 - Core: -- cgit v1.2.1 From 8a936e8eb938965b0daaf076c109ec60141e57a7 Mon Sep 17 00:00:00 2001 From: Levi Morrison Date: Thu, 12 Sep 2013 16:03:39 -0600 Subject: EmptyIterator now implements Countable; fixes bug 60577 (cherry picked from commit 6398844c86bee08abe4ee3f206ecd86ad0a498f9) --- ext/spl/internal/emptyiterator.inc | 13 +++++++++++-- ext/spl/spl_iterators.c | 12 ++++++++++++ ext/spl/tests/bug60577.phpt | 8 ++++++++ 3 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 ext/spl/tests/bug60577.phpt diff --git a/ext/spl/internal/emptyiterator.inc b/ext/spl/internal/emptyiterator.inc index ac80e79581..d02b15b999 100644 --- a/ext/spl/internal/emptyiterator.inc +++ b/ext/spl/internal/emptyiterator.inc @@ -15,7 +15,7 @@ * @version 1.0 * @since PHP 5.1 */ -class EmptyIterator implements Iterator +class EmptyIterator implements Iterator, Countable { /** No operation. * @return void @@ -57,6 +57,15 @@ class EmptyIterator implements Iterator { // nothing to do } + + /** + * @return int + */ + function count() + { + return 0; + } + } -?> \ No newline at end of file +?> diff --git a/ext/spl/spl_iterators.c b/ext/spl/spl_iterators.c index eb8247654e..ad76258413 100644 --- a/ext/spl/spl_iterators.c +++ b/ext/spl/spl_iterators.c @@ -3279,12 +3279,23 @@ SPL_METHOD(EmptyIterator, next) } } /* }}} */ +/* {{{ proto int EmptyIterator::count() + Does nothing */ +SPL_METHOD(EmptyIterator, count) +{ + if (zend_parse_parameters_none() == FAILURE) { + return; + } + RETURN_LONG(0); +} /* }}} */ + static const zend_function_entry spl_funcs_EmptyIterator[] = { SPL_ME(EmptyIterator, rewind, arginfo_recursive_it_void, ZEND_ACC_PUBLIC) SPL_ME(EmptyIterator, valid, arginfo_recursive_it_void, ZEND_ACC_PUBLIC) SPL_ME(EmptyIterator, key, arginfo_recursive_it_void, ZEND_ACC_PUBLIC) SPL_ME(EmptyIterator, current, arginfo_recursive_it_void, ZEND_ACC_PUBLIC) SPL_ME(EmptyIterator, next, arginfo_recursive_it_void, ZEND_ACC_PUBLIC) + SPL_ME(EmptyIterator, count, arginfo_recursive_it_void, ZEND_ACC_PUBLIC) PHP_FE_END }; @@ -3756,6 +3767,7 @@ PHP_MINIT_FUNCTION(spl_iterators) REGISTER_SPL_STD_CLASS_EX(EmptyIterator, NULL, spl_funcs_EmptyIterator); REGISTER_SPL_ITERATOR(EmptyIterator); + REGISTER_SPL_IMPLEMENTS(EmptyIterator, Countable); REGISTER_SPL_SUB_CLASS_EX(RecursiveTreeIterator, RecursiveIteratorIterator, spl_RecursiveTreeIterator_new, spl_funcs_RecursiveTreeIterator); REGISTER_SPL_CLASS_CONST_LONG(RecursiveTreeIterator, "BYPASS_CURRENT", RTIT_BYPASS_CURRENT); diff --git a/ext/spl/tests/bug60577.phpt b/ext/spl/tests/bug60577.phpt new file mode 100644 index 0000000000..33fc133d0f --- /dev/null +++ b/ext/spl/tests/bug60577.phpt @@ -0,0 +1,8 @@ +--TEST-- +count(new EmptyIterator) should return zero +--FILE-- + Date: Sun, 21 Apr 2013 14:32:02 +0700 Subject: Fix bug #64441 (FILTER_VALIDATE_URL rejects fully qualified domain names) (cherry picked from commit c149d4ee4be81ecf005eafd43ede06e70aa4c985) --- ext/filter/logical_filters.c | 4 ---- ext/filter/tests/bug64441.phpt | 11 +++++++++++ 2 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 ext/filter/tests/bug64441.phpt diff --git a/ext/filter/logical_filters.c b/ext/filter/logical_filters.c index 58d5870c11..c8f94a772c 100644 --- a/ext/filter/logical_filters.c +++ b/ext/filter/logical_filters.c @@ -484,10 +484,6 @@ void php_filter_validate_url(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */ } s++; } - - if (*(e - 1) == '.') { - goto bad_url; - } } if ( diff --git a/ext/filter/tests/bug64441.phpt b/ext/filter/tests/bug64441.phpt new file mode 100644 index 0000000000..149079ec05 --- /dev/null +++ b/ext/filter/tests/bug64441.phpt @@ -0,0 +1,11 @@ +--TEST-- +bug 64441, FILTER_VALIDATE_URL will invalidate a hostname that ended by dot +--SKIPIF-- + +--FILE-- + Date: Mon, 16 Sep 2013 05:21:42 +0200 Subject: NEWS for bug #64441 --- NEWS | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/NEWS b/NEWS index c7d5e030f3..67e31d044f 100644 --- a/NEWS +++ b/NEWS @@ -10,6 +10,10 @@ PHP NEWS . Fixed bug #64157 (DateTime::createFromFormat() reports confusing error message). (Boro Sitnikovski) +- Filter: + . Fixed bug #64441 (FILTER_VALIDATE_URL rejects fully qualified domain names). + (Syra) + ?? ??? 2013, PHP 5.4.20 - Core: -- cgit v1.2.1 From 6a0b90da84433ab1b0844a96036f3185d8a29cef Mon Sep 17 00:00:00 2001 From: David Soria Parra Date: Mon, 16 Sep 2013 16:23:29 +0200 Subject: NEWS for #60577 --- NEWS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/NEWS b/NEWS index 67e31d044f..b1280b376b 100644 --- a/NEWS +++ b/NEWS @@ -14,6 +14,9 @@ PHP NEWS . Fixed bug #64441 (FILTER_VALIDATE_URL rejects fully qualified domain names). (Syra) +- SPL: + . Fixed bug #60577 (count(new EmptyIterator) returns 1). (Levi Morrison) + ?? ??? 2013, PHP 5.4.20 - Core: -- cgit v1.2.1 From 7c279df6ae29d585021355559c07fa51f4373075 Mon Sep 17 00:00:00 2001 From: Sebastian Nohn Date: Sun, 15 Sep 2013 19:18:20 +0200 Subject: Add RFC 6598 IPs to reserved addresses (cherry picked from commit b3f5b822e9f83d99d7cb5eed36ba8d307d1408ee) --- ext/filter/logical_filters.c | 1 + ext/filter/tests/018.phpt | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/ext/filter/logical_filters.c b/ext/filter/logical_filters.c index c8f94a772c..71c5aba1e9 100644 --- a/ext/filter/logical_filters.c +++ b/ext/filter/logical_filters.c @@ -714,6 +714,7 @@ void php_filter_validate_ip(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */ if (flags & FILTER_FLAG_NO_RES_RANGE) { if ( (ip[0] == 0) || + (ip[0] == 100 && (ip[1] == 0 || ip[1] <= 127)) || (ip[0] == 128 && ip[1] == 0) || (ip[0] == 191 && ip[1] == 255) || (ip[0] == 169 && ip[1] == 254) || diff --git a/ext/filter/tests/018.phpt b/ext/filter/tests/018.phpt index af52b2e60d..9c73fc3cfc 100644 --- a/ext/filter/tests/018.phpt +++ b/ext/filter/tests/018.phpt @@ -15,6 +15,8 @@ var_dump(filter_var("192.168.0.1", FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE var_dump(filter_var("192.0.34.166", FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE)); var_dump(filter_var("127.0.0.1", FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE)); var_dump(filter_var("192.0.0.1", FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE)); +var_dump(filter_var("100.0.0.0", FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE)); +var_dump(filter_var("100.127.255.255", FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE)); var_dump(filter_var("192.0.34.166", FILTER_VALIDATE_IP)); var_dump(filter_var("256.1237.123.1", FILTER_VALIDATE_IP)); var_dump(filter_var("255.255.255.255", FILTER_VALIDATE_IP)); @@ -40,6 +42,8 @@ bool(false) string(12) "192.0.34.166" bool(false) string(9) "192.0.0.1" +bool(false) +bool(false) string(12) "192.0.34.166" bool(false) string(15) "255.255.255.255" -- cgit v1.2.1 From dfd7d1063a5292b04f6134284337550f4f513749 Mon Sep 17 00:00:00 2001 From: David Soria Parra Date: Tue, 17 Sep 2013 09:54:58 +0200 Subject: NEWS for added reserved ip addresses according to RFC 6598 --- NEWS | 1 + 1 file changed, 1 insertion(+) diff --git a/NEWS b/NEWS index b1280b376b..d8895bdfde 100644 --- a/NEWS +++ b/NEWS @@ -11,6 +11,7 @@ PHP NEWS message). (Boro Sitnikovski) - Filter: + . Add RFC 6598 IPs to reserved addresses. (Sebastian Nohn) . Fixed bug #64441 (FILTER_VALIDATE_URL rejects fully qualified domain names). (Syra) -- cgit v1.2.1 From 9bfd55cda3bd66b56af84a569fafd8a77cbb3726 Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Wed, 18 Sep 2013 11:10:55 +0200 Subject: fix a very rare case of use of uninitialized value combined with a memleak --- main/fopen_wrappers.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/main/fopen_wrappers.c b/main/fopen_wrappers.c index 6f11cf3f32..9b8645a061 100644 --- a/main/fopen_wrappers.c +++ b/main/fopen_wrappers.c @@ -775,7 +775,12 @@ PHPAPI char *expand_filepath_with_mode(const char *filepath, char *real_path, co * we cannot cannot getcwd() and the requested, * relatively referenced file is accessible */ copy_len = strlen(filepath) > MAXPATHLEN - 1 ? MAXPATHLEN - 1 : strlen(filepath); - real_path = estrndup(filepath, copy_len); + if (real_path) { + memcpy(real_path, filepath, copy_len); + real_path[copy_len] = '\0'; + } else { + real_path = estrndup(filepath, copy_len); + } close(fdtest); return real_path; } else { -- cgit v1.2.1 From 7e9044b6a251f40da1217c3265b83a9caae8bff8 Mon Sep 17 00:00:00 2001 From: David Soria Parra Date: Wed, 18 Sep 2013 14:26:10 +0200 Subject: RFC 6598 reserved ip range starts at 100.64.0.0 --- ext/filter/logical_filters.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/filter/logical_filters.c b/ext/filter/logical_filters.c index 71c5aba1e9..14964883c1 100644 --- a/ext/filter/logical_filters.c +++ b/ext/filter/logical_filters.c @@ -714,7 +714,7 @@ void php_filter_validate_ip(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */ if (flags & FILTER_FLAG_NO_RES_RANGE) { if ( (ip[0] == 0) || - (ip[0] == 100 && (ip[1] == 0 || ip[1] <= 127)) || + (ip[0] == 100 && (ip[1] >= 64 || ip[1] <= 127)) || (ip[0] == 128 && ip[1] == 0) || (ip[0] == 191 && ip[1] == 255) || (ip[0] == 169 && ip[1] == 254) || -- cgit v1.2.1 From 7a24ee13ec74bf3e85970e59dd69db8034ff434c Mon Sep 17 00:00:00 2001 From: David Soria Parra Date: Wed, 18 Sep 2013 15:06:19 +0200 Subject: Revert "EmptyIterator now implements Countable; fixes bug 60577" This reverts commit 8a936e8eb938965b0daaf076c109ec60141e57a7. --- NEWS | 3 --- ext/spl/internal/emptyiterator.inc | 13 ++----------- ext/spl/spl_iterators.c | 12 ------------ ext/spl/tests/bug60577.phpt | 8 -------- 4 files changed, 2 insertions(+), 34 deletions(-) delete mode 100644 ext/spl/tests/bug60577.phpt diff --git a/NEWS b/NEWS index d8895bdfde..6d94980fbc 100644 --- a/NEWS +++ b/NEWS @@ -15,9 +15,6 @@ PHP NEWS . Fixed bug #64441 (FILTER_VALIDATE_URL rejects fully qualified domain names). (Syra) -- SPL: - . Fixed bug #60577 (count(new EmptyIterator) returns 1). (Levi Morrison) - ?? ??? 2013, PHP 5.4.20 - Core: diff --git a/ext/spl/internal/emptyiterator.inc b/ext/spl/internal/emptyiterator.inc index d02b15b999..ac80e79581 100644 --- a/ext/spl/internal/emptyiterator.inc +++ b/ext/spl/internal/emptyiterator.inc @@ -15,7 +15,7 @@ * @version 1.0 * @since PHP 5.1 */ -class EmptyIterator implements Iterator, Countable +class EmptyIterator implements Iterator { /** No operation. * @return void @@ -57,15 +57,6 @@ class EmptyIterator implements Iterator, Countable { // nothing to do } - - /** - * @return int - */ - function count() - { - return 0; - } - } -?> +?> \ No newline at end of file diff --git a/ext/spl/spl_iterators.c b/ext/spl/spl_iterators.c index ad76258413..eb8247654e 100644 --- a/ext/spl/spl_iterators.c +++ b/ext/spl/spl_iterators.c @@ -3279,23 +3279,12 @@ SPL_METHOD(EmptyIterator, next) } } /* }}} */ -/* {{{ proto int EmptyIterator::count() - Does nothing */ -SPL_METHOD(EmptyIterator, count) -{ - if (zend_parse_parameters_none() == FAILURE) { - return; - } - RETURN_LONG(0); -} /* }}} */ - static const zend_function_entry spl_funcs_EmptyIterator[] = { SPL_ME(EmptyIterator, rewind, arginfo_recursive_it_void, ZEND_ACC_PUBLIC) SPL_ME(EmptyIterator, valid, arginfo_recursive_it_void, ZEND_ACC_PUBLIC) SPL_ME(EmptyIterator, key, arginfo_recursive_it_void, ZEND_ACC_PUBLIC) SPL_ME(EmptyIterator, current, arginfo_recursive_it_void, ZEND_ACC_PUBLIC) SPL_ME(EmptyIterator, next, arginfo_recursive_it_void, ZEND_ACC_PUBLIC) - SPL_ME(EmptyIterator, count, arginfo_recursive_it_void, ZEND_ACC_PUBLIC) PHP_FE_END }; @@ -3767,7 +3756,6 @@ PHP_MINIT_FUNCTION(spl_iterators) REGISTER_SPL_STD_CLASS_EX(EmptyIterator, NULL, spl_funcs_EmptyIterator); REGISTER_SPL_ITERATOR(EmptyIterator); - REGISTER_SPL_IMPLEMENTS(EmptyIterator, Countable); REGISTER_SPL_SUB_CLASS_EX(RecursiveTreeIterator, RecursiveIteratorIterator, spl_RecursiveTreeIterator_new, spl_funcs_RecursiveTreeIterator); REGISTER_SPL_CLASS_CONST_LONG(RecursiveTreeIterator, "BYPASS_CURRENT", RTIT_BYPASS_CURRENT); diff --git a/ext/spl/tests/bug60577.phpt b/ext/spl/tests/bug60577.phpt deleted file mode 100644 index 33fc133d0f..0000000000 --- a/ext/spl/tests/bug60577.phpt +++ /dev/null @@ -1,8 +0,0 @@ ---TEST-- -count(new EmptyIterator) should return zero ---FILE-- -