Compare commits

...
79 Commits
Author SHA1 Message Date
Anatol Belski 89a97812aa set versions 2017-03-14 11:12:15 +01:00
Derick Rethans 387ea8b983 Make sure we anchor this test to February
(cherry picked from commit 61e9b7354f)
2017-03-02 22:13:05 +01:00
Mitch Hagstrand b6616f7e9c Fix bug73858.phpt to work in months without 31 days
Used hardcoded months in bug73858.phpt rather than the current and previous
month.

(cherry picked from commit 29333550d2)
2017-03-02 22:12:34 +01:00
Anatol Belski e60263d269 sync NEWS 2017-03-02 20:41:42 +01:00
Anatol Belski 511a4b0918 Revert "Fix bug #74159"
This reverts commit e9873d9853.
2017-03-02 20:40:41 +01:00
Anatol Belski 46a418f450 Revert "Update test for bug #74159"
This reverts commit ff8a6b1232.
2017-03-02 20:40:25 +01:00
Anatol Belski 7ac1122ff5 set versions 2017-02-28 09:32:27 +01:00
Joe Watkins c564924d31 Revert "fix crash in phpdbg shutdown process when opcache is loaded"
This reverts commit 008fb28eaf.
2017-02-27 19:21:10 +00:00
Joe Watkins 008fb28eaf fix crash in phpdbg shutdown process when opcache is loaded 2017-02-27 17:54:48 +00:00
Nikita Popov bbfa1b6419 Improve fix for bug #73807
At least on some architectures memmove() on FreeBSD does not
short-curcuit if src==dst. Check for it explicitly to avoid
quadratic copying.
2017-02-25 12:55:14 +01:00
Grundik eac8166bd4 Fix bug #73127
gost-crypto hash was incorrect if input data contained long 0xFF
sequence, due to a carry-propagation bug.
2017-02-24 23:20:49 +01:00
Anatol Belski 9450e23b32 Support run or test target invoked within debugger
Useful, as it gets all the environment produced by the makefile. For the
test target, it might make sense to have the child process debug plugin
for VS installed.
2017-02-24 19:37:16 +01:00
Aaron Piotrowski ff8a6b1232 Update test for bug #74159 2017-02-23 22:24:59 -06:00
Aaron Piotrowski cc10515056 Update NEWS 2017-02-23 21:10:14 -06:00
Aaron Piotrowski e9873d9853 Fix bug #74159
Thanks to @brzuchal for the patch to xp_ssl.c and @DaveRandom for helping debug the problem.
2017-02-23 20:59:43 -06:00
Xinchen Hui 330a7b62c3 Fixed bug #74152 (if statement says true to a null variable) 2017-02-23 12:33:17 +08:00
Xinchen Hui 1d4eead995 Fixed bug #74148 (ReflectionFunction incorrectly reports the number of arguments) 2017-02-23 11:02:23 +08:00
Remi Collet 015a80ef7b report about OpenSSL 1.1 not supported during configure 2017-02-22 08:39:07 +01:00
Coenraad Loubser 9eaf551c86 pull-request/2393:
stop make install from clobbering default dot d configuration
2017-02-22 06:47:23 +00:00
Dmitry Stogov 593a4d8fe9 too many dashes 2017-02-21 10:47:48 +03:00
Dmitry Stogov bd7e5c1548 Increase WSDL cache version (7.0 wsdl cache is incomatible with PHP-5)
Include WSDL cache version number into file name
2017-02-21 10:41:20 +03:00
Remi Collet c836ad1c7e fix test for libzip 1.2.0 2017-02-19 17:02:00 +01:00
Anatol Belski 1623ef10c9 initialize valid_symbol_table, important for the main thread
to prevent php_errormsg population on invalid symlol_table
2017-02-18 17:58:17 +01:00
Benjamin Robin 513582814b Fixed bug #74105
If getrandom syscall is unavailable (ENOSYS), try to fallback on
/dev/urandom.
2017-02-17 18:42:35 +01:00
Ondřej Surý 61e59db99d Disable RTLD_DEEPBIND when compiling with AddressSanitizer (-fsanitize=address).
The AddressSanitizer doesn't support RTLD_DEEPBIND resulting in
erratic errors when deinitializing phar module and possibly others.

Clang use __has_feature() macro to indicate compilation with
AddressSanitizer while gcc uses __SANITIZE_ADDRESS__ define.

Fixes bug #73677.
2017-02-16 17:35:29 +01:00
Nikita Popov cf3ef36323 Fix memory errors in url rewriter
Strings aren't terminated here...
2017-02-16 17:24:07 +01:00
Nikita Popov 708973c9bd Fix autoload_func_info destruction
Can't reference the function ptr after the closure has been
destroyed.
2017-02-16 16:59:17 +01:00
Mitch Hagstrand 3b91ed112f Make the ftp and stream tests more reliable.
The tests can sometimes fail because it chooses a passive port for ftp that
is already in use. This makes the test attempt multiple times to find a free
port.
2017-02-16 12:46:55 +01:00
Nikita Popov 5432d6f982 Add json dep to test 2017-02-16 12:45:24 +01:00
Anatol Belski e79754dee3 [ci skip] update NEWS 2017-02-15 16:33:49 +01:00
Anatol Belski 89a5bd6750 Fixed bug #74090 stream_get_contents maxlength>-1 returns empty string 2017-02-15 11:22:47 +01:00
Xinchen Hui 3917350531 Fixed bug #73989 (PHP 7.1 Segfaults within Symfony test suite) 2017-02-13 19:16:17 +08:00
Nikita Popov eb1373e509 Revert "Fixed bug #74035"
This reverts commit 9ffc6ca62f.
2017-02-12 22:02:39 +01:00
Derick Rethans f0519f4837 Upgrade timelib to 2017.01
This fixes:

- Fixed bug #72719 (Relative datetime format ignores weekday on sundays only).
- Fixed bug #73294 (DateTime wrong when date string is negative).
- Fixed bug #73489 (wrong timestamp when call setTimeZone multi times with UTC
  offset).
- Fixed bug #73858 (first/last day of' flag is not being reset).
- Fixed bug #73942 ($date->modify('Friday this week') doesn't return a Friday
  if $date is a Sunday).
- Fixed bug #74057 (wrong day when using "this week" in strtotime).
2017-02-12 20:17:01 +00:00
Xinchen Hui 26fdebc63b Fixed bug #74084 (Out of bound read - zend_mm_alloc_small) 2017-02-12 20:34:08 +08:00
andrewnester 01c1afa79f Fixed bug #74021 2017-02-12 12:48:18 +01:00
Xinchen Hui ee25eb0eae Fixed #73496 (Invalid memory access in zend_inline_hash_func)
no test script is added because it requre too much memory
2017-02-12 18:55:19 +08:00
Nikita Popov 981c58705a run-tests: Exit 1 on BORKED tests 2017-02-12 00:19:36 +01:00
Adam Saponara 7e5cf2aa19 Fixed bug #73118 2017-02-12 00:14:59 +01:00
Denis Yeldandi 9814be4bc2 Fixed bug #69860 2017-02-12 00:06:04 +01:00
Xinchen Hui db7c0badd4 Fixed typo 2017-02-11 00:01:09 +08:00
Xinchen Hui 185304a61e Fixed bug #74019 (Segfault with list) 2017-02-10 14:24:01 +08:00
Zheng SHAO 80c8d84af3 Fixed bug #61471 2017-02-08 01:10:13 +01:00
dreamsxin 7a0adb4cd2 Add #ifndef restrict 2017-02-08 01:00:35 +01:00
Christian Schmidt 714d825b62 Fix detection of isnan and isinf
The isnan() and isinf() are C99 macros not functions.

Also fix is_infinite(-INF) in case isinf is not defined.
2017-02-08 00:53:18 +01:00
Anatol Belski 044dd30440 use some dynamically generated NAN as well 2017-02-07 13:16:30 +01:00
Anatol Belski fd521a22f7 switch to smart str conversion routine to hide exact NAN type
see https://github.com/php/php-src/pull/2356#issuecomment-277564135
2017-02-07 12:01:14 +01:00
Nikita Popov 8a8aa67844 Revert "Fix detection of isnan and isinf"
This reverts commit 9ea0949f43.
2017-02-06 01:45:53 +01:00
Christian Schmidt 9ea0949f43 Fix detection of isnan and isinf
The isnan() and isinf() are C99 macros not functions.

Also fix is_infinite(-INF) in case isinf is not defined.
2017-02-05 18:09:04 +01:00
Andrea Faulds 21d7878690 Fix bug #73954 2017-02-05 01:30:20 +00:00
Nikita Popov dcaf4da8a6 Revert "Merge branch 'pull-request/2344' into PHP-7.0"
This reverts commit 6988d070ea, reversing
changes made to 75ad2b301a.
2017-02-03 18:42:10 +01:00
andrewnester 9ffc6ca62f Fixed bug #74035 2017-02-03 18:29:39 +01:00
Joe Watkins 6988d070ea Merge branch 'pull-request/2344' into PHP-7.0
* pull-request/2344:
  Fixed bug #74004 LIBXML_NOWARNING (etc) ignored by DOMDocument::loadHTML
2017-02-03 06:12:05 +00:00
somedaysummer 4df993d89d Fixed bug #74004 LIBXML_NOWARNING (etc) ignored by DOMDocument::loadHTML 2017-02-03 06:08:42 +00:00
Joe Watkins 75ad2b301a Merge branch 'pull-request/2359' into PHP-7.0
* pull-request/2359:
  increase wait time in timeout_variation_9.phpt by 1 second
2017-02-03 06:00:34 +00:00
Rodrigo Prado 0b56ba51d0 increase wait time in timeout_variation_9.phpt by 1 second 2017-02-03 05:57:26 +00:00
Joe Watkins 25271feeb0 Merge branch 'pull-request/2360' into PHP-7.0
* pull-request/2360:
  increase wait time in timeout_variation_10.phpt by 1 second
2017-02-03 05:54:50 +00:00
Rodrigo Prado 8faf5f979c increase wait time in timeout_variation_10.phpt by 1 second 2017-02-03 05:53:28 +00:00
Mitch Hagstrand dd9cf23457 BUG #73998: Numeric properties are not accessible from get_object_vars 2017-02-02 18:33:10 +01:00
Matěj Humpál acda2563ce Fix bug #74031
Fix incorrect parameter count for imagepng function
2017-02-02 18:13:53 +01:00
Nikita Popov a15bffd105 Fix bug #73807 2017-02-02 18:06:15 +01:00
Anatol Belski 570a273807 [ci skip] update NEWS 2017-02-02 14:19:35 +01:00
Anatol Belski 6fc0ae638a Fixed #74022 PHP Fast CGI crashes when reading from a pfx file. 2017-02-02 12:48:12 +01:00
Anatol Belski 1d7f8eb693 update NEWS 2017-02-02 01:33:41 +01:00
Anatol Belski 74c95fb3fb sync NEWS with the reverted stuff 2017-02-01 20:00:32 +01:00
Anatol Belski 3446e3b749 Revert "fixed bug #50989 (DOM support for LIBXML_NOXMLDECL)"
This reverts commit 2fcf1259c6.
2017-02-01 19:59:24 +01:00
Anatol Belski 69a2e4ece2 Revert "fix BC break introduced by #2346 (sebastianbergmann/phpunit#2454)"
This reverts commit 62938bf088.
2017-02-01 19:59:18 +01:00
Dmitry Stogov 3f89b630b4 typo 2017-02-01 17:36:55 +03:00
Dmitry Stogov 15e9aa1706 fixed macro 2017-02-01 16:05:33 +03:00
Anatol Belski 8dfa428ccd fix possible NULL dereference 2017-02-01 13:43:33 +01:00
Anatol Belski 15404bda13 remove unused var 2017-02-01 12:49:32 +01:00
Anatol Belski 2cd0d8b711 use zend_string API 2017-02-01 12:45:19 +01:00
Anatol Belski ec43a11581 Fixed bug #74005 mail.add_x_header causes RFC-breaking lone line feed 2017-02-01 12:36:14 +01:00
Anatol Belski d9ca5d9637 Merge branch 'PHP-5.6' into PHP-7.0
* PHP-5.6:
  fix test for 32bits (int -> float)
2017-02-01 11:59:44 +01:00
Remi Collet 0e21d8066b fix test for 32bits (int -> float)
(cherry picked from commit 0f1ae93bfa)
2017-02-01 11:49:52 +01:00
Remi Collet aa9742d80d fix test for 32bits (int -> float) 2017-02-01 10:25:30 +01:00
Anatol Belski 163bb87897 add a primitive debug facility to sendmail 2017-01-31 18:25:36 +01:00
Anatol Belski 5b5130c4ff Revert "backport 51e1da6ea1 into 7.0"
This reverts commit 8da8756312.
2017-01-31 14:21:20 +01:00
Anatol Belski 536b3ca1e1 bump versions for next in dev 2017-01-31 11:18:23 +01:00
76 changed files with 1347 additions and 653 deletions

No files matched your search

