From 4b420dae109ee4ca511cbbba0c209ea5c30513b1 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Sat, 15 Oct 2016 10:17:16 +0200 Subject: PHP 5.5.38 with 15 security fix from 5.6.27 --- bug73073.patch | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 bug73073.patch (limited to 'bug73073.patch') diff --git a/bug73073.patch b/bug73073.patch new file mode 100644 index 0000000..7831362 --- /dev/null +++ b/bug73073.patch @@ -0,0 +1,72 @@ +Backported from 5.6.27 by Remi. + + +From 33a8af0510c5899cbf9148f53da08cf4f2df0013 Mon Sep 17 00:00:00 2001 +From: Stanislav Malyshev +Date: Tue, 20 Sep 2016 22:59:12 -0700 +Subject: [PATCH] Fix bug #73073 - CachingIterator null dereference when + convert to string + +--- + ext/spl/spl_iterators.c | 254 +++++++++++++++++++++++--------------------- + ext/spl/tests/bug73073.phpt | 9 ++ + 2 files changed, 141 insertions(+), 122 deletions(-) + create mode 100644 ext/spl/tests/bug73073.phpt + +diff --git a/ext/spl/spl_iterators.c b/ext/spl/spl_iterators.c +index a023b11..c6d03e0 100644 +--- a/ext/spl/spl_iterators.c ++++ b/ext/spl/spl_iterators.c +@@ -2784,15 +2784,25 @@ SPL_METHOD(CachingIterator, __toString) + + SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis()); + ++ if (!spl_caching_it_valid(intern TSRMLS_CC)) { ++ RETURN_EMPTY_STRING(); ++ } ++ + if (!(intern->u.caching.flags & (CIT_CALL_TOSTRING|CIT_TOSTRING_USE_KEY|CIT_TOSTRING_USE_CURRENT|CIT_TOSTRING_USE_INNER))) { + zend_throw_exception_ex(spl_ce_BadMethodCallException, 0 TSRMLS_CC, "%s does not fetch string value (see CachingIterator::__construct)", Z_OBJCE_P(getThis())->name); + return; + } + if (intern->u.caching.flags & CIT_TOSTRING_USE_KEY) { ++ if (!intern->current.key) { ++ RETURN_EMPTY_STRING(); ++ } + MAKE_COPY_ZVAL(&intern->current.key, return_value); + convert_to_string(return_value); + return; + } else if (intern->u.caching.flags & CIT_TOSTRING_USE_CURRENT) { ++ if (!intern->current.data) { ++ RETURN_EMPTY_STRING(); ++ } + MAKE_COPY_ZVAL(&intern->current.data, return_value); + convert_to_string(return_value); + return; +@@ -2800,7 +2810,7 @@ SPL_METHOD(CachingIterator, __toString) + if (intern->u.caching.zstr) { + RETURN_STRINGL(Z_STRVAL_P(intern->u.caching.zstr), Z_STRLEN_P(intern->u.caching.zstr), 1); + } else { +- RETURN_NULL(); ++ RETURN_EMPTY_STRING(); + } + } /* }}} */ + +diff --git a/ext/spl/tests/bug73073.phpt b/ext/spl/tests/bug73073.phpt +new file mode 100644 +index 0000000..218a28e +--- /dev/null ++++ b/ext/spl/tests/bug73073.phpt +@@ -0,0 +1,9 @@ ++--TEST-- ++Bug #73073: CachingIterator null dereference when convert to string ++--FILE-- ++ ++--EXPECT-- ++string(0) "" +-- +2.1.4 + -- cgit