+1 -1
View File
@@ -53,7 +53,7 @@ install-headers:
paths="$$paths $(INSTALL_ROOT)$(phpincludedir)/$$i"; \
done; \
$(mkinstalldirs) $$paths && \
echo "Installing header files: $(INSTALL_ROOT)$(phpincludedir)/" && \
echo "Installing header files: $(INSTALL_ROOT)$(phpincludedir)/" && \
for i in `echo $(INSTALL_HEADERS)`; do \
if test "$(PHP_PECL_EXTENSION)"; then \
src=`echo $$i | $(SED) -e "s#ext/$(PHP_PECL_EXTENSION)/##g"`; \
+72 -2
View File
@@ -1,6 +1,77 @@
PHP NEWS
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
?? ??? 2017 PHP 7.0.16
16 Mar 2017 PHP 7.0.17
- Core:
. Fixed bug #73989 (PHP 7.1 Segfaults within Symfony test suite).
(Dmitry, Laruence)
. Fixed bug #74084 (Out of bound read - zend_mm_alloc_small). (Laruence)
. Fixed bug #73807 (Performance problem with processing large post request).
(Nikita)
. Fixed bug #73998 (array_key_exists fails on arrays created by
get_object_vars). (mhagstrand)
. Fixed bug #73954 (NAN check fails on Alpine Linux with musl). (Andrea)
. Fixed bug #74039 (is_infinite(-INF) returns false). (Christian Schmidt)
. Fixed bug #73677 (Generating phar.phar core dump with gcc ASAN enabled
build). (ondrej)
- Apache:
. Fixed bug #61471 (Incomplete POST does not timeout but is passed to PHP).
(Zheng Shao)
- Date:
. Fixed bug #72719 (Relative datetime format ignores weekday on sundays
only). (Derick)
. Fixed bug #73294 (DateTime wrong when date string is negative). (Derick)
. Fixed bug #73489 (wrong timestamp when call setTimeZone multi times with
UTC offset). (xiami, Derick)
. Fixed bug #73858 (first/last day of' flag is not being reset). (Derick)
. Fixed bug #73942 ($date->modify('Friday this week') doesn't return a Friday
if $date is a Sunday). (Derick)
. Fixed bug #74057 (wrong day when using "this week" in strtotime). (Derick)
- FPM:
. Fixed bug #69860 (php-fpm process accounting is broken with keepalive).
(Denis Yeldandi)
- Hash:
. Fixed bug #73127 (gost-crypto hash incorrect if input data contains long
0xFF sequence). (Grundik)
- GD:
. Fixed bug #74031 (ReflectionFunction for imagepng is missing last two
parameters). (finwe)
- Mysqlnd:
. Fixed bug #74021 (fetch_array broken data. Data more then MEDIUMBLOB).
(Andrew Nester, Nikita)
- Opcache:
. Fixed bug #74152 (if statement says true to a null variable). (Laruence)
. Fixed bug #74019 (Segfault with list). (Laruence)
- OpenSSL:
. Fixed bug #74022 (PHP Fast CGI crashes when reading from a pfx file).
(Anatol)
- Standard:
. Fixed bug #74148 (ReflectionFunction incorrectly reports the number of
arguments). (Laruence)
. Fixed bug #74005 (mail.add_x_header causes RFC-breaking lone line feed).
(Anatol)
. Fixed bug #73118 (is_callable callable name reports misleading value for
anonymous classes). (Adam Saponara)
. Fixed bug #74105 (PHP on Linux should use /dev/urandom when getrandom is
not available). (Benjamin Robin)
- Streams:
. Fixed bug #73496 (Invalid memory access in zend_inline_hash_func).
(Laruence)
. Fixed bug #74090 (stream_get_contents maxlength>-1 returns empty string).
(Anatol)
16 Feb 2017 PHP 7.0.16
- Core:
. Fixed bug #73916 (zend_print_flat_zval_r doesn't consider reference).
@@ -13,7 +84,6 @@ PHP NEWS
- DOM:
. Fixed bug #54382 (getAttributeNodeNS doesn't get xmlns* attributes).
(aboks)
. Fixed bug #50989 (support for LIBXML_NOXMLDECL). (jhdxr)
- DTrace:
. Fixed bug #73965 (DTrace reported as enabled when disabled). (Remi)
+1 -1
View File
@@ -100,7 +100,7 @@ AC_FUNC_ALLOCA
AC_CHECK_FUNCS(memcpy strdup getpid kill strtod strtol finite fpclass sigsetjmp)
AC_ZEND_BROKEN_SPRINTF
AC_CHECK_FUNCS(finite isfinite isinf isnan)
AC_CHECK_DECLS([isfinite, isnan, isinf], [], [], [[#include <math.h>]])
ZEND_FP_EXCEPT
+8 -8
View File
@@ -64,33 +64,33 @@ int zend_sprintf(char *buffer, const char *format, ...);
/* To enable the is_nan, is_infinite and is_finite PHP functions */
#ifdef NETWARE
#define HAVE_ISNAN 1
#define HAVE_ISINF 1
#define HAVE_ISFINITE 1
#define HAVE_DECL_ISNAN 1
#define HAVE_DECL_ISINF 1
#define HAVE_DECL_ISFINITE 1
#endif
#ifndef zend_isnan
#ifdef HAVE_ISNAN
#ifdef HAVE_DECL_ISNAN
#define zend_isnan(a) isnan(a)
#elif defined(HAVE_FPCLASS)
#define zend_isnan(a) ((fpclass(a) == FP_SNAN) || (fpclass(a) == FP_QNAN))
#else
#define zend_isnan(a) 0
#define zend_isnan(a) ((a) != (a))
#endif
#endif
#ifdef HAVE_ISINF
#ifdef HAVE_DECL_ISINF
#define zend_isinf(a) isinf(a)
#elif defined(INFINITY)
/* Might not work, but is required by ISO C99 */
#define zend_isinf(a) (((a)==INFINITY)?1:0)
#define zend_isinf(a) (((a)==INFINITY || (a)==-INFINITY)?1:0)
#elif defined(HAVE_FPCLASS)
#define zend_isinf(a) ((fpclass(a) == FP_PINF) || (fpclass(a) == FP_NINF))
#else
#define zend_isinf(a) 0
#endif
#if defined(HAVE_ISFINITE) || defined(isfinite)
#if defined(HAVE_DECL_ISFINITE)
#define zend_finite(a) isfinite(a)
#elif defined(HAVE_FINITE)
#define zend_finite(a) finite(a)
+23
View File
@@ -0,0 +1,23 @@
--TEST--
Bug #73954 (NAN check fails on Alpine Linux with musl)
--FILE--
<?php
var_dump(NAN);
var_dump(is_nan(NAN));
function takes_int(int $int) {
}
takes_int(log(tan(3.14)));
?>
--EXPECTF--
float(NAN)
bool(true)
Fatal error: Uncaught TypeError: Argument 1 passed to takes_int() must be of the type integer, float given, called in %s on line 9 and defined in %s:6
Stack trace:
#0 %s(9): takes_int(NAN)
#1 {main}
thrown in %s on line 6
+28
View File
@@ -0,0 +1,28 @@
--TEST--
Bug #73989 (PHP 7.1 Segfaults within Symfony test suite)
--FILE--
<?php
class Cycle
{
private $thing;
public function __construct()
{
$obj = $this;
$this->thing = function() use($obj) {};
}
public function __destruct()
{
($this->thing)();
}
}
for ($i = 0; $i < 10000; ++$i) {
$obj = new Cycle();
}
echo "OK\n";
?>
--EXPECT--
OK
+19
View File
@@ -0,0 +1,19 @@
--TEST--
Bug #73998 (array_key_exists fails on arrays created by get_object_vars)
--DESCRIPTION--
Properties of objects with numeric names should be accessible
--FILE--
<?php
$a = new stdClass;
$a->{1234} = "Numeric";
$a->a1234 = "String";
$properties = get_object_vars($a);
var_dump(array_key_exists(1234, $properties));
echo "Value: {$properties[1234]}\n";
?>
--EXPECT--
bool(true)
Value: Numeric
+19
View File
@@ -0,0 +1,19 @@
--TEST--
Bug #74084 (Out of bound read - zend_mm_alloc_small)
--INI--
error_reporting=0
--FILE--
<?php
$$A += $$B->a = &$$C;
unset($$A);
$$A -= $$B->a = &$$C;
unset($$A);
$$A *= $$B->a = &$$C;
unset($$A);
$$A /= $$B->a = &$$C;
unset($$A);
$$A **= $$B->a = &$$C;
var_dump($$A);
?>
--EXPECT--
int(1)
+1
View File
@@ -567,6 +567,7 @@ static void executor_globals_ctor(zend_executor_globals *executor_globals) /* {{
#ifdef ZEND_WIN32
zend_get_windows_version_info(&executor_globals->windows_version_info);
#endif
executor_globals->valid_symbol_table = 0;
}
/* }}} */
+14 -2
View File
@@ -1146,6 +1146,8 @@ ZEND_FUNCTION(get_object_vars)
HashTable *properties;
zend_string *key;
zend_object *zobj;
zend_ulong index;
zend_bool fast_copy = 0;
ZEND_PARSE_PARAMETERS_START(1, 1)
Z_PARAM_OBJECT(obj)
@@ -1164,7 +1166,17 @@ ZEND_FUNCTION(get_object_vars)
zobj = Z_OBJ_P(obj);
if (!zobj->ce->default_properties_count && properties == zobj->properties && !ZEND_HASH_GET_APPLY_COUNT(properties)) {
/* fast copy */
fast_copy = 1;
/* Check if the object has a numeric property, See Bug 73998 */
ZEND_HASH_FOREACH_STR_KEY(properties, key) {
if (key && ZEND_HANDLE_NUMERIC(key, index)) {
fast_copy = 0;
break;
}
} ZEND_HASH_FOREACH_END();
}
if (fast_copy) {
if (EXPECTED(zobj->handlers == &std_object_handlers)) {
if (EXPECTED(!(GC_FLAGS(properties) & IS_ARRAY_IMMUTABLE))) {
GC_REFCOUNT(properties)++;
@@ -1190,7 +1202,7 @@ ZEND_FUNCTION(get_object_vars)
zend_unmangle_property_name_ex(key, &class_name, &prop_name, &prop_len);
zend_hash_str_add_new(Z_ARRVAL_P(return_value), prop_name, prop_len, value);
} else {
zend_hash_add_new(Z_ARRVAL_P(return_value), key, value);
zend_symbtable_add_new(Z_ARRVAL_P(return_value), key, value);
}
}
}
+2 -2
View File
@@ -556,8 +556,8 @@ static void _build_trace_args(zval *arg, smart_str *str) /* {{{ */
break;
case IS_DOUBLE: {
double dval = Z_DVAL_P(arg);
char *s_tmp = emalloc(MAX_LENGTH_OF_DOUBLE + EG(precision) + 1);
int l_tmp = zend_sprintf(s_tmp, "%.*G", (int) EG(precision), dval); /* SAFE */
char *s_tmp;
size_t l_tmp = zend_spprintf(&s_tmp, MAX_LENGTH_OF_DOUBLE + EG(precision) + 1, "%.*G", (int) EG(precision), dval); /* SAFE */
smart_str_appendl(str, s_tmp, l_tmp);
smart_str_appends(str, ", ");
efree(s_tmp);
+71 -52
View File
@@ -25,26 +25,12 @@
/* one (0) is reserved */
#define GC_ROOT_BUFFER_MAX_ENTRIES 10001
#define GC_FAKE_BUFFER_FLAG 0x80
#define GC_TYPE_MASK 0x7f
#define GC_HAS_DESTRUCTORS (1<<0)
#ifndef ZEND_GC_DEBUG
# define ZEND_GC_DEBUG 0
#endif
#define GC_NUM_ADDITIONAL_ENTRIES \
((4096 - ZEND_MM_OVERHEAD - sizeof(void*) * 2) / sizeof(gc_root_buffer))
typedef struct _gc_addtional_bufer gc_additional_buffer;
struct _gc_addtional_bufer {
uint32_t used;
gc_additional_buffer *next;
gc_root_buffer buf[GC_NUM_ADDITIONAL_ENTRIES];
};
#ifdef ZTS
ZEND_API int gc_globals_id;
#else
@@ -53,9 +39,6 @@ ZEND_API zend_gc_globals gc_globals;
ZEND_API int (*gc_collect_cycles)(void);
#define GC_REMOVE_FROM_ROOTS(current) \
gc_remove_from_roots((current))
#if ZEND_GC_DEBUG > 1
# define GC_TRACE(format, ...) fprintf(stderr, format "\n", ##__VA_ARGS__);
# define GC_TRACE_REF(ref, format, ...) \
@@ -123,6 +106,12 @@ static zend_always_inline void gc_remove_from_roots(gc_root_buffer *root)
GC_BENCH_DEC(root_buf_length);
}
static zend_always_inline void gc_remove_from_additional_roots(gc_root_buffer *root)
{
root->next->prev = root->prev;
root->prev->next = root->next;
}
static void root_buffer_dtor(zend_gc_globals *gc_globals)
{
if (gc_globals->buf) {
@@ -149,6 +138,8 @@ static void gc_globals_ctor_ex(zend_gc_globals *gc_globals)
gc_globals->gc_runs = 0;
gc_globals->collected = 0;
gc_globals->additional_buffer = NULL;
#if GC_BENCH
gc_globals->root_buf_length = 0;
gc_globals->root_buf_peak = 0;
@@ -204,6 +195,8 @@ ZEND_API void gc_reset(void)
GC_G(first_unused) = NULL;
GC_G(last_unused) = NULL;
}
GC_G(additional_buffer) = NULL;
}
ZEND_API void gc_init(void)
@@ -276,21 +269,42 @@ ZEND_API void ZEND_FASTCALL gc_possible_root(zend_refcounted *ref)
GC_BENCH_PEAK(root_buf_peak, root_buf_length);
}
static zend_always_inline gc_root_buffer* gc_find_additional_buffer(zend_refcounted *ref)
{
gc_additional_buffer *additional_buffer = GC_G(additional_buffer);
/* We have to check each additional_buffer to find which one holds the ref */
while (additional_buffer) {
gc_root_buffer *root = additional_buffer->buf + (GC_ADDRESS(GC_INFO(ref)) - GC_ROOT_BUFFER_MAX_ENTRIES);
if (root->ref == ref) {
return root;
}
additional_buffer = additional_buffer->next;
}
ZEND_ASSERT(0);
return NULL;
}
ZEND_API void ZEND_FASTCALL gc_remove_from_buffer(zend_refcounted *ref)
{
gc_root_buffer *root;
ZEND_ASSERT(GC_ADDRESS(GC_INFO(ref)));
ZEND_ASSERT(GC_ADDRESS(GC_INFO(ref)) < GC_ROOT_BUFFER_MAX_ENTRIES);
GC_BENCH_INC(zval_remove_from_buffer);
root = GC_G(buf) + GC_ADDRESS(GC_INFO(ref));
if (EXPECTED(GC_ADDRESS(GC_INFO(ref)) < GC_ROOT_BUFFER_MAX_ENTRIES)) {
root = GC_G(buf) + GC_ADDRESS(GC_INFO(ref));
gc_remove_from_roots(root);
} else {
root = gc_find_additional_buffer(ref);
gc_remove_from_additional_roots(root);
}
if (GC_REF_GET_COLOR(ref) != GC_BLACK) {
GC_TRACE_SET_COLOR(ref, GC_PURPLE);
}
GC_INFO(ref) = 0;
GC_REMOVE_FROM_ROOTS(root);
/* updete next root that is going to be freed */
if (GC_G(next_to_free) == root) {
@@ -641,7 +655,7 @@ static void gc_scan_roots(void)
}
}
static void gc_add_garbage(zend_refcounted *ref, gc_additional_buffer **additional_buffer)
static void gc_add_garbage(zend_refcounted *ref)
{
gc_root_buffer *buf = GC_G(unused);
@@ -664,25 +678,23 @@ static void gc_add_garbage(zend_refcounted *ref, gc_additional_buffer **addition
#endif
} else {
/* If we don't have free slots in the buffer, allocate a new one and
* set it's address to GC_ROOT_BUFFER_MAX_ENTRIES that have special
* set it's address above GC_ROOT_BUFFER_MAX_ENTRIES that have special
* meaning.
*/
if (!*additional_buffer || (*additional_buffer)->used == GC_NUM_ADDITIONAL_ENTRIES) {
if (!GC_G(additional_buffer) || GC_G(additional_buffer)->used == GC_NUM_ADDITIONAL_ENTRIES) {
gc_additional_buffer *new_buffer = emalloc(sizeof(gc_additional_buffer));
new_buffer->used = 0;
new_buffer->next = *additional_buffer;
*additional_buffer = new_buffer;
new_buffer->next = GC_G(additional_buffer);
GC_G(additional_buffer) = new_buffer;
}
buf = (*additional_buffer)->buf + (*additional_buffer)->used;
(*additional_buffer)->used++;
buf = GC_G(additional_buffer)->buf + GC_G(additional_buffer)->used;
#if 1
/* optimization: color is already GC_BLACK (0) */
GC_INFO(ref) = GC_ROOT_BUFFER_MAX_ENTRIES;
GC_INFO(ref) = GC_ROOT_BUFFER_MAX_ENTRIES + GC_G(additional_buffer)->used;
#else
GC_REF_SET_ADDRESS(ref, GC_ROOT_BUFFER_MAX_ENTRIES);
GC_REF_SET_ADDRESS(ref, GC_ROOT_BUFFER_MAX_ENTRIES) + GC_G(additional_buffer)->used;
#endif
/* modify type to prevent indirect destruction */
GC_TYPE(ref) |= GC_FAKE_BUFFER_FLAG;
GC_G(additional_buffer)->used++;
}
if (buf) {
GC_REFCOUNT(ref)++;
@@ -694,7 +706,7 @@ static void gc_add_garbage(zend_refcounted *ref, gc_additional_buffer **addition
}
}
static int gc_collect_white(zend_refcounted *ref, uint32_t *flags, gc_additional_buffer **additional_buffer)
static int gc_collect_white(zend_refcounted *ref, uint32_t *flags)
{
int count = 0;
HashTable *ht;
@@ -727,7 +739,7 @@ tail_call:
#else
if (!GC_ADDRESS(GC_INFO(ref))) {
#endif
gc_add_garbage(ref, additional_buffer);
gc_add_garbage(ref);
}
if (obj->handlers->dtor_obj &&
((obj->handlers->dtor_obj != zend_objects_destroy_object) ||
@@ -751,7 +763,7 @@ tail_call:
if (Z_REFCOUNTED_P(zv)) {
ref = Z_COUNTED_P(zv);
GC_REFCOUNT(ref)++;
count += gc_collect_white(ref, flags, additional_buffer);
count += gc_collect_white(ref, flags);
/* count non-refcounted for compatibility ??? */
} else if (Z_TYPE_P(zv) != IS_UNDEF) {
count++;
@@ -773,7 +785,7 @@ tail_call:
#else
if (!GC_ADDRESS(GC_INFO(ref))) {
#endif
gc_add_garbage(ref, additional_buffer);
gc_add_garbage(ref);
}
ht = (zend_array*)ref;
} else if (GC_TYPE(ref) == IS_REFERENCE) {
@@ -813,7 +825,7 @@ tail_call:
if (Z_REFCOUNTED_P(zv)) {
ref = Z_COUNTED_P(zv);
GC_REFCOUNT(ref)++;
count += gc_collect_white(ref, flags, additional_buffer);
count += gc_collect_white(ref, flags);
/* count non-refcounted for compatibility ??? */
} else if (Z_TYPE_P(zv) != IS_UNDEF) {
count++;
@@ -831,7 +843,7 @@ tail_call:
return count;
}
static int gc_collect_roots(uint32_t *flags, gc_additional_buffer **additional_buffer)
static int gc_collect_roots(uint32_t *flags)
{
int count = 0;
gc_root_buffer *current = GC_G(roots).next;
@@ -840,8 +852,12 @@ static int gc_collect_roots(uint32_t *flags, gc_additional_buffer **additional_b
while (current != &GC_G(roots)) {
gc_root_buffer *next = current->next;
if (GC_REF_GET_COLOR(current->ref) == GC_BLACK) {
if (EXPECTED(GC_ADDRESS(GC_INFO(current->ref)) < GC_ROOT_BUFFER_MAX_ENTRIES)) {
gc_remove_from_roots(current);
} else {
gc_remove_from_additional_roots(current);
}
GC_INFO(current->ref) = 0; /* reset GC_ADDRESS() and keep GC_BLACK */
GC_REMOVE_FROM_ROOTS(current);
}
current = next;
}
@@ -850,7 +866,7 @@ static int gc_collect_roots(uint32_t *flags, gc_additional_buffer **additional_b
while (current != &GC_G(roots)) {
GC_REFCOUNT(current->ref)++;
if (GC_REF_GET_COLOR(current->ref) == GC_WHITE) {
count += gc_collect_white(current->ref, flags, additional_buffer);
count += gc_collect_white(current->ref, flags);
}
current = current->next;
}
@@ -886,13 +902,16 @@ static void gc_remove_nested_data_from_buffer(zend_refcounted *ref, gc_root_buff
tail_call:
if (root ||
(GC_ADDRESS(GC_INFO(ref)) != 0 &&
GC_REF_GET_COLOR(ref) == GC_BLACK &&
GC_ADDRESS(GC_INFO(ref)) != GC_ROOT_BUFFER_MAX_ENTRIES)) {
GC_REF_GET_COLOR(ref) == GC_BLACK)) {
GC_TRACE_REF(ref, "removing from buffer");
GC_REFCOUNT(ref)--;
if (root) {
if (EXPECTED(GC_ADDRESS(GC_INFO(root->ref)) < GC_ROOT_BUFFER_MAX_ENTRIES)) {
gc_remove_from_roots(root);
} else {
gc_remove_from_additional_roots(root);
}
GC_INFO(ref) = 0;
GC_REMOVE_FROM_ROOTS(root);
root = NULL;
} else {
GC_REMOVE_FROM_BUFFER(ref);
@@ -986,7 +1005,7 @@ ZEND_API int zend_gc_collect_cycles(void)
zend_refcounted *p;
gc_root_buffer to_free;
uint32_t gc_flags = 0;
gc_additional_buffer *additional_buffer;
gc_additional_buffer *additional_buffer_snapshot;
#if ZEND_GC_DEBUG
zend_bool orig_gc_full;
#endif
@@ -1010,8 +1029,8 @@ ZEND_API int zend_gc_collect_cycles(void)
#endif
GC_TRACE("Collecting roots");
additional_buffer = NULL;
count = gc_collect_roots(&gc_flags, &additional_buffer);
additional_buffer_snapshot = GC_G(additional_buffer);
count = gc_collect_roots(&gc_flags);
#if ZEND_GC_DEBUG
GC_G(gc_full) = orig_gc_full;
#endif
@@ -1055,7 +1074,7 @@ ZEND_API int zend_gc_collect_cycles(void)
while (current != &to_free) {
p = current->ref;
GC_G(next_to_free) = current->next;
if ((GC_TYPE(p) & GC_TYPE_MASK) == IS_OBJECT) {
if (GC_TYPE(p) == IS_OBJECT) {
zend_object *obj = (zend_object*)p;
if (IS_OBJ_VALID(EG(objects_store).object_buckets[obj->handle]) &&
@@ -1092,7 +1111,7 @@ ZEND_API int zend_gc_collect_cycles(void)
p = current->ref;
GC_G(next_to_free) = current->next;
GC_TRACE_REF(p, "destroying");
if ((GC_TYPE(p) & GC_TYPE_MASK) == IS_OBJECT) {
if (GC_TYPE(p) == IS_OBJECT) {
zend_object *obj = (zend_object*)p;
if (EG(objects_store).object_buckets &&
@@ -1111,7 +1130,7 @@ ZEND_API int zend_gc_collect_cycles(void)
EG(objects_store).free_list_head = obj->handle;
p = current->ref = (zend_refcounted*)(((char*)obj) - obj->handlers->offset);
}
} else if ((GC_TYPE(p) & GC_TYPE_MASK) == IS_ARRAY) {
} else if (GC_TYPE(p) == IS_ARRAY) {
zend_array *arr = (zend_array*)p;
GC_TYPE(arr) = IS_NULL;
@@ -1133,10 +1152,10 @@ ZEND_API int zend_gc_collect_cycles(void)
current = next;
}
while (additional_buffer != NULL) {
gc_additional_buffer *next = additional_buffer->next;
efree(additional_buffer);
additional_buffer = next;
while (GC_G(additional_buffer) != additional_buffer_snapshot) {
gc_additional_buffer *next = GC_G(additional_buffer)->next;
efree(GC_G(additional_buffer));
GC_G(additional_buffer) = next;
}
GC_TRACE("Collection finished");
+13
View File
@@ -67,6 +67,17 @@ typedef struct _gc_root_buffer {
uint32_t refcount;
} gc_root_buffer;
#define GC_NUM_ADDITIONAL_ENTRIES \
((4096 - ZEND_MM_OVERHEAD - sizeof(void*) * 2) / sizeof(gc_root_buffer))
typedef struct _gc_additional_bufer gc_additional_buffer;
struct _gc_additional_bufer {
uint32_t used;
gc_additional_buffer *next;
gc_root_buffer buf[GC_NUM_ADDITIONAL_ENTRIES];
};
typedef struct _zend_gc_globals {
zend_bool gc_enabled;
zend_bool gc_active;
@@ -93,6 +104,8 @@ typedef struct _zend_gc_globals {
uint32_t zval_marked_grey;
#endif
gc_additional_buffer *additional_buffer;
} zend_gc_globals;
#ifdef ZTS
+10
View File
@@ -310,6 +310,16 @@ static zend_always_inline int zend_hash_str_exists_ind(const HashTable *ht, cons
Z_TYPE_P(Z_INDIRECT_P(zv)) != IS_UNDEF);
}
static zend_always_inline zval *zend_symbtable_add_new(HashTable *ht, zend_string *key, zval *pData)
{
zend_ulong idx;
if (ZEND_HANDLE_NUMERIC(key, idx)) {
return zend_hash_index_add_new(ht, idx, pData);
} else {
return zend_hash_add_new(ht, key, pData);
}
}
static zend_always_inline zval *zend_symtable_update(HashTable *ht, zend_string *key, zval *pData)
{
+48 -19
View File
@@ -926,8 +926,13 @@ ZEND_API int ZEND_FASTCALL add_function(zval *result, zval *op1, zval *op2) /* {
} else if (!converted) {
ZEND_TRY_BINARY_OBJECT_OPERATION(ZEND_ADD, add_function);
zendi_convert_scalar_to_number(op1, op1_copy, result);
zendi_convert_scalar_to_number(op2, op2_copy, result);
if (EXPECTED(op1 != op2)) {
zendi_convert_scalar_to_number(op1, op1_copy, result);
zendi_convert_scalar_to_number(op2, op2_copy, result);
} else {
zendi_convert_scalar_to_number(op1, op1_copy, result);
op2 = op1;
}
converted = 1;
} else {
zend_throw_error(NULL, "Unsupported operand types");
@@ -979,8 +984,13 @@ ZEND_API int ZEND_FASTCALL sub_function(zval *result, zval *op1, zval *op2) /* {
} else if (!converted) {
ZEND_TRY_BINARY_OBJECT_OPERATION(ZEND_SUB, sub_function);
zendi_convert_scalar_to_number(op1, op1_copy, result);
zendi_convert_scalar_to_number(op2, op2_copy, result);
if (EXPECTED(op1 != op2)) {
zendi_convert_scalar_to_number(op1, op1_copy, result);
zendi_convert_scalar_to_number(op2, op2_copy, result);
} else {
zendi_convert_scalar_to_number(op1, op1_copy, result);
op2 = op1;
}
converted = 1;
} else {
zend_throw_error(NULL, "Unsupported operand types");
@@ -1026,8 +1036,13 @@ ZEND_API int ZEND_FASTCALL mul_function(zval *result, zval *op1, zval *op2) /* {
} else if (!converted) {
ZEND_TRY_BINARY_OBJECT_OPERATION(ZEND_MUL, mul_function);
zendi_convert_scalar_to_number(op1, op1_copy, result);
zendi_convert_scalar_to_number(op2, op2_copy, result);
if (EXPECTED(op1 != op2)) {
zendi_convert_scalar_to_number(op1, op1_copy, result);
zendi_convert_scalar_to_number(op2, op2_copy, result);
} else {
zendi_convert_scalar_to_number(op1, op1_copy, result);
op2 = op1;
}
converted = 1;
} else {
zend_throw_error(NULL, "Unsupported operand types");
@@ -1104,17 +1119,27 @@ ZEND_API int ZEND_FASTCALL pow_function(zval *result, zval *op1, zval *op2) /* {
} else if (!converted) {
ZEND_TRY_BINARY_OBJECT_OPERATION(ZEND_POW, pow_function);
if (Z_TYPE_P(op1) == IS_ARRAY) {
ZVAL_LONG(result, 0);
return SUCCESS;
if (EXPECTED(op1 != op2)) {
if (Z_TYPE_P(op1) == IS_ARRAY) {
ZVAL_LONG(result, 0);
return SUCCESS;
} else {
zendi_convert_scalar_to_number(op1, op1_copy, result);
}
if (Z_TYPE_P(op2) == IS_ARRAY) {
ZVAL_LONG(result, 1L);
return SUCCESS;
} else {
zendi_convert_scalar_to_number(op2, op2_copy, result);
}
} else {
zendi_convert_scalar_to_number(op1, op1_copy, result);
}
if (Z_TYPE_P(op2) == IS_ARRAY) {
ZVAL_LONG(result, 1L);
return SUCCESS;
} else {
zendi_convert_scalar_to_number(op2, op2_copy, result);
if (Z_TYPE_P(op1) == IS_ARRAY) {
ZVAL_LONG(result, 0);
return SUCCESS;
} else {
zendi_convert_scalar_to_number(op1, op1_copy, result);
}
op2 = op1;
}
converted = 1;
} else {
@@ -1178,9 +1203,13 @@ ZEND_API int ZEND_FASTCALL div_function(zval *result, zval *op1, zval *op2) /* {
op2 = Z_REFVAL_P(op2);
} else if (!converted) {
ZEND_TRY_BINARY_OBJECT_OPERATION(ZEND_DIV, div_function);
zendi_convert_scalar_to_number(op1, op1_copy, result);
zendi_convert_scalar_to_number(op2, op2_copy, result);
if (EXPECTED(op1 != op2)) {
zendi_convert_scalar_to_number(op1, op1_copy, result);
zendi_convert_scalar_to_number(op2, op2_copy, result);
} else {
zendi_convert_scalar_to_number(op1, op1_copy, result);
op2 = op1;
}
converted = 1;
} else {
zend_throw_error(NULL, "Unsupported operand types");
+13 -5
View File
@@ -131,6 +131,12 @@
#if defined(HAVE_LIBDL) && !defined(ZEND_WIN32)
# if defined(__has_feature)
# if __has_feature(address_sanitizer)
# define __SANITIZE_ADDRESS__
# endif
# endif
# ifndef RTLD_LAZY
# define RTLD_LAZY 1 /* Solaris 1, FreeBSD's (2.1.7.1 and older) */
# endif
@@ -141,7 +147,7 @@
# if defined(RTLD_GROUP) && defined(RTLD_WORLD) && defined(RTLD_PARENT)
# define DL_LOAD(libname) dlopen(libname, RTLD_LAZY | RTLD_GLOBAL | RTLD_GROUP | RTLD_WORLD | RTLD_PARENT)
# elif defined(RTLD_DEEPBIND)
# elif defined(RTLD_DEEPBIND) && !defined(__SANITIZE_ADDRESS__)
# define DL_LOAD(libname) dlopen(libname, RTLD_LAZY | RTLD_GLOBAL | RTLD_DEEPBIND)
# else
# define DL_LOAD(libname) dlopen(libname, RTLD_LAZY | RTLD_GLOBAL)
@@ -239,11 +245,13 @@ char *alloca();
# define ZEND_FASTCALL
#endif
#if defined(__GNUC__) && ZEND_GCC_VERSION >= 3004
#else
# define __restrict__
#ifndef restrict
# if defined(__GNUC__) && ZEND_GCC_VERSION >= 3004
# else
# define __restrict__
# endif
# define restrict __restrict__
#endif
#define restrict __restrict__
#if (defined(__GNUC__) && __GNUC__ >= 3 && !defined(__INTEL_COMPILER) && !defined(DARWIN) && !defined(__hpux) && !defined(_AIX) && !defined(__osf__)) || __has_attribute(noreturn)
# define HAVE_NORETURN
+4 -3
View File
@@ -912,9 +912,10 @@ static zend_always_inline uint32_t zval_delref_p(zval* pz) {
#define SEPARATE_STRING(zv) do { \
zval *_zv = (zv); \
if (Z_REFCOUNTED_P(_zv) && \
Z_REFCOUNT_P(_zv) > 1) { \
Z_DELREF_P(_zv); \
if (Z_REFCOUNT_P(_zv) > 1) { \
if (Z_REFCOUNTED_P(_zv)) { \
Z_DELREF_P(_zv); \
} \
zval_copy_ctor_func(_zv); \
} \
} while (0)
+1 -8
View File
@@ -899,12 +899,9 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i
int bufindex = 0, isabsolute = 0;
wchar_t * reparsetarget;
BOOL isVolume = FALSE;
#if VIRTUAL_CWD_DEBUG
char printname[MAX_PATH];
int printname_len;
#endif
char substitutename[MAX_PATH];
int substitutename_len;
int printname_len, substitutename_len;
int substitutename_off = 0;
if(++(*ll) > LINK_MAX) {
@@ -931,7 +928,6 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i
if(pbuffer->ReparseTag == IO_REPARSE_TAG_SYMLINK) {
reparsetarget = pbuffer->SymbolicLinkReparseBuffer.ReparseTarget;
#if VIRTUAL_CWD_DEBUG
printname_len = pbuffer->MountPointReparseBuffer.PrintNameLength / sizeof(WCHAR);
isabsolute = (pbuffer->SymbolicLinkReparseBuffer.Flags == 0) ? 1 : 0;
if (!WideCharToMultiByte(CP_THREAD_ACP, 0,
@@ -944,7 +940,6 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i
};
printname_len = pbuffer->MountPointReparseBuffer.PrintNameLength / sizeof(WCHAR);
printname[printname_len] = 0;
#endif
substitutename_len = pbuffer->MountPointReparseBuffer.SubstituteNameLength / sizeof(WCHAR);
if (!WideCharToMultiByte(CP_THREAD_ACP, 0,
@@ -960,7 +955,6 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i
else if(pbuffer->ReparseTag == IO_REPARSE_TAG_MOUNT_POINT) {
isabsolute = 1;
reparsetarget = pbuffer->MountPointReparseBuffer.ReparseTarget;
#if VIRTUAL_CWD_DEBUG
printname_len = pbuffer->MountPointReparseBuffer.PrintNameLength / sizeof(WCHAR);
if (!WideCharToMultiByte(CP_THREAD_ACP, 0,
reparsetarget + pbuffer->MountPointReparseBuffer.PrintNameOffset / sizeof(WCHAR),
@@ -971,7 +965,6 @@ static int tsrm_realpath_r(char *path, int start, int len, int *ll, time_t *t, i
return -1;
};
printname[pbuffer->MountPointReparseBuffer.PrintNameLength / sizeof(WCHAR)] = 0;
#endif
substitutename_len = pbuffer->MountPointReparseBuffer.SubstituteNameLength / sizeof(WCHAR);
if (!WideCharToMultiByte(CP_THREAD_ACP, 0,
+4 -2
View File
@@ -2337,13 +2337,15 @@ AC_DEFUN([PHP_SETUP_OPENSSL],[
dnl If pkg-config is found try using it
if test "$PHP_OPENSSL_DIR" = "yes" && test -x "$PKG_CONFIG" && $PKG_CONFIG --exists openssl; then
if $PKG_CONFIG --atleast-version=0.9.8 openssl; then
if $PKG_CONFIG --atleast-version=1.1 openssl; then
AC_MSG_ERROR([OpenSSL version >= 1.1 is not supported.])
elif $PKG_CONFIG --atleast-version=0.9.8 openssl; then
found_openssl=yes
OPENSSL_LIBS=`$PKG_CONFIG --libs openssl`
OPENSSL_INCS=`$PKG_CONFIG --cflags-only-I openssl`
OPENSSL_INCDIR=`$PKG_CONFIG --variable=includedir openssl`
else
AC_MSG_ERROR([OpenSSL version 0.9.8 or greater required.])
AC_MSG_ERROR([OpenSSL version >= 0.9.8 and < 1.1 required.])
fi
if test -n "$OPENSSL_LIBS"; then
+10 -10
View File
@@ -69,33 +69,33 @@ int zend_sprintf(char *buffer, const char *format, ...);
/* To enable the is_nan, is_infinite and is_finite PHP functions */
#ifdef NETWARE
#define HAVE_ISNAN 1
#define HAVE_ISINF 1
#define HAVE_ISFINITE 1
#define HAVE_DECL_ISNAN 1
#define HAVE_DECL_ISINF 1
#define HAVE_DECL_ISFINITE 1
#endif
#ifndef zend_isnan
#ifdef HAVE_ISNAN
#ifdef HAVE_DECL_ISNAN
#define zend_isnan(a) isnan(a)
#elif defined(HAVE_FPCLASS)
#define zend_isnan(a) ((fpclass(a) == FP_SNAN) || (fpclass(a) == FP_QNAN))
#else
#define zend_isnan(a) 0
#define zend_isnan(a) ((a) != (a))
#endif
#endif
#ifdef HAVE_ISINF
#ifdef HAVE_DECL_ISINF
#define zend_isinf(a) isinf(a)
#elif defined(INFINITY)
/* Might not work, but is required by ISO C99 */
#define zend_isinf(a) (((a)==INFINITY)?1:0)
#define zend_isinf(a) (((a)==INFINITY || (a)==-INFINITY)?1:0)
#elif defined(HAVE_FPCLASS)
#define zend_isinf(a) ((fpclass(a) == FP_PINF) || (fpclass(a) == FP_NINF))
#else
#define zend_isinf(a) 0
#endif
#if defined(HAVE_ISFINITE) || defined(isfinite)
#if defined(HAVE_DECL_ISFINITE)
#define zend_finite(a) isfinite(a)
#elif defined(HAVE_FINITE)
#define zend_finite(a) finite(a)
@@ -119,8 +119,8 @@ int zend_sprintf(char *buffer, const char *format, ...);
PHP_MAJOR_VERSION=7
PHP_MINOR_VERSION=0
PHP_RELEASE_VERSION=16
PHP_EXTRA_VERSION="-dev"
PHP_RELEASE_VERSION=17
PHP_EXTRA_VERSION=""
PHP_VERSION="$PHP_MAJOR_VERSION.$PHP_MINOR_VERSION.$PHP_RELEASE_VERSION$PHP_EXTRA_VERSION"
PHP_VERSION_ID=`expr [$]PHP_MAJOR_VERSION \* 10000 + [$]PHP_MINOR_VERSION \* 100 + [$]PHP_RELEASE_VERSION`
+3 -3
View File
@@ -154,7 +154,7 @@ static void do_adjust_for_weekday(timelib_time* time)
{
/* To make "this week" work, where the current DOW is a "sunday" */
if (current_dow == 0 && time->relative.weekday != 0) {
time->relative.weekday = -6;
time->relative.weekday -= 7;
}
/* To make "sunday this week" work, where the current DOW is not a
@@ -354,7 +354,7 @@ static timelib_sll do_years(timelib_sll year)
return res;
}
static timelib_sll do_months(timelib_ull month, timelib_ull year)
static timelib_sll do_months(timelib_ull month, timelib_sll year)
{
if (timelib_is_leap(year)) {
return ((month_tab_leap[month - 1] + 1) * SECS_PER_DAY);
@@ -463,7 +463,7 @@ void timelib_update_ts(timelib_time* time, timelib_tzinfo* tzi)
time->sse = res;
time->sse_uptodate = 1;
time->have_relative = time->relative.have_weekday_relative = time->relative.have_special_relative = 0;
time->have_relative = time->relative.have_weekday_relative = time->relative.have_special_relative = time->relative.first_last_day_of = 0;
}
#if 0
+1
View File
@@ -189,6 +189,7 @@ void timelib_unixtime2local(timelib_time *tm, timelib_sll ts)
timelib_unixtime2gmt(tm, ts - (tm->z * 60) + (tm->dst * 3600));
tm->sse = ts;
tm->z = z;
tm->dst = dst;
break;
+20
View File
@@ -0,0 +1,20 @@
--TEST--
Bug #72719: Relative datetime format ignores weekday on sundays only
--FILE--
<?php
echo (new DateTimeImmutable('Monday next week 13:00'))->format('l'), "\n";
echo (new DateTimeImmutable('Tuesday next week 14:00'))->format('l'), "\n";
echo (new DateTimeImmutable('Wednesday next week 14:00'))->format('l'), "\n";
echo (new DateTimeImmutable('Thursday next week 15:00'))->format('l'), "\n";
echo (new DateTimeImmutable('Friday next week 16:00'))->format('l'), "\n";
echo (new DateTimeImmutable('Saturday next week 17:00'))->format('l'), "\n";
echo (new DateTimeImmutable('Sunday next week 18:00'))->format('l'), "\n";
?>
--EXPECT--
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
Sunday
+22
View File
@@ -0,0 +1,22 @@
--TEST--
Bug #73294: DateTime wrong when date string is negative
--FILE--
<?php
for ( $i = -1050; $i <= -1000; $i++ )
{
$M = "06";
$D = "22";
$dt = new DateTime("{$i}-{$M}-{$D} 00:00:00");
$expected = "{$i}-{$M}-{$D} 00:00:00";
$result = $dt->format('Y-m-d H:i:s');
if ( $expected != $result )
{
echo "Wrong: Should have been {$expected}, was {$result}\n";
}
}
?>
==DONE==
--EXPECT--
==DONE==
+24
View File
@@ -0,0 +1,24 @@
--TEST--
Bug #73489: wrong timestamp when call setTimeZone multi times with UTC offset
--FILE--
<?php
// example 1 - Timestamp is changing
$datetime = new DateTime('2016-11-09 20:00:00', new DateTimeZone('UTC'));
var_dump($datetime->getTimestamp());
$datetime->setTimeZone(new DateTimeZone('-03:00'));
$datetime->setTimeZone(new DateTimeZone('-03:00'));
var_dump($datetime->getTimestamp());
// example 2 - Timestamp keeps if you use getTimestamp() before second setTimeZone() calls
$datetime = new DateTime('2016-11-09 20:00:00', new DateTimeZone('UTC'));
var_dump($datetime->getTimestamp());
$datetime->setTimeZone(new DateTimeZone('-03:00'));
$datetime->getTimestamp();
$datetime->setTimeZone(new DateTimeZone('-03:00'));
var_dump($datetime->getTimestamp());
?>
--EXPECT--
int(1478721600)
int(1478721600)
int(1478721600)
int(1478721600)
+63
View File
@@ -0,0 +1,63 @@
--TEST--
Bug #73858: diff() of two relative/described DateTimes is wrong
--FILE--
<?php
/*
In the "verbose setup method" I'm trying setup the DateTime object myself
to see if it's the format string which is parsed in correctly or if it's the DateTime
object which is breaking stuff. From the testing it appears DateTime is broken somehow.
*/
$ss = 'february first day of last month midnight';
$es = 'february first day of this month midnight - 1 second';
$s = new DateTime($ss);
$e = new DateTime($es);
$d= $e->diff($s);
var_dump($d->days); // 0 ... but should be 30
$s = (new DateTime(null))->setTimestamp(strtotime($ss)); // verbose setup method
$e = (new DateTime(null))->setTimestamp(strtotime($es)); // verbose setup method
$d = $e->diff($s);
var_dump($d->days); // 30 ... and should be 30
/*
Next we will try mix/match the code to see what happens, surprisingly it seems that the end date ($e)
is the important one, if it uses the verbose method it returns the correct values.
*/
$s = (new DateTime(null))->setTimestamp(strtotime($ss)); // verbose setup method
$e = new DateTime($es);
$d= $e->diff($s);
var_dump($d->days); // 0 ... but should be 30
$s = new DateTime($ss);
$e = (new DateTime(null))->setTimestamp(strtotime($es)); // verbose setup method
$d= $e->diff($s);
var_dump($d->days); // 30 ... and should be 30
/*
This test just proves that the $e date is important BUT NOT because it's the one we call the diff() method
on, that's just coincidental that seems to imply that the "- 1 second" in the date string is the problem.
*/
$s = new DateTime($ss);
$e = (new DateTime(null))->setTimestamp(strtotime($es)); // verbose setup method
$d= $s->diff($e);
var_dump($d->days); // 30 ... and should be 30
/*
[Workaround]
This final test seems to prove that the input string is important and that the "- 1 secord" has a negative knock-on
effect on the results of the diff. By modifying the datetime with ->modify everything works as expected ...
it just means you have to be careful of how we work with DateTimes .
*/
$s = new DateTime($ss);
$e = new DateTime('february first day of this month midnight');
$e->modify('- 1 second');
var_dump($e->diff($s)->days); // 30 ... and should be 30
?>
--EXPECT--
int(30)
int(30)
int(30)
int(30)
int(30)
int(30)
+12
View File
@@ -0,0 +1,12 @@
--TEST--
Bug #73942: $date->modify('Friday this week') doesn't return a Friday if $date is a Sunday
--FILE--
<?php
$date1 = "2017-01-08"; // this is a Sunday
$date = new \DateTime($date1);
$date->modify('Friday this week');
$dateFormat = $date->format('Y-m-d');
echo $dateFormat, "\n";
?>
--EXPECT--
2017-01-06
+24
View File
@@ -0,0 +1,24 @@
--TEST--
Bug #74057: wrong day when using "this week" in strtotime
--FILE--
<?php
echo date("D Y-m-d", strtotime("saturday this week", strtotime("Sun 2017-01-01")))."\n";
echo date("D Y-m-d", strtotime("saturday this week", strtotime("Mon 2017-01-02")))."\n";
echo date("D Y-m-d", strtotime("saturday this week", strtotime("Tue 2017-01-03")))."\n";
echo date("D Y-m-d", strtotime("saturday this week", strtotime("Wed 2017-01-04")))."\n";
echo date("D Y-m-d", strtotime("saturday this week", strtotime("Thu 2017-01-05")))."\n";
echo date("D Y-m-d", strtotime("saturday this week", strtotime("Fri 2017-01-06")))."\n";
echo date("D Y-m-d", strtotime("saturday this week", strtotime("Sat 2017-01-07")))."\n";
echo date("D Y-m-d", strtotime("saturday this week", strtotime("Sun 2017-01-08")))."\n";
echo date("D Y-m-d", strtotime("saturday this week", strtotime("Mon 2017-01-09")))."\n";
?>
--EXPECT--
Sat 2016-12-31
Sat 2017-01-07
Sat 2017-01-07
Sat 2017-01-07
Sat 2017-01-07
Sat 2017-01-07
Sat 2017-01-07
Sat 2017-01-07
Sat 2017-01-14
+33 -29
View File
@@ -26,7 +26,6 @@
#include "php.h"
#if HAVE_LIBXML && HAVE_DOM
#include "php_dom.h"
#include <libxml/xmlsave.h>
#include <libxml/SAX.h>
#ifdef LIBXML_SCHEMAS_ENABLED
#include <libxml/relaxng.h>
@@ -1617,54 +1616,59 @@ PHP_FUNCTION(dom_document_savexml)
dom_doc_propsptr doc_props;
int size, format, saveempty = 0;
zend_long options = 0;
xmlSaveCtxtPtr xscp;
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O|O!l", &id, dom_document_class_entry, &nodep, dom_node_class_entry, &options) == FAILURE) {
return;
}
options = options | XML_SAVE_AS_XML;
DOM_GET_OBJ(docp, id, xmlDocPtr, intern);
doc_props = dom_get_doc_props(intern->document);
format = doc_props->formatoutput;
if (format) {
options = options | XML_SAVE_FORMAT;
}
buf = xmlBufferCreate();
if (!buf) {
php_error_docref(NULL, E_WARNING, "Could not fetch buffer");
RETURN_FALSE;
}
xscp = xmlSaveToBuffer(buf, docp->encoding, options);
if (nodep != NULL) {
/* Dump contents of Node */
DOM_GET_OBJ(node, nodep, xmlNodePtr, nodeobj);
if (node->doc != docp) {
php_dom_throw_error(WRONG_DOCUMENT_ERR, dom_get_strict_error(intern->document));
RETURN_FALSE;
}
buf = xmlBufferCreate();
if (!buf) {
php_error_docref(NULL, E_WARNING, "Could not fetch buffer");
RETURN_FALSE;
}
if (options & LIBXML_SAVE_NOEMPTYTAG) {
saveempty = xmlSaveNoEmptyTags;
xmlSaveNoEmptyTags = 1;
}
xmlNodeDump(buf, docp, node, 0, format);
if (options & LIBXML_SAVE_NOEMPTYTAG) {
xmlSaveNoEmptyTags = saveempty;
}
mem = (xmlChar*) xmlBufferContent(buf);
if (!mem) {
xmlBufferFree(buf);
RETURN_FALSE;
}
if(xmlSaveTree(xscp, node) < 0) {
xmlBufferFree(buf);
RETURN_FALSE;
}
} else {
if(xmlSaveDoc(xscp, docp) < 0) {
xmlBufferFree(buf);
RETURN_FALSE;
}
}
xmlSaveClose(xscp);
mem = (xmlChar*) xmlBufferContent(buf);
if (!mem) {
RETVAL_STRING((char *) mem);
xmlBufferFree(buf);
RETURN_FALSE;
} else {
if (options & LIBXML_SAVE_NOEMPTYTAG) {
saveempty = xmlSaveNoEmptyTags;
xmlSaveNoEmptyTags = 1;
}
/* Encoding is handled from the encoding property set on the document */
xmlDocDumpFormatMemory(docp, &mem, &size, format);
if (options & LIBXML_SAVE_NOEMPTYTAG) {
xmlSaveNoEmptyTags = saveempty;
}
if (!size || !mem) {
RETURN_FALSE;
}
RETVAL_STRINGL((char *) mem, size);
xmlFree(mem);
}
RETVAL_STRING((char *) mem);
xmlBufferFree(buf);
}
/* }}} end dom_document_savexml */
@@ -1,33 +0,0 @@
--TEST--
DOM Document: saveXML with createElement and formatOutput
--CREDITS--
CHU Zhaowei <jhdxr@php.net>
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--FILE--
<?php
$dom = new domDocument('1.0', 'UTF-8');
$dom->formatOutput = true;
$root = $dom->createElement('root');
$dom->appendChild($root);
$child1 = $dom->createElement('testsuite');
$root->appendChild($child1);
$child11 = $dom->createElement('testcase');
$child11->setAttribute('name', 'leaf1');
$child12 = $dom->createElement('testcase');
$child12->setAttribute('name', 'leaf2');
$child1->appendChild($child11);
$child1->appendChild($child12);
echo $dom->saveXml();
--EXPECT--
<?xml version="1.0" encoding="UTF-8"?>
<root>
<testsuite>
<testcase name="leaf1"/>
<testcase name="leaf2"/>
</testsuite>
</root>
-12
View File
@@ -1,12 +0,0 @@
--TEST--
Bug #50989 add support LIBXML_NOXMLDECL for DOMDocument::saveXML()
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--FILE--
<?php
$dom = new DomDocument();
$dom->loadXML("<foo />");
print $dom->saveXML(null,LIBXML_NOXMLDECL);
--EXPECT--
<foo/>
+23 -9
View File
@@ -6,8 +6,8 @@ $context = stream_context_create(array('ssl' => array('local_cert' => dirname(__
for ($i=0; $i<10 && !$socket; ++$i) {
$port = rand(50000, 65535);
@$socket = stream_socket_server("tcp://127.0.0.1:$port", $errno, $errstr, STREAM_SERVER_BIND|STREAM_SERVER_LISTEN, $context);
$socket = @stream_socket_server("tcp://127.0.0.1:$port", $errno, $errstr, STREAM_SERVER_BIND|STREAM_SERVER_LISTEN, $context);
}
//set anther random port that is not the same as $port
do{
@@ -402,20 +402,34 @@ if ($pid) {
}elseif (preg_match('/^PASV/', $buf, $matches)) {
$pasv=true;
$p2 = $pasv_port % ((int) 1 << 8);
$p1 = ($pasv_port-$p2)/((int) 1 << 8);
$host = "127.0.0.1";
if (!empty($ssl)) {
$soc = stream_socket_server("tcp://127.0.0.1:$pasv_port", $errno, $errstr, STREAM_SERVER_BIND|STREAM_SERVER_LISTEN, $context);
} else {
$soc = stream_socket_server("tcp://127.0.0.1:$pasv_port");
$i=0;
do {
if (!empty($ssl)) {
$soc = @stream_socket_server("tcp://127.0.0.1:$pasv_port", $errno, $errstr, STREAM_SERVER_BIND|STREAM_SERVER_LISTEN, $context);
} else {
$soc = @stream_socket_server("tcp://127.0.0.1:$pasv_port");
}
/* Could bind port, Try another port */
if (!$soc) {
$pasv_port = rand(50000, 65535);
}
$i++;
} while ($i<10 && !$soc);
if (!$soc) {
echo "$errstr ($errno)\n";
die("could not bind passive port\n");
}
$p2 = $pasv_port % ((int) 1 << 8);
$p1 = ($pasv_port-$p2)/((int) 1 << 8);
fputs($s, "227 Entering Passive Mode. (127,0,0,1,{$p1},{$p2})\r\n");
$pasvs = stream_socket_accept($soc,10);
}elseif (preg_match('/^EPSV/', $buf, $matches)) {
} elseif (preg_match('/^EPSV/', $buf, $matches)) {
fputs($s, "550 Extended passsive mode not supported.\r\n");
} elseif (preg_match('/^SITE EXEC/', $buf, $matches)) {
fputs($s, "200 OK\r\n");
+2
View File
@@ -368,6 +368,8 @@ ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_imagepng, 0, 0, 1)
ZEND_ARG_INFO(0, im)
ZEND_ARG_INFO(0, filename)
ZEND_ARG_INFO(0, quality)
ZEND_ARG_INFO(0, filters)
ZEND_END_ARG_INFO()
#endif
+10
View File
@@ -0,0 +1,10 @@
--TEST--
(Bug #74031) ReflectionFunction for imagepng returns wrong number of parameters
--FILE--
<?php
$ref = new ReflectionFunction('imagepng');
var_dump(count($ref->getParameters()));
?>
--EXPECT--
int(4)
+2 -3
View File
@@ -227,14 +227,13 @@ static inline void Gost(PHP_GOST_CTX *context, php_hash_uint32 data[8])
static inline void GostTransform(PHP_GOST_CTX *context, const unsigned char input[32])
{
int i, j;
php_hash_uint32 data[8], temp = 0, save = 0;
php_hash_uint32 data[8], temp = 0;
for (i = 0, j = 0; i < 8; ++i, j += 4) {
data[i] = ((php_hash_uint32) input[j]) | (((php_hash_uint32) input[j + 1]) << 8) |
(((php_hash_uint32) input[j + 2]) << 16) | (((php_hash_uint32) input[j + 3]) << 24);
save = context->state[i + 8];
context->state[i + 8] += data[i] + temp;
temp = ((context->state[i + 8] < data[i]) || (context->state[i + 8] < save)) ? 1 : 0;
temp = context->state[i + 8] < data[i] ? 1 : (context->state[i + 8] == data[i] ? temp : 0);
}
Gost(context, data);
+27
View File
@@ -0,0 +1,27 @@
--TEST--
Bug #73127 (gost-crypto hash incorrect if input data contains long 0xFF sequence)
--FILE--
<?php // $Id$
$test1 = str_repeat("\xFF", 40);
$test2 = str_repeat("\x00", 40);
echo hash('gost-crypto', $test1),
"\n",
hash('gost', $test1),
"\n",
hash('gost-crypto', $test2),
"\n",
hash('gost', $test2),
"\n",
hash('gost-crypto', ''),
"\n",
hash('gost', '')
;
?>
--EXPECT--
231d8bb980d3faa30fee6ec475df5669cf6c24bbce22f46d6737470043a99f8e
9eaf96ba62f90fae6707f1d4274d1a9d6680f5a121d4387815aa3a6ec42439c5
bbf1f3179409c853cd3e396d67b0e10a266c218a4fd19f149c39aa4f6d37a007
a0be0b90fea5a5b50c90c9429d07bb98fa0c06f0c30210e94c7d80c3125c67ac
981e5f3ca30c841487830f84fb433e13ac1101569b9c13584ac483234cd656c0
ce85b99cc46752fffee35cab9a7b0278abb4c2d2055cff685af4912c49490f8d
+27
View File
@@ -0,0 +1,27 @@
--TEST--
Bug #73800 (sporadic segfault with MYSQLI_OPT_INT_AND_FLOAT_NATIVE)
--SKIPIF--
<?php
require_once('skipif.inc');
require_once('skipifconnectfailure.inc');
if (PHP_INT_SIZE != 8) die('skip requires 64-bit');
?>
--FILE--
<?php
require_once("connect.inc");
$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
$link->query('SET @@global.max_allowed_packet = 67108864');
$link->close();
$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
$link->options(MYSQLI_OPT_INT_AND_FLOAT_NATIVE, 1);
$res = $link->query("SELECT RPAD('1',9000000,'1') as a,RPAD('1',9000000,'1') as b, 9223372036854775807 as c");
$r = $res->fetch_array();
var_dump($r['c']);
?>
--EXPECT--
int(9223372036854775807)
+25
View File
@@ -0,0 +1,25 @@
--TEST--
Bug #74021 (fetch_array broken data. Data more then MEDIUMBLOB)
--SKIPIF--
<?php
require_once('skipif.inc');
require_once('skipifconnectfailure.inc');
?>
--FILE--
<?php
require_once("connect.inc");
$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
$link->query('SET @@global.max_allowed_packet = 67108864');
$link->close();
$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
$res = $link->query("SELECT RPAD('1',9000000,'1') as a,RPAD('1',9000000,'1') as b");
$r = $res->fetch_array();
var_dump(md5($r['a']));
var_dump(md5($r['b']));
?>
--EXPECT--
string(32) "42ca0fd16ab6b6d4b9d47dc0a4a8b12a"
string(32) "42ca0fd16ab6b6d4b9d47dc0a4a8b12a"
+4 -4
View File
@@ -1458,7 +1458,7 @@ php_mysqlnd_read_row_ex(MYSQLND_CONN_DATA * conn, MYSQLND_MEMORY_POOL * result_s
zero-length byte, don't read the body, there is no such.
*/
*data_size = prealloc_more_bytes;
*data_size = 0;
while (1) {
if (FAIL == mysqlnd_read_header(conn->net, &header, conn->stats, conn->error_info)) {
ret = FAIL;
@@ -1469,7 +1469,8 @@ php_mysqlnd_read_row_ex(MYSQLND_CONN_DATA * conn, MYSQLND_MEMORY_POOL * result_s
if (first_iteration) {
first_iteration = FALSE;
*buffer = result_set_memory_pool->get_chunk(result_set_memory_pool, *data_size);
*buffer = result_set_memory_pool->get_chunk(
result_set_memory_pool, *data_size + prealloc_more_bytes);
if (!*buffer) {
ret = FAIL;
break;
@@ -1484,7 +1485,7 @@ php_mysqlnd_read_row_ex(MYSQLND_CONN_DATA * conn, MYSQLND_MEMORY_POOL * result_s
/*
We have to realloc the buffer.
*/
if (FAIL == (*buffer)->resize_chunk((*buffer), *data_size)) {
if (FAIL == (*buffer)->resize_chunk((*buffer), *data_size + prealloc_more_bytes)) {
SET_OOM_ERROR(*conn->error_info);
ret = FAIL;
break;
@@ -1507,7 +1508,6 @@ php_mysqlnd_read_row_ex(MYSQLND_CONN_DATA * conn, MYSQLND_MEMORY_POOL * result_s
(*buffer)->free_chunk((*buffer));
*buffer = NULL;
}
*data_size -= prealloc_more_bytes;
DBG_RETURN(ret);
}
/* }}} */
+12 -2
View File
@@ -561,6 +561,17 @@ static void zend_rebuild_access_path(zend_cfg *cfg, zend_op_array *op_array, int
convert_to_string((v)); \
}
static int is_predecessor_smart_branch(zend_op *start, zend_op *predecessor) {
do {
if (predecessor == start) {
return 0;
}
predecessor--;
} while (predecessor->opcode == ZEND_NOP);
return zend_is_smart_branch(predecessor);
}
static void strip_nop(zend_code_block *block, zend_op_array *op_array, zend_optimizer_ctx *ctx)
{
zend_op *opline = block->start_opline;
@@ -602,8 +613,7 @@ static void strip_nop(zend_code_block *block, zend_op_array *op_array, zend_opti
&& ((opline + 1)->opcode == ZEND_JMPZ
|| (opline + 1)->opcode == ZEND_JMPNZ)
&& (opline + 1)->op1_type & (IS_CV|IS_CONST)
&& opline > op_array->opcodes
&& zend_is_smart_branch(opline - 1)) {
&& is_predecessor_smart_branch(op_array->opcodes, opline)) {
/* don't remove NOP, that splits incorrect smart branch */
opline++;
break;
+18 -4
View File
@@ -406,12 +406,26 @@ int zend_optimizer_replace_by_const(zend_op_array *op_array,
break;
/* In most cases IS_TMP_VAR operand may be used only once.
* The operands are usually destroyed by the opcode handler.
* ZEND_CASE is an exception, that keeps operand unchanged,
* and allows its reuse. The number of ZEND_CASE instructions
* ZEND_CASE and ZEND_FETCH_LIST are exceptions, they keeps operand
* unchanged, and allows its reuse. these instructions
* usually terminated by ZEND_FREE that finally kills the value.
*/
case ZEND_FREE:
case ZEND_CASE: {
case ZEND_FETCH_LIST: {
zend_op *m = opline;
do {
if (m->opcode == ZEND_FETCH_LIST &&
ZEND_OP1_TYPE(m) == type &&
ZEND_OP1(m).var == var) {
zend_optimizer_update_op1_const(op_array, m, val);
}
m++;
} while (m->opcode != ZEND_FREE || ZEND_OP1_TYPE(m) != type || ZEND_OP1(m).var != var);
ZEND_ASSERT(m->opcode == ZEND_FREE && ZEND_OP1_TYPE(m) == type && ZEND_OP1(m).var == var);
MAKE_NOP(m);
return 1;
}
case ZEND_CASE:
case ZEND_FREE: {
zend_op *m, *n;
int brk = op_array->last_brk_cont;
zend_bool in_switch = 0;
+25
View File
@@ -0,0 +1,25 @@
--TEST--
Bug #74019 (Segfault with list)
--INI--
opcache.enable=1
opcache.enable_cli=1
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--FILE--
<?php
class A {
public function seg() {
list($a, $b) = A::CONSTS;
var_dump($a, $b);
return;
}
const CONSTS = [1, 2];
}
$a = new A;
$a->seg();
?>
--EXPECT--
int(1)
int(2)
+27
View File
@@ -0,0 +1,27 @@
--TEST--
Bug #74152 (if statement says true to a null variable)
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.optimization_level=-1
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--FILE--
<?php
$foo = 'foo';
$bar = null;
switch ($foo) {
default:
case 'foo':
if ($bar) {
echo 'true';
} else {
echo 'false';
}
}
?>
--EXPECT--
false
+46 -42
View File
@@ -2638,56 +2638,60 @@ PHP_FUNCTION(openssl_pkcs12_read)
zval_dtor(zout);
array_init(zout);
bio_out = BIO_new(BIO_s_mem());
if (PEM_write_bio_X509(bio_out, cert)) {
BUF_MEM *bio_buf;
BIO_get_mem_ptr(bio_out, &bio_buf);
ZVAL_STRINGL(&zcert, bio_buf->data, bio_buf->length);
add_assoc_zval(zout, "cert", &zcert);
}
BIO_free(bio_out);
bio_out = BIO_new(BIO_s_mem());
if (PEM_write_bio_PrivateKey(bio_out, pkey, NULL, NULL, 0, 0, NULL)) {
BUF_MEM *bio_buf;
BIO_get_mem_ptr(bio_out, &bio_buf);
ZVAL_STRINGL(&zpkey, bio_buf->data, bio_buf->length);
add_assoc_zval(zout, "pkey", &zpkey);
}
BIO_free(bio_out);
array_init(&zextracerts);
for (i=0;;i++) {
zval zextracert;
X509* aCA = sk_X509_pop(ca);
if (!aCA) break;
/* fix for bug 69882 */
{
int err = ERR_peek_error();
if (err == OPENSSL_ERROR_X509_PRIVATE_KEY_VALUES_MISMATCH) {
ERR_get_error();
}
}
if (cert) {
bio_out = BIO_new(BIO_s_mem());
if (PEM_write_bio_X509(bio_out, aCA)) {
if (PEM_write_bio_X509(bio_out, cert)) {
BUF_MEM *bio_buf;
BIO_get_mem_ptr(bio_out, &bio_buf);
ZVAL_STRINGL(&zextracert, bio_buf->data, bio_buf->length);
add_index_zval(&zextracerts, i, &zextracert);
ZVAL_STRINGL(&zcert, bio_buf->data, bio_buf->length);
add_assoc_zval(zout, "cert", &zcert);
}
BIO_free(bio_out);
X509_free(aCA);
}
if(ca) {
if (pkey) {
bio_out = BIO_new(BIO_s_mem());
if (PEM_write_bio_PrivateKey(bio_out, pkey, NULL, NULL, 0, 0, NULL)) {
BUF_MEM *bio_buf;
BIO_get_mem_ptr(bio_out, &bio_buf);
ZVAL_STRINGL(&zpkey, bio_buf->data, bio_buf->length);
add_assoc_zval(zout, "pkey", &zpkey);
}
BIO_free(bio_out);
}
if (ca && sk_X509_num(ca)) {
array_init(&zextracerts);
for (i=0; i < sk_X509_num(ca); i++) {
zval zextracert;
X509* aCA = sk_X509_pop(ca);
if (!aCA) break;
/* fix for bug 69882 */
{
int err = ERR_peek_error();
if (err == OPENSSL_ERROR_X509_PRIVATE_KEY_VALUES_MISMATCH) {
ERR_get_error();
}
}
bio_out = BIO_new(BIO_s_mem());
if (PEM_write_bio_X509(bio_out, aCA)) {
BUF_MEM *bio_buf;
BIO_get_mem_ptr(bio_out, &bio_buf);
ZVAL_STRINGL(&zextracert, bio_buf->data, bio_buf->length);
add_index_zval(&zextracerts, i, &zextracert);
}
BIO_free(bio_out);
X509_free(aCA);
}
sk_X509_free(ca);
add_assoc_zval(zout, "extracerts", &zextracerts);
} else {
zval_dtor(&zextracerts);
}
RETVAL_TRUE;
Binary file not shown.
+19
View File
@@ -0,0 +1,19 @@
--TEST--
Bug #74022 PHP Fast CGI crashes when reading from a pfx file with valid password
--SKIPIF--
<?php
if (!extension_loaded("openssl")) die("skip");
?>
--FILE--
<?php
$pfx = dirname(__FILE__) . DIRECTORY_SEPARATOR . "bug74022.pfx";
$cert_store = file_get_contents($pfx);
var_dump(openssl_pkcs12_read($cert_store, $cert_info, "csos"));
var_dump(openssl_error_string());
?>
===DONE===
--EXPECTF--
bool(true)
bool(false)
===DONE===
+12 -2
View File
@@ -1174,7 +1174,7 @@ static sdlPtr load_wsdl(zval *this_ptr, char *struri)
return ctx.sdl;
}
#define WSDL_CACHE_VERSION 0x0e
#define WSDL_CACHE_VERSION 0x0f
#define WSDL_CACHE_GET(ret,type,buf) memcpy(&ret,*buf,sizeof(type)); *buf += sizeof(type);
#define WSDL_CACHE_GET_INT(ret,buf) ret = ((unsigned char)(*buf)[0])|((unsigned char)(*buf)[1]<<8)|((unsigned char)(*buf)[2]<<16)|((int)(*buf)[3]<<24); *buf += 4;
@@ -3204,7 +3204,7 @@ sdlPtr get_sdl(zval *this_ptr, char *uri, zend_long cache_wsdl)
PHP_MD5Update(&context, (unsigned char*)uri, uri_len);
PHP_MD5Final(digest, &context);
make_digest(md5str, digest);
key = emalloc(len+sizeof("/wsdl-")-1+user_len+sizeof(md5str));
key = emalloc(len+sizeof("/wsdl-")-1+user_len+2+sizeof(md5str));
memcpy(key,SOAP_GLOBAL(cache_dir),len);
memcpy(key+len,"/wsdl-",sizeof("/wsdl-")-1);
len += sizeof("/wsdl-")-1;
@@ -3213,6 +3213,16 @@ sdlPtr get_sdl(zval *this_ptr, char *uri, zend_long cache_wsdl)
len += user_len-1;
key[len++] = '-';
}
if (WSDL_CACHE_VERSION <= 0x9f) {
key[len++] = (WSDL_CACHE_VERSION >> 8) + '0';
} else {
key[len++] = (WSDL_CACHE_VERSION >> 8) - 10 + 'a';
}
if ((WSDL_CACHE_VERSION & 0xf) <= 0x9) {
key[len++] = (WSDL_CACHE_VERSION & 0xf) + '0';
} else {
key[len++] = (WSDL_CACHE_VERSION & 0xf) - 10 + 'a';
}
memcpy(key+len,md5str,sizeof(md5str));
if ((sdl = get_sdl_from_cache(key, uri, t-SOAP_GLOBAL(cache_ttl), &cached)) != NULL) {
+3 -3
View File
@@ -378,14 +378,14 @@ static void autoload_func_info_dtor(zval *element)
if (!Z_ISUNDEF(alfi->obj)) {
zval_ptr_dtor(&alfi->obj);
}
if (!Z_ISUNDEF(alfi->closure)) {
zval_ptr_dtor(&alfi->closure);
}
if (alfi->func_ptr &&
UNEXPECTED(alfi->func_ptr->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE)) {
zend_string_release(alfi->func_ptr->common.function_name);
zend_free_trampoline(alfi->func_ptr);
}
if (!Z_ISUNDEF(alfi->closure)) {
zval_ptr_dtor(&alfi->closure);
}
efree(alfi);
}
+1
View File
@@ -1193,6 +1193,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_fputcsv, 0, 0, 2)
ZEND_ARG_INFO(0, fields) /* ARRAY_INFO(0, fields, 1) */
ZEND_ARG_INFO(0, delimiter)
ZEND_ARG_INFO(0, enclosure)
ZEND_ARG_INFO(0, escape_char)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_fgetcsv, 0, 0, 1)
+8 -7
View File
@@ -349,7 +349,8 @@ dnl Check for available functions
dnl
dnl log2 could be used to improve the log function, however it requires C99. The check for log2 should be turned on,
dnl as soon as we support C99.
AC_CHECK_FUNCS(getcwd getwd asinh acosh atanh log1p hypot glob strfmon nice fpclass isinf isnan mempcpy strpncpy)
AC_CHECK_FUNCS(getcwd getwd asinh acosh atanh log1p hypot glob strfmon nice fpclass mempcpy strpncpy)
AC_CHECK_DECLS([isnan, isinf], [], [], [[#include <math.h>]])
AC_FUNC_FNMATCH
dnl
@@ -420,7 +421,7 @@ AC_TRY_RUN([
#include <math.h>
#include <stdlib.h>
#ifdef HAVE_ISNAN
#ifdef HAVE_DECL_ISNAN
#define zend_isnan(a) isnan(a)
#elif defined(HAVE_FPCLASS)
#define zend_isnan(a) ((fpclass(a) == FP_SNAN) || (fpclass(a) == FP_QNAN))
@@ -451,11 +452,11 @@ AC_TRY_RUN([
#include <math.h>
#include <stdlib.h>
#ifdef HAVE_ISINF
#ifdef HAVE_DECL_ISINF
#define zend_isinf(a) isinf(a)
#elif defined(INFINITY)
/* Might not work, but is required by ISO C99 */
#define zend_isinf(a) (((a)==INFINITY)?1:0)
#define zend_isinf(a) (((a)==INFINITY || (a)==-INFINITY)?1:0)
#elif defined(HAVE_FPCLASS)
#define zend_isinf(a) ((fpclass(a) == FP_PINF) || (fpclass(a) == FP_NINF))
#else
@@ -485,11 +486,11 @@ AC_TRY_RUN([
#include <math.h>
#include <stdlib.h>
#ifdef HAVE_ISINF
#ifdef HAVE_DECL_ISINF
#define zend_isinf(a) isinf(a)
#elif defined(INFINITY)
/* Might not work, but is required by ISO C99 */
#define zend_isinf(a) (((a)==INFINITY)?1:0)
#define zend_isinf(a) (((a)==INFINITY || (a)==-INFINITY)?1:0)
#elif defined(HAVE_FPCLASS)
#define zend_isinf(a) ((fpclass(a) == FP_PINF) || (fpclass(a) == FP_NINF))
#else
@@ -520,7 +521,7 @@ AC_TRY_RUN([
#include <math.h>
#include <stdlib.h>
#ifdef HAVE_ISNAN
#ifdef HAVE_DECL_ISNAN
#define zend_isnan(a) isnan(a)
#elif defined(HAVE_FPCLASS)
#define zend_isnan(a) ((fpclass(a) == FP_SNAN) || (fpclass(a) == FP_QNAN))
+55 -51
View File
@@ -93,14 +93,13 @@ PHPAPI int php_random_bytes(void *bytes, size_t size, zend_bool should_throw)
}
#elif HAVE_DECL_ARC4RANDOM_BUF && ((defined(__OpenBSD__) && OpenBSD >= 201405) || (defined(__NetBSD__) && __NetBSD_Version__ >= 700000001))
arc4random_buf(bytes, size);
#elif defined(__linux__) && defined(SYS_getrandom)
/* Linux getrandom(2) syscall */
#else
size_t read_bytes = 0;
size_t amount_to_read = 0;
ssize_t n;
#if defined(__linux__) && defined(SYS_getrandom)
/* Linux getrandom(2) syscall */
/* Keep reading until we get enough entropy */
do {
while (read_bytes < size) {
/* Below, (bytes + read_bytes) is pointer arithmetic.
bytes read_bytes size
@@ -110,11 +109,17 @@ PHPAPI int php_random_bytes(void *bytes, size_t size, zend_bool should_throw)
amount_to_read
*/
amount_to_read = size - read_bytes;
size_t amount_to_read = size - read_bytes;
n = syscall(SYS_getrandom, bytes + read_bytes, amount_to_read, 0);
if (n == -1) {
if (errno == EINTR || errno == EAGAIN) {
if (errno == ENOSYS) {
/* This can happen if PHP was compiled against a newer kernel where getrandom()
* is available, but then runs on an older kernel without getrandom(). If this
* happens we simply fall back to reading from /dev/urandom. */
ZEND_ASSERT(read_bytes == 0);
break;
} else if (errno == EINTR || errno == EAGAIN) {
/* Try again */
continue;
}
@@ -130,53 +135,52 @@ PHPAPI int php_random_bytes(void *bytes, size_t size, zend_bool should_throw)
}
read_bytes += (size_t) n;
} while (read_bytes < size);
#else
int fd = RANDOM_G(fd);
struct stat st;
size_t read_bytes = 0;
ssize_t n;
if (fd < 0) {
#if HAVE_DEV_URANDOM
fd = open("/dev/urandom", O_RDONLY);
}
#endif
if (fd < 0) {
if (should_throw) {
zend_throw_exception(zend_ce_exception, "Cannot open source device", 0);
}
return FAILURE;
}
/* Does the file exist and is it a character device? */
if (fstat(fd, &st) != 0 ||
# ifdef S_ISNAM
!(S_ISNAM(st.st_mode) || S_ISCHR(st.st_mode))
# else
!S_ISCHR(st.st_mode)
# endif
) {
close(fd);
if (should_throw) {
zend_throw_exception(zend_ce_exception, "Error reading from source device", 0);
}
return FAILURE;
}
RANDOM_G(fd) = fd;
}
while (read_bytes < size) {
n = read(fd, bytes + read_bytes, size - read_bytes);
if (n <= 0) {
break;
}
read_bytes += n;
}
if (read_bytes < size) {
if (should_throw) {
zend_throw_exception(zend_ce_exception, "Could not gather sufficient random data", 0);
int fd = RANDOM_G(fd);
struct stat st;
if (fd < 0) {
#if HAVE_DEV_URANDOM
fd = open("/dev/urandom", O_RDONLY);
#endif
if (fd < 0) {
if (should_throw) {
zend_throw_exception(zend_ce_exception, "Cannot open source device", 0);
}
return FAILURE;
}
/* Does the file exist and is it a character device? */
if (fstat(fd, &st) != 0 ||
# ifdef S_ISNAM
!(S_ISNAM(st.st_mode) || S_ISCHR(st.st_mode))
# else
!S_ISCHR(st.st_mode)
# endif
) {
close(fd);
if (should_throw) {
zend_throw_exception(zend_ce_exception, "Error reading from source device", 0);
}
return FAILURE;
}
RANDOM_G(fd) = fd;
}
for (read_bytes = 0; read_bytes < size; read_bytes += (size_t) n) {
n = read(fd, bytes + read_bytes, size - read_bytes);
if (n <= 0) {
break;
}
}
if (read_bytes < size) {
if (should_throw) {
zend_throw_exception(zend_ce_exception, "Could not gather sufficient random data", 0);
}
return FAILURE;
}
return FAILURE;
}
#endif
@@ -0,0 +1,22 @@
--TEST--
Test is_callable() function : usage variations - anonymous class method
--FILE--
<?php
new class {
function __construct() {
$fname = null;
if (is_callable([$this, 'f'], false, $fname)) {
call_user_func($fname);
} else {
echo "dang\n";
}
}
function f() {
echo "nice\n";
}
};
?>
--EXPECT--
nice
@@ -1,5 +1,9 @@
--TEST--
Test is_callable() function : usage variations - undefined functions
--SKIPIF--
<?php
if (!extension_loaded('json')) die("skip requires ext/json");
?>
--INI--
precision=14
error_reporting = E_ALL & ~E_NOTICE | E_STRICT
@@ -21,10 +25,10 @@ function check_iscallable( $functions ) {
var_dump( is_callable($func) ); //given only $var argument
var_dump( is_callable($func, TRUE) ); //given $var and $syntax argument
var_dump( is_callable($func, TRUE, $callable_name) );
echo $callable_name, "\n";
echo json_encode($callable_name) . "\n";
var_dump( is_callable($func, FALSE) ); //given $var and $syntax argument
var_dump( is_callable($func, FALSE, $callable_name) );
echo $callable_name, "\n";
echo json_encode($callable_name) . "\n";
$counter++;
}
}
@@ -65,144 +69,144 @@ check_iscallable($undef_functions);
bool(false)
bool(true)
bool(true)
""
bool(false)
bool(false)
""
-- Iteration 2 --
bool(false)
bool(true)
bool(true)
""
bool(false)
bool(false)
""
-- Iteration 3 --
bool(false)
bool(true)
bool(true)
" "
bool(false)
bool(false)
" "
-- Iteration 4 --
bool(false)
bool(true)
bool(true)
" "
bool(false)
bool(false)
" "
-- Iteration 5 --
bool(false)
bool(true)
bool(true)
12356
"12356"
bool(false)
bool(false)
12356
"12356"
-- Iteration 6 --
bool(false)
bool(true)
bool(true)
"\u0000"
bool(false)
bool(false)
"\u0000"
-- Iteration 7 --
bool(false)
bool(true)
bool(true)
\0
"\\0"
bool(false)
bool(false)
\0
"\\0"
-- Iteration 8 --
bool(false)
bool(true)
bool(true)
hello world
"hello world"
bool(false)
bool(false)
hello world
"hello world"
-- Iteration 9 --
bool(false)
bool(true)
bool(true)
hello world
"hello world"
bool(false)
bool(false)
hello world
"hello world"
-- Iteration 10 --
bool(false)
bool(true)
bool(true)
welcome
"welcome\u0000"
bool(false)
bool(false)
welcome
"welcome\u0000"
-- Iteration 11 --
bool(false)
bool(true)
bool(true)
welcome\0
"welcome\\0"
bool(false)
bool(false)
welcome\0
"welcome\\0"
-- Iteration 12 --
bool(false)
bool(true)
bool(true)
==%%%***$$$@@@!!
"==%%%***$$$@@@!!"
bool(false)
bool(false)
==%%%***$$$@@@!!
"==%%%***$$$@@@!!"
-- Iteration 13 --
bool(false)
bool(true)
bool(true)
false
"false"
bool(false)
bool(false)
false
"false"
-- Iteration 14 --
bool(false)
bool(true)
bool(true)
8
"8"
bool(false)
bool(false)
8
"8"
-- Iteration 15 --
bool(false)
bool(true)
bool(true)
\t
"\\t"
bool(false)
bool(false)
\t
"\\t"
-- Iteration 16 --
bool(false)
bool(true)
bool(true)
\007
"\\007"
bool(false)
bool(false)
\007
"\\007"
-- Iteration 17 --
bool(false)
bool(true)
bool(true)
123
"123"
bool(false)
bool(false)
123
"123"
-- Iteration 18 --
bool(false)
bool(true)
bool(true)
echo()
"echo()"
bool(false)
bool(false)
echo()
===DONE===
"echo()"
===DONE===
+28
View File
@@ -0,0 +1,28 @@
--TEST--
Bug #74039: is_infinite(-INF) returns false
--FILE--
<?php
var_dump(is_finite(INF));
var_dump(is_infinite(INF));
var_dump(is_nan(INF));
var_dump(is_finite(-INF));
var_dump(is_infinite(-INF));
var_dump(is_nan(-INF));
var_dump(is_finite(NAN));
var_dump(is_infinite(NAN));
var_dump(is_nan(NAN));
?>
--EXPECT--
bool(false)
bool(true)
bool(false)
bool(false)
bool(true)
bool(false)
bool(false)
bool(false)
bool(true)
+2 -2
View File
@@ -14,5 +14,5 @@ $poc = 'O:8:"stdClass":1:{i:0;O:3:"obj":1:{s:4:"ryat";R:1;}}';
var_dump(unserialize($poc));
?>
--EXPECT--
int(73588229205)
--EXPECTF--
%s(73588229205)
+22
View File
@@ -0,0 +1,22 @@
--TEST--
Bug #74090 stream_get_contents maxlength>-1 returns empty string on windows
--SKIPIF--
<?php
if (getenv("SKIP_ONLINE_TESTS")) { die('skip: online test'); }
if (getenv("SKIP_SLOW_TESTS")) { die('skip: slow test'); }
?>
--FILE--
<?php
$data = base64_decode("1oIBAAABAAAAAAAAB2V4YW1wbGUDb3JnAAABAAE=");
$fd = stream_socket_client("udp://8.8.8.8:53", $errno, $errstr, 0, STREAM_CLIENT_CONNECT | STREAM_CLIENT_ASYNC_CONNECT);
stream_set_blocking($fd, 0);
stream_socket_sendto($fd,$data);
sleep(1);
$ret = stream_get_contents($fd,65565);
var_dump(strlen($ret) > 0);
stream_socket_shutdown($fd,STREAM_SHUT_RDWR);
?>
==DONE==
--EXPECTF--
bool(true)
==DONE==
+1 -7
View File
@@ -384,13 +384,7 @@ PHP_FUNCTION(is_callable)
if (ZEND_NUM_ARGS() > 2) {
retval = zend_is_callable_ex(var, NULL, check_flags, &name, NULL, &error);
zval_dtor(callable_name);
//??? is it necessary to be consistent with old PHP ("\0" support)
if (UNEXPECTED(ZSTR_LEN(name)) != strlen(ZSTR_VAL(name))) {
ZVAL_STRINGL(callable_name, ZSTR_VAL(name), strlen(ZSTR_VAL(name)));
zend_string_release(name);
} else {
ZVAL_STR(callable_name, name);
}
ZVAL_STR(callable_name, name);
} else {
retval = zend_is_callable_ex(var, NULL, check_flags, NULL, NULL, &error);
}
+180 -240
View File
@@ -1,4 +1,4 @@
/* Generated by re2c 0.14.3 */
/* Generated by re2c 0.16 */
#line 1 "ext/standard/url_scanner_ex.re"
/*
+----------------------------------------------------------------------+
@@ -35,6 +35,7 @@
#include "php_ini.h"
#include "php_globals.h"
#include "php_string.h"
#define STATE_TAG SOME_OTHER_STATE_TAG
#include "basic_functions.h"
#include "url.h"
@@ -100,7 +101,7 @@ PHP_INI_BEGIN()
STD_PHP_INI_ENTRY("url_rewriter.tags", "a=href,area=href,frame=src,form=,fieldset=", PHP_INI_ALL, OnUpdateTags, url_adapt_state_ex, php_basic_globals, basic_globals)
PHP_INI_END()
#line 107 "ext/standard/url_scanner_ex.re"
#line 108 "ext/standard/url_scanner_ex.re"
#define YYFILL(n) goto done
@@ -119,7 +120,8 @@ static inline void append_modified_url(smart_str *url, smart_str *dest, smart_st
* Don't modify "//example.com" full path, unless
* HTTP_HOST matches.
*/
if (ZSTR_VAL(url->s)[0] == '/' && ZSTR_VAL(url->s)[1] == '/') {
if (ZSTR_LEN(url->s) > 2 && ZSTR_VAL(url->s)[0] == '/' && ZSTR_VAL(url->s)[1] == '/') {
const char *end_chars = "/\"'?>\r\n";
zval *tmp = NULL, *http_host = NULL;
size_t target_len, host_len;
if ((!(tmp = zend_hash_str_find(&EG(symbol_table), ZEND_STRL("_SERVER"))))
@@ -129,10 +131,13 @@ static inline void append_modified_url(smart_str *url, smart_str *dest, smart_st
smart_str_append_smart_str(dest, url);
return;
}
/* HTTP_HOST could be "example.com:8888", etc. */
/* Need to find end of URL in buffer */
host_len = strcspn(Z_STRVAL_P(http_host), ":");
target_len = strcspn(ZSTR_VAL(url->s)+2, "/\"'?>\r\n");
target_len = php_strcspn(
ZSTR_VAL(url->s) + 2, (char *) end_chars,
ZSTR_VAL(url->s) + ZSTR_LEN(url->s), (char *) end_chars + strlen(end_chars));
if (host_len
&& host_len == target_len
&& strncasecmp(Z_STRVAL_P(http_host), ZSTR_VAL(url->s)+2, host_len)) {
@@ -145,7 +150,7 @@ static inline void append_modified_url(smart_str *url, smart_str *dest, smart_st
scan:
#line 149 "ext/standard/url_scanner_ex.c"
#line 154 "ext/standard/url_scanner_ex.c"
{
YYCTYPE yych;
static const unsigned char yybm[] = {
@@ -182,40 +187,41 @@ scan:
128, 128, 128, 128, 128, 128, 128, 128,
128, 128, 128, 128, 128, 128, 128, 128,
};
if (YYLIMIT <= YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
if (yybm[0+yych] & 128) {
goto yy8;
goto yy2;
}
if (yych <= '#') goto yy6;
if (yych >= ';') goto yy4;
++YYCURSOR;
#line 151 "ext/standard/url_scanner_ex.re"
{ smart_str_append_smart_str(dest, url); return; }
#line 197 "ext/standard/url_scanner_ex.c"
yy4:
++YYCURSOR;
#line 152 "ext/standard/url_scanner_ex.re"
{ sep = separator; goto scan; }
#line 202 "ext/standard/url_scanner_ex.c"
yy6:
++YYCURSOR;
#line 153 "ext/standard/url_scanner_ex.re"
{ bash = p - 1; goto done; }
#line 207 "ext/standard/url_scanner_ex.c"
yy8:
if (yych <= '#') goto yy5;
if (yych <= ':') goto yy7;
goto yy9;
yy2:
++YYCURSOR;
if (YYLIMIT <= YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
if (yybm[0+yych] & 128) {
goto yy8;
goto yy2;
}
#line 154 "ext/standard/url_scanner_ex.re"
#line 159 "ext/standard/url_scanner_ex.re"
{ goto scan; }
#line 217 "ext/standard/url_scanner_ex.c"
#line 208 "ext/standard/url_scanner_ex.c"
yy5:
++YYCURSOR;
#line 158 "ext/standard/url_scanner_ex.re"
{ bash = p - 1; goto done; }
#line 213 "ext/standard/url_scanner_ex.c"
yy7:
++YYCURSOR;
#line 156 "ext/standard/url_scanner_ex.re"
{ smart_str_append_smart_str(dest, url); return; }
#line 218 "ext/standard/url_scanner_ex.c"
yy9:
++YYCURSOR;
#line 157 "ext/standard/url_scanner_ex.re"
{ sep = separator; goto scan; }
#line 223 "ext/standard/url_scanner_ex.c"
}
#line 155 "ext/standard/url_scanner_ex.re"
#line 160 "ext/standard/url_scanner_ex.re"
done:
@@ -400,7 +406,7 @@ state_plain_begin:
state_plain:
start = YYCURSOR;
#line 404 "ext/standard/url_scanner_ex.c"
#line 410 "ext/standard/url_scanner_ex.c"
{
YYCTYPE yych;
static const unsigned char yybm[] = {
@@ -440,30 +446,32 @@ state_plain:
if (YYLIMIT <= YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
if (yybm[0+yych] & 128) {
goto yy15;
goto yy13;
}
++YYCURSOR;
#line 339 "ext/standard/url_scanner_ex.re"
{ passthru(STD_ARGS); STATE = STATE_TAG; goto state_tag; }
#line 449 "ext/standard/url_scanner_ex.c"
yy15:
goto yy16;
yy13:
++YYCURSOR;
if (YYLIMIT <= YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
if (yybm[0+yych] & 128) {
goto yy15;
goto yy13;
}
#line 340 "ext/standard/url_scanner_ex.re"
#line 345 "ext/standard/url_scanner_ex.re"
{ passthru(STD_ARGS); goto state_plain; }
#line 459 "ext/standard/url_scanner_ex.c"
#line 462 "ext/standard/url_scanner_ex.c"
yy16:
++YYCURSOR;
#line 344 "ext/standard/url_scanner_ex.re"
{ passthru(STD_ARGS); STATE = STATE_TAG; goto state_tag; }
#line 467 "ext/standard/url_scanner_ex.c"
}
#line 341 "ext/standard/url_scanner_ex.re"
#line 346 "ext/standard/url_scanner_ex.re"
state_tag:
start = YYCURSOR;
#line 467 "ext/standard/url_scanner_ex.c"
#line 475 "ext/standard/url_scanner_ex.c"
{
YYCTYPE yych;
static const unsigned char yybm[] = {
@@ -500,39 +508,27 @@ state_tag:
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
};
if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
if (YYLIMIT <= YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
if (yych <= '@') {
if (yych != ':') goto yy22;
} else {
if (yych <= 'Z') goto yy20;
if (yych <= '`') goto yy22;
if (yych >= '{') goto yy22;
if (yybm[0+yych] & 128) {
goto yy22;
}
yy20:
++YYCURSOR;
yych = *YYCURSOR;
goto yy25;
yy21:
#line 346 "ext/standard/url_scanner_ex.re"
{ handle_tag(STD_ARGS); /* Sets STATE */; passthru(STD_ARGS); if (STATE == STATE_PLAIN) goto state_plain; else goto state_next_arg; }
#line 352 "ext/standard/url_scanner_ex.re"
{ passthru(STD_ARGS); goto state_plain_begin; }
#line 520 "ext/standard/url_scanner_ex.c"
yy22:
++YYCURSOR;
#line 347 "ext/standard/url_scanner_ex.re"
{ passthru(STD_ARGS); goto state_plain_begin; }
#line 525 "ext/standard/url_scanner_ex.c"
yy24:
++YYCURSOR;
if (YYLIMIT <= YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
yy25:
if (yybm[0+yych] & 128) {
goto yy24;
goto yy22;
}
goto yy21;
#line 351 "ext/standard/url_scanner_ex.re"
{ handle_tag(STD_ARGS); /* Sets STATE */; passthru(STD_ARGS); if (STATE == STATE_PLAIN) goto state_plain; else goto state_next_arg; }
#line 530 "ext/standard/url_scanner_ex.c"
}
#line 348 "ext/standard/url_scanner_ex.re"
#line 353 "ext/standard/url_scanner_ex.re"
state_next_arg_begin:
@@ -541,7 +537,7 @@ state_next_arg_begin:
state_next_arg:
start = YYCURSOR;
#line 545 "ext/standard/url_scanner_ex.c"
#line 541 "ext/standard/url_scanner_ex.c"
{
YYCTYPE yych;
static const unsigned char yybm[] = {
@@ -580,78 +576,57 @@ state_next_arg:
};
if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
yych = *YYCURSOR;
if (yych <= '.') {
if (yych <= '\f') {
if (yych <= 0x08) goto yy36;
if (yych <= '\v') goto yy32;
goto yy36;
} else {
if (yych <= '\r') goto yy32;
if (yych == ' ') goto yy32;
goto yy36;
}
if (yybm[0+yych] & 128) {
goto yy29;
}
if (yych <= '>') {
if (yych == '/') goto yy32;
if (yych >= '>') goto yy33;
} else {
if (yych <= '@') {
if (yych <= '/') goto yy28;
if (yych == '>') goto yy30;
goto yy36;
if (yych <= 'Z') {
if (yych >= 'A') goto yy35;
} else {
if (yych <= 'Z') goto yy34;
if (yych <= '`') goto yy36;
if (yych <= 'z') goto yy34;
goto yy36;
if (yych <= '`') goto yy27;
if (yych <= 'z') goto yy35;
}
}
yy27:
++YYCURSOR;
yy28:
++YYCURSOR;
if ((yych = *YYCURSOR) == '>') goto yy39;
yy29:
#line 359 "ext/standard/url_scanner_ex.re"
#line 364 "ext/standard/url_scanner_ex.re"
{ passthru(STD_ARGS); goto state_plain_begin; }
#line 612 "ext/standard/url_scanner_ex.c"
yy30:
++YYCURSOR;
yy31:
#line 356 "ext/standard/url_scanner_ex.re"
{ passthru(STD_ARGS); handle_form(STD_ARGS); goto state_plain_begin; }
#line 618 "ext/standard/url_scanner_ex.c"
yy32:
++YYCURSOR;
yych = *YYCURSOR;
goto yy38;
yy33:
#line 357 "ext/standard/url_scanner_ex.re"
{ passthru(STD_ARGS); goto state_next_arg; }
#line 626 "ext/standard/url_scanner_ex.c"
yy34:
++YYCURSOR;
#line 358 "ext/standard/url_scanner_ex.re"
{ --YYCURSOR; STATE = STATE_ARG; goto state_arg; }
#line 631 "ext/standard/url_scanner_ex.c"
yy36:
yych = *++YYCURSOR;
goto yy29;
yy37:
#line 599 "ext/standard/url_scanner_ex.c"
yy29:
++YYCURSOR;
if (YYLIMIT <= YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
yy38:
if (yybm[0+yych] & 128) {
goto yy37;
goto yy29;
}
goto yy33;
yy39:
#line 362 "ext/standard/url_scanner_ex.re"
{ passthru(STD_ARGS); goto state_next_arg; }
#line 609 "ext/standard/url_scanner_ex.c"
yy32:
yych = *++YYCURSOR;
if (yych != '>') goto yy28;
yy33:
++YYCURSOR;
yych = *YYCURSOR;
goto yy31;
#line 361 "ext/standard/url_scanner_ex.re"
{ passthru(STD_ARGS); handle_form(STD_ARGS); goto state_plain_begin; }
#line 617 "ext/standard/url_scanner_ex.c"
yy35:
++YYCURSOR;
#line 363 "ext/standard/url_scanner_ex.re"
{ --YYCURSOR; STATE = STATE_ARG; goto state_arg; }
#line 622 "ext/standard/url_scanner_ex.c"
}
#line 360 "ext/standard/url_scanner_ex.re"
#line 365 "ext/standard/url_scanner_ex.re"
state_arg:
start = YYCURSOR;
#line 655 "ext/standard/url_scanner_ex.c"
#line 630 "ext/standard/url_scanner_ex.c"
{
YYCTYPE yych;
static const unsigned char yybm[] = {
@@ -688,42 +663,35 @@ state_arg:
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
};
if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
if (YYLIMIT <= YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
if (yych <= '@') goto yy44;
if (yych <= 'Z') goto yy42;
if (yych <= '`') goto yy44;
if (yych >= '{') goto yy44;
yy42:
if (yych <= '@') goto yy39;
if (yych <= 'Z') goto yy41;
if (yych <= '`') goto yy39;
if (yych <= 'z') goto yy41;
yy39:
++YYCURSOR;
yych = *YYCURSOR;
goto yy47;
yy43:
#line 365 "ext/standard/url_scanner_ex.re"
{ passthru(STD_ARGS); handle_arg(STD_ARGS); STATE = STATE_BEFORE_VAL; goto state_before_val; }
#line 705 "ext/standard/url_scanner_ex.c"
yy44:
++YYCURSOR;
#line 366 "ext/standard/url_scanner_ex.re"
#line 371 "ext/standard/url_scanner_ex.re"
{ passthru(STD_ARGS); STATE = STATE_NEXT_ARG; goto state_next_arg; }
#line 710 "ext/standard/url_scanner_ex.c"
yy46:
#line 677 "ext/standard/url_scanner_ex.c"
yy41:
++YYCURSOR;
if (YYLIMIT <= YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
yy47:
if (yybm[0+yych] & 128) {
goto yy46;
goto yy41;
}
goto yy43;
#line 370 "ext/standard/url_scanner_ex.re"
{ passthru(STD_ARGS); handle_arg(STD_ARGS); STATE = STATE_BEFORE_VAL; goto state_before_val; }
#line 687 "ext/standard/url_scanner_ex.c"
}
#line 367 "ext/standard/url_scanner_ex.re"
#line 372 "ext/standard/url_scanner_ex.re"
state_before_val:
start = YYCURSOR;
#line 727 "ext/standard/url_scanner_ex.c"
#line 695 "ext/standard/url_scanner_ex.c"
{
YYCTYPE yych;
static const unsigned char yybm[] = {
@@ -762,54 +730,44 @@ state_before_val:
};
if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
yych = *YYCURSOR;
if (yych == ' ') goto yy50;
if (yych == '=') goto yy52;
goto yy54;
yy50:
yych = *(YYMARKER = ++YYCURSOR);
if (yych == ' ') goto yy57;
if (yych == '=') goto yy55;
yy51:
#line 373 "ext/standard/url_scanner_ex.re"
if (yych == ' ') goto yy48;
if (yych == '=') goto yy49;
++YYCURSOR;
yy47:
#line 378 "ext/standard/url_scanner_ex.re"
{ --YYCURSOR; goto state_next_arg_begin; }
#line 776 "ext/standard/url_scanner_ex.c"
#line 740 "ext/standard/url_scanner_ex.c"
yy48:
yych = *(YYMARKER = ++YYCURSOR);
if (yych == ' ') goto yy52;
if (yych != '=') goto yy47;
yy49:
++YYCURSOR;
if (YYLIMIT <= YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
if (yybm[0+yych] & 128) {
goto yy49;
}
#line 377 "ext/standard/url_scanner_ex.re"
{ passthru(STD_ARGS); STATE = STATE_VAL; goto state_val; }
#line 754 "ext/standard/url_scanner_ex.c"
yy52:
++YYCURSOR;
yych = *YYCURSOR;
goto yy56;
yy53:
#line 372 "ext/standard/url_scanner_ex.re"
{ passthru(STD_ARGS); STATE = STATE_VAL; goto state_val; }
#line 784 "ext/standard/url_scanner_ex.c"
yy54:
yych = *++YYCURSOR;
goto yy51;
yy55:
++YYCURSOR;
if (YYLIMIT <= YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
yy56:
if (yybm[0+yych] & 128) {
goto yy55;
}
goto yy53;
yy57:
++YYCURSOR;
if (YYLIMIT <= YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
if (yych == ' ') goto yy57;
if (yych == '=') goto yy55;
if (yych == ' ') goto yy52;
if (yych == '=') goto yy49;
YYCURSOR = YYMARKER;
goto yy51;
goto yy47;
}
#line 374 "ext/standard/url_scanner_ex.re"
#line 379 "ext/standard/url_scanner_ex.re"
state_val:
start = YYCURSOR;
#line 813 "ext/standard/url_scanner_ex.c"
#line 771 "ext/standard/url_scanner_ex.c"
{
YYCTYPE yych;
static const unsigned char yybm[] = {
@@ -817,7 +775,7 @@ state_val:
224, 192, 192, 224, 224, 192, 224, 224,
224, 224, 224, 224, 224, 224, 224, 224,
224, 224, 224, 224, 224, 224, 224, 224,
192, 224, 64, 224, 224, 224, 224, 128,
192, 224, 128, 224, 224, 224, 224, 64,
224, 224, 224, 224, 224, 224, 224, 224,
224, 224, 224, 224, 224, 224, 224, 224,
224, 224, 224, 224, 224, 224, 0, 224,
@@ -848,87 +806,69 @@ state_val:
};
if ((YYLIMIT - YYCURSOR) < 2) YYFILL(2);
yych = *YYCURSOR;
if (yych <= ' ') {
if (yych <= '\f') {
if (yych <= 0x08) goto yy65;
if (yych <= '\n') goto yy67;
goto yy65;
} else {
if (yych <= '\r') goto yy67;
if (yych <= 0x1F) goto yy65;
goto yy67;
}
} else {
if (yych <= '&') {
if (yych != '"') goto yy65;
} else {
if (yych <= '\'') goto yy64;
if (yych == '>') goto yy67;
goto yy65;
}
}
yych = *(YYMARKER = ++YYCURSOR);
if (yych != '>') goto yy76;
yy63:
#line 383 "ext/standard/url_scanner_ex.re"
{ passthru(STD_ARGS); goto state_next_arg_begin; }
#line 876 "ext/standard/url_scanner_ex.c"
yy64:
yych = *(YYMARKER = ++YYCURSOR);
if (yych == '>') goto yy63;
goto yy71;
yy65:
++YYCURSOR;
yych = *YYCURSOR;
goto yy69;
yy66:
#line 382 "ext/standard/url_scanner_ex.re"
{ handle_val(STD_ARGS, 0, ' '); goto state_next_arg_begin; }
#line 888 "ext/standard/url_scanner_ex.c"
yy67:
yych = *++YYCURSOR;
goto yy63;
yy68:
++YYCURSOR;
if (YYLIMIT <= YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
yy69:
if (yybm[0+yych] & 32) {
goto yy68;
goto yy57;
}
goto yy66;
yy70:
if (yych <= ' ') goto yy60;
if (yych <= '"') goto yy62;
if (yych <= '\'') goto yy63;
goto yy60;
yy57:
++YYCURSOR;
if (YYLIMIT <= YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
yy71:
if (yybm[0+yych] & 32) {
goto yy57;
}
#line 387 "ext/standard/url_scanner_ex.re"
{ handle_val(STD_ARGS, 0, ' '); goto state_next_arg_begin; }
#line 826 "ext/standard/url_scanner_ex.c"
yy60:
++YYCURSOR;
yy61:
#line 388 "ext/standard/url_scanner_ex.re"
{ passthru(STD_ARGS); goto state_next_arg_begin; }
#line 832 "ext/standard/url_scanner_ex.c"
yy62:
yych = *(YYMARKER = ++YYCURSOR);
if (yych == '>') goto yy61;
goto yy65;
yy63:
yych = *(YYMARKER = ++YYCURSOR);
if (yych == '>') goto yy61;
goto yy70;
yy64:
++YYCURSOR;
if (YYLIMIT <= YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
yy65:
if (yybm[0+yych] & 64) {
goto yy70;
goto yy64;
}
if (yych <= '\'') goto yy73;
yy72:
if (yych <= '"') goto yy67;
yy66:
YYCURSOR = YYMARKER;
goto yy63;
yy73:
goto yy61;
yy67:
++YYCURSOR;
#line 381 "ext/standard/url_scanner_ex.re"
{ handle_val(STD_ARGS, 1, '\''); goto state_next_arg_begin; }
#line 917 "ext/standard/url_scanner_ex.c"
yy75:
#line 385 "ext/standard/url_scanner_ex.re"
{ handle_val(STD_ARGS, 1, '"'); goto state_next_arg_begin; }
#line 857 "ext/standard/url_scanner_ex.c"
yy69:
++YYCURSOR;
if (YYLIMIT <= YYCURSOR) YYFILL(1);
yych = *YYCURSOR;
yy76:
yy70:
if (yybm[0+yych] & 128) {
goto yy75;
goto yy69;
}
if (yych >= '#') goto yy72;
if (yych >= '(') goto yy66;
++YYCURSOR;
#line 380 "ext/standard/url_scanner_ex.re"
{ handle_val(STD_ARGS, 1, '"'); goto state_next_arg_begin; }
#line 930 "ext/standard/url_scanner_ex.c"
#line 386 "ext/standard/url_scanner_ex.re"
{ handle_val(STD_ARGS, 1, '\''); goto state_next_arg_begin; }
#line 870 "ext/standard/url_scanner_ex.c"
}
#line 384 "ext/standard/url_scanner_ex.re"
#line 389 "ext/standard/url_scanner_ex.re"
stop:
+7 -2
View File
@@ -33,6 +33,7 @@
#include "php_ini.h"
#include "php_globals.h"
#include "php_string.h"
#define STATE_TAG SOME_OTHER_STATE_TAG
#include "basic_functions.h"
#include "url.h"
@@ -122,7 +123,8 @@ static inline void append_modified_url(smart_str *url, smart_str *dest, smart_st
* Don't modify "//example.com" full path, unless
* HTTP_HOST matches.
*/
if (ZSTR_VAL(url->s)[0] == '/' && ZSTR_VAL(url->s)[1] == '/') {
if (ZSTR_LEN(url->s) > 2 && ZSTR_VAL(url->s)[0] == '/' && ZSTR_VAL(url->s)[1] == '/') {
const char *end_chars = "/\"'?>\r\n";
zval *tmp = NULL, *http_host = NULL;
size_t target_len, host_len;
if ((!(tmp = zend_hash_str_find(&EG(symbol_table), ZEND_STRL("_SERVER"))))
@@ -132,10 +134,13 @@ static inline void append_modified_url(smart_str *url, smart_str *dest, smart_st
smart_str_append_smart_str(dest, url);
return;
}
/* HTTP_HOST could be "example.com:8888", etc. */
/* Need to find end of URL in buffer */
host_len = strcspn(Z_STRVAL_P(http_host), ":");
target_len = strcspn(ZSTR_VAL(url->s)+2, "/\"'?>\r\n");
target_len = php_strcspn(
ZSTR_VAL(url->s) + 2, (char *) end_chars,
ZSTR_VAL(url->s) + ZSTR_LEN(url->s), (char *) end_chars + strlen(end_chars));
if (host_len
&& host_len == target_len
&& strncasecmp(Z_STRVAL_P(http_host), ZSTR_VAL(url->s)+2, host_len)) {
+1 -1
View File
@@ -25,5 +25,5 @@ var_dump($zip->close());
@unlink(__DIR__ . '/bug70322.zip');
?>
--EXPECTF--
Warning: ZipArchive::close(): Read error: No such file or directory in %s%ebug70322.php on line %d
Warning: ZipArchive::close(): %s: No such file or directory in %s%ebug70322.php on line %d
bool(false)
+6 -4
View File
@@ -462,6 +462,11 @@ void fcgi_terminate(void)
in_shutdown = 1;
}
void fcgi_request_set_keep(fcgi_request *req, int new_value)
{
req->keep = new_value;
}
#ifndef HAVE_ATTRIBUTE_WEAK
void fcgi_set_logger(fcgi_logger lg) {
fcgi_log = lg;
@@ -1426,8 +1431,6 @@ int fcgi_accept_request(fcgi_request *req)
struct pollfd fds;
int ret;
req->hook.on_read();
fds.fd = req->fd;
fds.events = POLLIN;
fds.revents = 0;
@@ -1440,8 +1443,6 @@ int fcgi_accept_request(fcgi_request *req)
}
fcgi_close(req, 1, 0);
#else
req->hook.on_read();
if (req->fd < FD_SETSIZE) {
struct timeval tv = {5,0};
fd_set set;
@@ -1468,6 +1469,7 @@ int fcgi_accept_request(fcgi_request *req)
} else if (in_shutdown) {
return -1;
}
req->hook.on_read();
if (fcgi_read_request(req)) {
#ifdef _WIN32
if (is_impersonate && !req->tcp) {
+1
View File
@@ -102,6 +102,7 @@ int fcgi_accept_request(fcgi_request *req);
int fcgi_finish_request(fcgi_request *req, int force_close);
const char *fcgi_get_last_client_ip();
void fcgi_set_in_shutdown(int new_value);
void fcgi_request_set_keep(fcgi_request *req, int new_value);
#ifndef HAVE_ATTRIBUTE_WEAK
typedef void (*fcgi_logger)(int type, const char *fmt, ...);
+9 -3
View File
@@ -239,11 +239,14 @@ typedef struct post_var_data {
char *ptr;
char *end;
uint64_t cnt;
/* Bytes in ptr that have already been scanned for '&' */
size_t already_scanned;
} post_var_data_t;
static zend_bool add_post_var(zval *arr, post_var_data_t *var, zend_bool eof)
{
char *ksep, *vsep, *val;
char *start, *ksep, *vsep, *val;
size_t klen, vlen;
size_t new_vlen;
@@ -251,9 +254,11 @@ static zend_bool add_post_var(zval *arr, post_var_data_t *var, zend_bool eof)
return 0;
}
vsep = memchr(var->ptr, '&', var->end - var->ptr);
start = var->ptr + var->already_scanned;
vsep = memchr(start, '&', var->end - start);
if (!vsep) {
if (!eof) {
var->already_scanned = var->end - var->ptr;
return 0;
} else {
vsep = var->end;
@@ -286,6 +291,7 @@ static zend_bool add_post_var(zval *arr, post_var_data_t *var, zend_bool eof)
efree(val);
var->ptr = vsep + (vsep != var->end);
var->already_scanned = 0;
return 1;
}
@@ -305,7 +311,7 @@ static inline int add_post_vars(zval *arr, post_var_data_t *vars, zend_bool eof)
}
}
if (!eof) {
if (!eof && ZSTR_VAL(vars->str.s) != vars->ptr) {
memmove(ZSTR_VAL(vars->str.s), vars->ptr, ZSTR_LEN(vars->str.s) = vars->end - vars->ptr);
}
return SUCCESS;
+4 -4
View File
@@ -2,7 +2,7 @@
/* edit configure.in to change version number */
#define PHP_MAJOR_VERSION 7
#define PHP_MINOR_VERSION 0
#define PHP_RELEASE_VERSION 16
#define PHP_EXTRA_VERSION "-dev"
#define PHP_VERSION "7.0.16-dev"
#define PHP_VERSION_ID 70016
#define PHP_RELEASE_VERSION 17
#define PHP_EXTRA_VERSION ""
#define PHP_VERSION "7.0.17"
#define PHP_VERSION_ID 70017
+3 -3
View File
@@ -252,10 +252,10 @@ PHPAPI php_stream_filter *php_stream_filter_create(const char *filtername, zval
HashTable *filter_hash = (FG(stream_filters) ? FG(stream_filters) : &stream_filters_hash);
php_stream_filter_factory *factory = NULL;
php_stream_filter *filter = NULL;
int n;
size_t n;
char *period;
n = (int)strlen(filtername);
n = strlen(filtername);
if (NULL != (factory = zend_hash_str_find_ptr(filter_hash, filtername, n))) {
filter = factory->create_filter(filtername, filterparams, persistent);
@@ -263,7 +263,7 @@ PHPAPI php_stream_filter *php_stream_filter_create(const char *filtername, zval
/* try a wildcard */
char *wildname;
wildname = emalloc(n+3);
wildname = safe_emalloc(1, n, 3);
memcpy(wildname, filtername, n+1);
period = wildname + (period - filtername);
while (period && !filter) {
+4
View File
@@ -53,6 +53,10 @@
# undef EWOULDBLOCK
# endif
# define EWOULDBLOCK WSAEWOULDBLOCK
# ifdef EMSGSIZE
# undef EMSGSIZE
# endif
# define EMSGSIZE WSAEMSGSIZE
#endif
/* This functions transforms the first char to 'w' if it's not 'r', 'a' or 'w'
+1 -1
View File
@@ -336,7 +336,7 @@ static int php_sockop_set_option(php_stream *stream, int option, int value, void
ret = recv(sock->socket, &buf, sizeof(buf), MSG_PEEK);
err = php_socket_errno();
if (0 == ret || /* the counterpart did properly shutdown*/
(0 > ret && err != EWOULDBLOCK && err != EAGAIN)) { /* there was an unrecoverable error */
(0 > ret && err != EWOULDBLOCK && err != EAGAIN && err != EMSGSIZE)) { /* there was an unrecoverable error */
alive = 0;
}
}
+2 -2
View File
@@ -873,7 +873,7 @@ HELP;
junit_save_xml();
if (getenv('REPORT_EXIT_STATUS') == 1 and $sum_results['FAILED']) {
if (getenv('REPORT_EXIT_STATUS') == 1 && ($sum_results['FAILED'] || $sum_results['BORKED'])) {
exit(1);
}
@@ -1009,7 +1009,7 @@ save_or_mail_results();
junit_save_xml();
if (getenv('REPORT_EXIT_STATUS') == 1 and $sum_results['FAILED']) {
if (getenv('REPORT_EXIT_STATUS') == 1 && ($sum_results['FAILED'] || $sum_results['BORKED'])) {
exit(1);
}
exit(0);
+1
View File
@@ -73,6 +73,7 @@ typedef struct {
zend_bool engine;
zend_bool xbithack;
zend_bool last_modified;
zend_bool post_read_error;
} php_apache2_info_struct;
extern zend_module_entry apache2_module_entry;
+46 -1
View File
@@ -63,6 +63,33 @@
#define PHP_SOURCE_MAGIC_TYPE "application/x-httpd-php-source"
#define PHP_SCRIPT "php7-script"
/* if apache's version is newer than 2.2.31 or 2.4.16 */
#if MODULE_MAGIC_COOKIE == 0x41503232UL && AP_MODULE_MAGIC_AT_LEAST(20051115,40) || \
MODULE_MAGIC_COOKIE == 0x41503234UL && AP_MODULE_MAGIC_AT_LEAST(20120211,47)
#define php_ap_map_http_request_error ap_map_http_request_error
#else
static int php_ap_map_http_request_error(apr_status_t rv, int status)
{
switch (rv) {
case AP_FILTER_ERROR: {
return AP_FILTER_ERROR;
}
case APR_ENOSPC: {
return HTTP_REQUEST_ENTITY_TOO_LARGE;
}
case APR_ENOTIMPL: {
return HTTP_NOT_IMPLEMENTED;
}
case APR_ETIMEDOUT: {
return HTTP_REQUEST_TIME_OUT;
}
default: {
return status;
}
}
}
#endif
/* A way to specify the location of the php.ini dir in an apache directive */
char *apache2_php_ini_path_override = NULL;
#if defined(PHP_WIN32) && defined(ZTS)
@@ -184,6 +211,7 @@ php_apache_sapi_read_post(char *buf, size_t count_bytes)
php_struct *ctx = SG(server_context);
request_rec *r;
apr_bucket_brigade *brigade;
apr_status_t ret;
r = ctx->r;
brigade = ctx->brigade;
@@ -195,7 +223,7 @@ php_apache_sapi_read_post(char *buf, size_t count_bytes)
* need to make sure that if data is available we fill the buffer completely.
*/
while (ap_get_brigade(r->input_filters, brigade, AP_MODE_READBYTES, APR_BLOCK_READ, len) == APR_SUCCESS) {
while ((ret=ap_get_brigade(r->input_filters, brigade, AP_MODE_READBYTES, APR_BLOCK_READ, len)) == APR_SUCCESS) {
apr_brigade_flatten(brigade, buf, &len);
apr_brigade_cleanup(brigade);
tlen += len;
@@ -206,6 +234,15 @@ php_apache_sapi_read_post(char *buf, size_t count_bytes)
len = count_bytes - tlen;
}
if (ret != APR_SUCCESS) {
AP2(post_read_error) = 1;
if (APR_STATUS_IS_TIMEUP(ret)) {
SG(sapi_headers).http_response_code = php_ap_map_http_request_error(ret, HTTP_REQUEST_TIME_OUT);
} else {
SG(sapi_headers).http_response_code = php_ap_map_http_request_error(ret, HTTP_BAD_REQUEST);
}
}
return tlen;
}
@@ -487,6 +524,7 @@ static int php_apache_request_ctor(request_rec *r, php_struct *ctx)
SG(request_info).proto_num = r->proto_num;
SG(request_info).request_uri = apr_pstrdup(r->pool, r->uri);
SG(request_info).path_translated = apr_pstrdup(r->pool, r->filename);
AP2(post_read_error) = 0;
r->no_local_copy = 1;
content_length = (char *) apr_table_get(r->headers_in, "Content-Length");
@@ -656,6 +694,13 @@ zend_first_try {
brigade = ctx->brigade;
}
if (AP2(post_read_error)) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, "Error while attempting to read POST data: %d", SG(sapi_headers).http_response_code);
apr_brigade_cleanup(brigade);
PHPAP_INI_OFF;
return SG(sapi_headers).http_response_code;
}
if (AP2(last_modified)) {
ap_update_mtime(r, r->finfo.mtime);
ap_set_last_modified(r);
+9 -5
View File
@@ -10,11 +10,15 @@ install-fpm: $(SAPI_FPM_PATH)
@$(mkinstalldirs) $(INSTALL_ROOT)$(localstatedir)/run
@$(INSTALL) -m 0755 $(SAPI_FPM_PATH) $(INSTALL_ROOT)$(sbindir)/$(program_prefix)php-fpm$(program_suffix)$(EXEEXT)
@echo "Installing PHP FPM config: $(INSTALL_ROOT)$(sysconfdir)/" && \
$(mkinstalldirs) $(INSTALL_ROOT)$(sysconfdir)/php-fpm.d || :
@$(INSTALL_DATA) sapi/fpm/php-fpm.conf $(INSTALL_ROOT)$(sysconfdir)/php-fpm.conf.default || :
@$(INSTALL_DATA) sapi/fpm/www.conf $(INSTALL_ROOT)$(sysconfdir)/php-fpm.d/www.conf.default || :
@if test -f "$(INSTALL_ROOT)$(sysconfdir)/php-fpm.conf"; then \
echo "Installing PHP FPM defconfig: skipping"; \
else \
echo "Installing PHP FPM defconfig: $(INSTALL_ROOT)$(sysconfdir)/" && \
$(mkinstalldirs) $(INSTALL_ROOT)$(sysconfdir)/php-fpm.d; \
$(INSTALL_DATA) sapi/fpm/php-fpm.conf $(INSTALL_ROOT)$(sysconfdir)/php-fpm.conf.default; \
$(INSTALL_DATA) sapi/fpm/www.conf $(INSTALL_ROOT)$(sysconfdir)/php-fpm.d/www.conf.default; \
fi
@echo "Installing PHP FPM man page: $(INSTALL_ROOT)$(mandir)/man8/"
@$(mkinstalldirs) $(INSTALL_ROOT)$(mandir)/man8
@$(INSTALL_DATA) sapi/fpm/php-fpm.8 $(INSTALL_ROOT)$(mandir)/man8/php-fpm$(program_suffix).8
+2 -1
View File
@@ -1996,7 +1996,8 @@ fastcgi_request_done:
requests++;
if (UNEXPECTED(max_requests && (requests == max_requests))) {
fcgi_finish_request(request, 1);
fcgi_request_set_keep(request, 0);
fcgi_finish_request(request, 0);
break;
}
/* end of fastcgi loop */
+1 -1
View File
@@ -14,7 +14,7 @@ set_time_limit($t);
function f()
{
echo "call";
busy_wait(4);
busy_wait(5);
}
register_shutdown_function("f");
+1 -1
View File
@@ -14,7 +14,7 @@ set_time_limit($t);
function f()
{
echo "call";
busy_wait(4);
busy_wait(5);
}
register_shutdown_function("f");
+13 -4
View File
@@ -29,6 +29,14 @@ MCFILE=$(BUILD_DIR)\wsyslog.rc
BUILD_DIR_DEV_NAME=php-$(PHP_VERSION_STRING)-devel-$(PHP_COMPILER_SHORT)-$(PHP_ARCHITECTURE)
BUILD_DIR_DEV=$(BUILD_DIR)\$(BUILD_DIR_DEV_NAME)
!if "$(DEBUGGER)" == "1"
DEBUGGER_CMD=devenv
DEBUGGER_ARGS=/debugexe
!else
DEBUGGER_CMD=
DEBUGGER_ARGS=
!endif
all: generated_files $(EXT_TARGETS) $(PECL_TARGETS) $(SAPI_TARGETS)
build_dirs: $(BUILD_DIR) $(BUILD_DIRS_SUB) $(BUILD_DIR_DEV)
@@ -151,18 +159,19 @@ clean-pgo: clean-all
-del /f /q $(BUILD_DIR)\pecl-$(PHP_VERSION_STRING)$(PHP_ZTS_ARCHIVE_POSTFIX)-Win32-$(PHP_COMPILER_SHORT)-$(PHP_ARCHITECTURE).zip
-del /f /q $(BUILD_DIR)\php-test-pack-$(PHP_VERSION_STRING).zip
!if $(PHP_TEST_INI_PATH) == ""
test: set-tmp-env
"$(BUILD_DIR)\php.exe" -d open_basedir= -d output_buffering=0 run-tests.php $(TESTS) -p "$(BUILD_DIR)\php.exe"
$(DEBUGGER_CMD) $(DEBUGGER_ARGS) "$(BUILD_DIR)\php.exe" -d open_basedir= -d output_buffering=0 run-tests.php $(TESTS) -p "$(BUILD_DIR)\php.exe"
run: set-tmp-env
"$(BUILD_DIR)\php.exe" $(ARGS)
$(DEBUGGER_CMD) $(DEBUGGER_ARGS) "$(BUILD_DIR)\php.exe" $(ARGS)
!else
test: set-tmp-env
"$(BUILD_DIR)\php.exe" -n -c $(PHP_TEST_INI_PATH) -d open_basedir= -d output_buffering=0 -d memory_limit=-1 run-tests.php -p "$(BUILD_DIR)\php.exe" -n -c $(PHP_TEST_INI_PATH) $(TESTS)
$(DEBUGGER_CMD) $(DEBUGGER_ARGS) "$(BUILD_DIR)\php.exe" -n -c $(PHP_TEST_INI_PATH) -d open_basedir= -d output_buffering=0 -d memory_limit=-1 run-tests.php -p "$(BUILD_DIR)\php.exe" -n -c $(PHP_TEST_INI_PATH) $(TESTS)
run: set-tmp-env
"$(BUILD_DIR)\php.exe" -n -c $(PHP_TEST_INI_PATH) $(ARGS)
$(DEBUGGER_CMD) $(DEBUGGER_ARGS) "$(BUILD_DIR)\php.exe" -n -c $(PHP_TEST_INI_PATH) $(ARGS)
!endif
build-snap: set-tmp-env generated_files
+28 -13
View File
@@ -49,6 +49,8 @@
#include "ext/standard/php_string.h"
#include "ext/date/php_date.h"
#define SENDMAIL_DEBUG 0
/*enum
{
DO_CONNECT = WM_USER +1
@@ -171,7 +173,7 @@ static zend_string *php_win32_mail_trim_header(char *header)
regex = zend_string_init(PHP_WIN32_MAIL_RMVDBL_PATTERN, sizeof(PHP_WIN32_MAIL_RMVDBL_PATTERN)-1, 0);
result2 = php_pcre_replace(regex,
result, result->val, (int)result->len,
result, ZSTR_VAL(result), (int)ZSTR_LEN(result),
&replace,
0,
-1,
@@ -206,7 +208,7 @@ PHPAPI int TSendMail(char *host, int *error, char **error_message,
{
int ret;
char *RPath = NULL;
zend_string *headers_lc = NULL; /* headers_lc is only created if we've a header at all */
zend_string *headers_lc = NULL, *headers_trim = NULL; /* headers_lc is only created if we've a header at all */
char *pos1 = NULL, *pos2 = NULL;
if (host == NULL) {
@@ -221,19 +223,16 @@ PHPAPI int TSendMail(char *host, int *error, char **error_message,
if (headers) {
char *pos = NULL;
size_t i;
/* Use PCRE to trim the header into the right format */
if (NULL == (headers_lc = php_win32_mail_trim_header(headers))) {
if (NULL == (headers_trim = php_win32_mail_trim_header(headers))) {
*error = W32_SM_PCRE_ERROR;
return FAILURE;
}
/* Create a lowercased header for all the searches so we're finally case
* insensitive when searching for a pattern. */
for (i = 0; i < headers_lc->len; i++) {
headers_lc->val[i] = tolower(headers_lc->val[i]);
}
headers_lc = zend_string_tolower(headers_trim);
}
/* Fall back to sendmail_from php.ini setting */
@@ -243,14 +242,14 @@ PHPAPI int TSendMail(char *host, int *error, char **error_message,
RPath = estrdup(INI_STR("sendmail_from"));
} else if (headers_lc) {
int found = 0;
char *lookup = headers_lc->val;
char *lookup = ZSTR_VAL(headers_lc);
while (lookup) {
pos1 = strstr(lookup, "from:");
if (!pos1) {
break;
} else if (pos1 != headers_lc->val && *(pos1-1) != '\n') {
} else if (pos1 != ZSTR_VAL(headers_lc) && *(pos1-1) != '\n') {
if (strlen(pos1) >= sizeof("from:")) {
lookup = pos1 + sizeof("from:");
continue;
@@ -290,6 +289,7 @@ PHPAPI int TSendMail(char *host, int *error, char **error_message,
efree(RPath);
}
if (headers) {
zend_string_free(headers_trim);
zend_string_free(headers_lc);
}
/* 128 is safe here, the specifier in snprintf isn't longer than that */
@@ -302,12 +302,13 @@ PHPAPI int TSendMail(char *host, int *error, char **error_message,
PW32G(mail_host), !INI_INT("smtp_port") ? 25 : INI_INT("smtp_port"));
return FAILURE;
} else {
ret = SendText(RPath, Subject, mailTo, mailCc, mailBcc, data, headers, headers_lc->val, error_message);
ret = SendText(RPath, Subject, mailTo, mailCc, mailBcc, data, headers ? ZSTR_VAL(headers_trim) : NULL, headers ? ZSTR_VAL(headers_lc) : NULL, error_message);
TSMClose();
if (RPath) {
efree(RPath);
}
if (headers) {
zend_string_free(headers_trim);
zend_string_free(headers_lc);
}
if (ret != SUCCESS) {
@@ -633,8 +634,8 @@ static int SendText(char *RPath, char *Subject, char *mailTo, char *mailCc, char
/* send message contents in 1024 chunks */
{
char c, *e2, *e = data_cln->val + data_cln->len;
p = data_cln->val;
char c, *e2, *e = ZSTR_VAL(data_cln) + ZSTR_LEN(data_cln);
p = ZSTR_VAL(data_cln);
while (e - p > 1024) {
e2 = p + 1024;
@@ -711,7 +712,7 @@ static int PostHeader(char *RPath, char *Subject, char *mailTo, char *xheaders)
time_t tNow = time(NULL);
zend_string *dt = php_format_date("r", 1, tNow, 1);
snprintf(header_buffer, MAIL_BUFFER_SIZE, "Date: %s\r\n", dt->val);
snprintf(header_buffer, MAIL_BUFFER_SIZE, "Date: %s\r\n", ZSTR_VAL(dt));
zend_string_free(dt);
}
@@ -780,6 +781,10 @@ static int MailConnect()
#endif
SOCKADDR_IN sock_in;
#if SENDMAIL_DEBUG
return 0;
#endif
/* Create Socket */
if ((PW32G(mail_socket) = socket(PF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET) {
return (FAILED_TO_OBTAIN_SOCKET_HANDLE);
@@ -866,6 +871,12 @@ static int Post(LPCSTR msg)
int slen;
int index = 0;
#if SENDMAIL_DEBUG
if (msg)
printf("POST: '%s'\n", msg);
return (SUCCESS);
#endif
while (len > 0) {
if ((slen = send(PW32G(mail_socket), msg + index, len, 0)) < 1)
return (FAILED_TO_SEND);
@@ -894,6 +905,10 @@ static int Ack(char **server_response)
int Index = 0;
int Received = 0;
#if SENDMAIL_DEBUG
return (SUCCESS);
#endif
again:
if ((rlen = recv(PW32G(mail_socket), buf + Index, ((MAIL_BUFFER_SIZE) - 1) - Received, 0)) < 1) {