summaryrefslogtreecommitdiff
path: root/ext/standard
diff options
context:
space:
mode:
Diffstat (limited to 'ext/standard')
-rw-r--r--ext/standard/array.c115
-rw-r--r--ext/standard/basic_functions.c13
-rw-r--r--ext/standard/basic_functions.h20
-rw-r--r--ext/standard/crc32.c4
-rw-r--r--ext/standard/exec.c75
-rw-r--r--ext/standard/exec.h1
-rw-r--r--ext/standard/incomplete_class.c3
-rw-r--r--ext/standard/iptc.c16
-rw-r--r--ext/standard/lcg.c4
-rw-r--r--ext/standard/math.c12
-rw-r--r--ext/standard/md5.c20
-rw-r--r--ext/standard/md5.h6
-rw-r--r--ext/standard/pack.c2
-rw-r--r--ext/standard/php_crypt_r.c2
-rw-r--r--ext/standard/php_lcg.h4
-rw-r--r--ext/standard/php_rand.h4
-rw-r--r--ext/standard/php_smart_string.h4
-rw-r--r--ext/standard/rand.c18
-rw-r--r--ext/standard/sha1.c38
-rw-r--r--ext/standard/sha1.h4
-rw-r--r--ext/standard/streamsfuncs.c11
-rw-r--r--ext/standard/string.c55
-rw-r--r--ext/standard/tests/array/bug71603.phpt15
-rw-r--r--ext/standard/tests/array/bug71660.phpt18
-rw-r--r--ext/standard/tests/array/range_bug71132.phpt10
-rw-r--r--ext/standard/tests/array/range_bug71197.phpt8
-rw-r--r--ext/standard/tests/class_object/bug71442.phpt37
-rw-r--r--ext/standard/tests/file/stream_rfc2397_002.phpt56
-rw-r--r--ext/standard/tests/general_functions/escapeshellarg_bug71039.phpt10
-rw-r--r--ext/standard/tests/general_functions/escapeshellarg_bug71270.phpt12
-rw-r--r--ext/standard/tests/general_functions/escapeshellcmd_bug71039.phpt10
-rw-r--r--ext/standard/tests/general_functions/escapeshellcmd_bug71270.phpt12
-rw-r--r--ext/standard/tests/general_functions/var_export_bug71314.phpt15
-rw-r--r--ext/standard/tests/math/mt_rand_value.phpt44
-rw-r--r--ext/standard/tests/network/socket_get_status_basic.phpt12
-rw-r--r--ext/standard/tests/serialize/bug71311.phpt16
-rw-r--r--ext/standard/tests/serialize/bug71313.phpt14
-rw-r--r--ext/standard/tests/streams/bug71323.phpt31
-rw-r--r--ext/standard/tests/streams/stream_get_meta_data_dir_basic.phpt16
-rw-r--r--ext/standard/tests/streams/stream_get_meta_data_file_basic.phpt12
-rw-r--r--ext/standard/tests/streams/stream_get_meta_data_file_variation1.phpt104
-rw-r--r--ext/standard/tests/streams/stream_get_meta_data_file_variation2.phpt46
-rw-r--r--ext/standard/tests/streams/stream_get_meta_data_file_variation4.phpt20
-rw-r--r--ext/standard/tests/streams/stream_get_meta_data_file_variation5.phpt24
-rw-r--r--ext/standard/tests/streams/stream_get_meta_data_process_basic.phpt12
-rw-r--r--ext/standard/tests/streams/stream_get_meta_data_socket_basic.phpt12
-rw-r--r--ext/standard/tests/streams/stream_get_meta_data_socket_variation1.phpt44
-rw-r--r--ext/standard/tests/streams/stream_get_meta_data_socket_variation2.phpt46
-rw-r--r--ext/standard/tests/streams/stream_get_meta_data_socket_variation3.phpt36
-rw-r--r--ext/standard/tests/streams/stream_get_meta_data_socket_variation4.phpt34
-rw-r--r--ext/standard/tests/streams/stream_socket_enable_crypto-win32.phpt70
-rw-r--r--ext/standard/tests/streams/stream_socket_enable_crypto.phpt14
-rw-r--r--ext/standard/tests/strings/bug53021.phpt6
-rw-r--r--ext/standard/tests/strings/bug70720.phpt6
-rw-r--r--ext/standard/tests/strings/html_entity_decode3.phpt45
-rw-r--r--ext/standard/var.c13
-rw-r--r--ext/standard/var_unserializer.c59
-rw-r--r--ext/standard/var_unserializer.re4
58 files changed, 945 insertions, 429 deletions
diff --git a/ext/standard/array.c b/ext/standard/array.c
index 30ca0508a9..3e9ecdfd46 100644
--- a/ext/standard/array.c
+++ b/ext/standard/array.c
@@ -46,9 +46,7 @@
#include "php_string.h"
#include "php_rand.h"
#include "zend_smart_str.h"
-#ifdef HAVE_SPL
#include "ext/spl/spl_array.h"
-#endif
/* {{{ defines */
#define EXTR_OVERWRITE 0
@@ -81,8 +79,6 @@
#define INTERSECT_COMP_DATA_USER 1
#define INTERSECT_COMP_KEY_INTERNAL 0
#define INTERSECT_COMP_KEY_USER 1
-
-#define DOUBLE_DRIFT_FIX 0.000000000000001
/* }}} */
ZEND_DECLARE_MODULE_GLOBALS(array)
@@ -272,7 +268,7 @@ static int php_array_key_compare_string(const void *a, const void *b) /* {{{ */
l2 = s->key->len;
} else {
s2 = zend_print_long_to_buf(buf2 + sizeof(buf2) - 1, s->h);
- l2 = buf2 + sizeof(buf2) - 1 - s1;
+ l2 = buf2 + sizeof(buf2) - 1 - s2;
}
return zend_binary_strcmp(s1, l1, s2, l2);
}
@@ -823,9 +819,7 @@ PHP_FUNCTION(count)
RETURN_LONG(cnt);
break;
case IS_OBJECT: {
-#ifdef HAVE_SPL
zval retval;
-#endif
/* first, we check if the handler is defined */
if (Z_OBJ_HT_P(array)->count_elements) {
RETVAL_LONG(1);
@@ -833,7 +827,6 @@ PHP_FUNCTION(count)
return;
}
}
-#ifdef HAVE_SPL
/* if not and the object implements Countable we call its count() method */
if (instanceof_function(Z_OBJCE_P(array), spl_ce_Countable)) {
zend_call_method_with_0_params(array, NULL, NULL, "count", &retval);
@@ -843,7 +836,6 @@ PHP_FUNCTION(count)
}
return;
}
-#endif
}
default:
RETURN_LONG(1);
@@ -1773,7 +1765,7 @@ PHPAPI int php_prefix_varname(zval *result, zval *prefix, char *var_name, size_t
Imports variables into symbol table from an array */
PHP_FUNCTION(extract)
{
- zval *var_array, *prefix = NULL;
+ zval *var_array_param, *prefix = NULL;
zend_long extract_type = EXTR_OVERWRITE;
zval *entry;
zend_string *var_name;
@@ -1781,14 +1773,15 @@ PHP_FUNCTION(extract)
int var_exists, count = 0;
int extract_refs = 0;
zend_array *symbol_table;
+ zval var_array;
#ifndef FAST_ZPP
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "a|lz/", &var_array, &extract_type, &prefix) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "a|lz/", &var_array_param, &extract_type, &prefix) == FAILURE) {
return;
}
#else
ZEND_PARSE_PARAMETERS_START(1, 3)
- Z_PARAM_ARRAY(var_array)
+ Z_PARAM_ARRAY(var_array_param)
Z_PARAM_OPTIONAL
Z_PARAM_LONG(extract_type)
Z_PARAM_ZVAL_EX(prefix, 0, 1)
@@ -1797,7 +1790,7 @@ PHP_FUNCTION(extract)
extract_refs = (extract_type & EXTR_REFS);
if (extract_refs) {
- SEPARATE_ZVAL(var_array);
+ SEPARATE_ZVAL(var_array_param);
}
extract_type &= 0xff;
@@ -1827,7 +1820,11 @@ PHP_FUNCTION(extract)
}
#endif
- ZEND_HASH_FOREACH_KEY_VAL_IND(Z_ARRVAL_P(var_array), num_key, var_name, entry) {
+ /* The array might be stored in a local variable that will be overwritten. To avoid losing the
+ * reference in that case we work on a copy. */
+ ZVAL_COPY(&var_array, var_array_param);
+
+ ZEND_HASH_FOREACH_KEY_VAL_IND(Z_ARRVAL(var_array), num_key, var_name, entry) {
zval final_name;
ZVAL_NULL(&final_name);
@@ -1928,6 +1925,7 @@ PHP_FUNCTION(extract)
}
zval_dtor(&final_name);
} ZEND_HASH_FOREACH_END();
+ zval_ptr_dtor(&var_array);
RETURN_LONG(count);
}
@@ -1940,6 +1938,7 @@ static void php_compact_var(HashTable *eg_active_symbol_table, zval *return_valu
ZVAL_DEREF(entry);
if (Z_TYPE_P(entry) == IS_STRING) {
if ((value_ptr = zend_hash_find_ind(eg_active_symbol_table, Z_STR_P(entry))) != NULL) {
+ ZVAL_DEREF(value_ptr);
ZVAL_COPY(&data, value_ptr);
zend_hash_update(Z_ARRVAL_P(return_value), Z_STR_P(entry), &data);
}
@@ -2061,13 +2060,25 @@ PHP_FUNCTION(array_fill_keys)
}
/* }}} */
-#define RANGE_CHECK_INIT_ARRAY(start, end) do { \
+#define RANGE_CHECK_DOUBLE_INIT_ARRAY(start, end) do { \
double __calc_size = ((start - end) / step) + 1; \
- if (fabs(__calc_size) >= (double)HT_MAX_SIZE) { \
- php_error_docref(NULL, E_WARNING, "The supplied range exceeds the maximum array size: start=%0.0f end=%0.0f", start > end ? end : start, start > end ? start : end); \
+ if (__calc_size >= (double)HT_MAX_SIZE) { \
+ php_error_docref(NULL, E_WARNING, "The supplied range exceeds the maximum array size: start=%0.0f end=%0.0f", end, start); \
+ RETURN_FALSE; \
+ } \
+ size = (uint32_t)__calc_size; \
+ array_init_size(return_value, size); \
+ zend_hash_real_init(Z_ARRVAL_P(return_value), 1); \
+ } while (0)
+
+#define RANGE_CHECK_LONG_INIT_ARRAY(start, end) do { \
+ zend_ulong __calc_size = (start - end) / lstep; \
+ if (__calc_size >= HT_MAX_SIZE - 1) { \
+ php_error_docref(NULL, E_WARNING, "The supplied range exceeds the maximum array size: start=%pd end=%pd", end, start); \
RETURN_FALSE; \
} \
- array_init_size(return_value, (uint32_t)fabs(__calc_size)); \
+ size = (uint32_t)(__calc_size + 1); \
+ array_init_size(return_value, size); \
zend_hash_real_init(Z_ARRVAL_P(return_value), 1); \
} while (0)
@@ -2167,12 +2178,11 @@ PHP_FUNCTION(range)
zend_hash_next_index_insert_new(Z_ARRVAL_P(return_value), &tmp);
}
} else if (Z_TYPE_P(zlow) == IS_DOUBLE || Z_TYPE_P(zhigh) == IS_DOUBLE || is_step_double) {
- double low, high, value;
- zend_long i;
+ double low, high;
+ uint32_t i, size;
double_str:
low = zval_get_double(zlow);
high = zval_get_double(zhigh);
- i = 0;
if (zend_isinf(high) || zend_isinf(low)) {
php_error_docref(NULL, E_WARNING, "Invalid range supplied: start=%0.0f end=%0.0f", low, high);
@@ -2186,12 +2196,13 @@ double_str:
goto err;
}
- RANGE_CHECK_INIT_ARRAY(low, high);
+ RANGE_CHECK_DOUBLE_INIT_ARRAY(low, high);
+
ZEND_HASH_FILL_PACKED(Z_ARRVAL_P(return_value)) {
- for (value = low; value >= (high - DOUBLE_DRIFT_FIX); value = low - (++i * step)) {
- Z_DVAL(tmp) = value;
- ZEND_HASH_FILL_ADD(&tmp);
- }
+ for (i = 0; i < size; ++i) {
+ Z_DVAL(tmp) = low - (i * step);
+ ZEND_HASH_FILL_ADD(&tmp);
+ }
} ZEND_HASH_FILL_END();
} else if (high > low) { /* Positive steps */
if (high - low < step || step <= 0) {
@@ -2199,10 +2210,11 @@ double_str:
goto err;
}
- RANGE_CHECK_INIT_ARRAY(high, low);
+ RANGE_CHECK_DOUBLE_INIT_ARRAY(high, low);
+
ZEND_HASH_FILL_PACKED(Z_ARRVAL_P(return_value)) {
- for (value = low; value <= (high + DOUBLE_DRIFT_FIX); value = low + (++i * step)) {
- Z_DVAL(tmp) = value;
+ for (i = 0; i < size; ++i) {
+ Z_DVAL(tmp) = low + (i * step);
ZEND_HASH_FILL_ADD(&tmp);
}
} ZEND_HASH_FILL_END();
@@ -2212,43 +2224,53 @@ double_str:
zend_hash_next_index_insert_new(Z_ARRVAL_P(return_value), &tmp);
}
} else {
- double low, high;
- zend_long lstep;
+ zend_long low, high;
+ /* lstep is a ulong so that comparisons to it don't overflow, i.e. low - high < lstep */
+ zend_ulong lstep;
+ uint32_t i, size;
long_str:
- low = zval_get_double(zlow);
- high = zval_get_double(zhigh);
- lstep = (zend_long) step;
+ low = zval_get_long(zlow);
+ high = zval_get_long(zhigh);
+
+ if (step <= 0) {
+ err = 1;
+ goto err;
+ }
+
+ lstep = step;
Z_TYPE_INFO(tmp) = IS_LONG;
if (low > high) { /* Negative steps */
- if (low - high < lstep || lstep <= 0) {
+ if (low - high < lstep) {
err = 1;
goto err;
}
- RANGE_CHECK_INIT_ARRAY(low, high);
+ RANGE_CHECK_LONG_INIT_ARRAY(low, high);
+
ZEND_HASH_FILL_PACKED(Z_ARRVAL_P(return_value)) {
- for (; low >= high; low -= lstep) {
- Z_LVAL(tmp) = (zend_long)low;
+ for (i = 0; i < size; ++i) {
+ Z_LVAL(tmp) = low - (i * lstep);
ZEND_HASH_FILL_ADD(&tmp);
}
} ZEND_HASH_FILL_END();
} else if (high > low) { /* Positive steps */
- if (high - low < lstep || lstep <= 0) {
+ if (high - low < lstep) {
err = 1;
goto err;
}
- RANGE_CHECK_INIT_ARRAY(high, low);
+ RANGE_CHECK_LONG_INIT_ARRAY(high, low);
+
ZEND_HASH_FILL_PACKED(Z_ARRVAL_P(return_value)) {
- for (; low <= high; low += lstep) {
- Z_LVAL(tmp) = (zend_long)low;
+ for (i = 0; i < size; ++i) {
+ Z_LVAL(tmp) = low + (i * lstep);
ZEND_HASH_FILL_ADD(&tmp);
}
} ZEND_HASH_FILL_END();
} else {
array_init(return_value);
- Z_LVAL(tmp) = (zend_long)low;
+ Z_LVAL(tmp) = low;
zend_hash_next_index_insert_new(Z_ARRVAL_P(return_value), &tmp);
}
}
@@ -2260,7 +2282,8 @@ err:
}
/* }}} */
-#undef RANGE_CHECK_INIT_ARRAY
+#undef RANGE_CHECK_DOUBLE_INIT_ARRAY
+#undef RANGE_CHECK_LONG_INIT_ARRAY
static void php_array_data_shuffle(zval *array) /* {{{ */
{
@@ -3469,6 +3492,10 @@ static inline zval *array_column_fetch_prop(zval *data, zval *name, zval *rv)
}
}
+ if (prop) {
+ ZVAL_DEREF(prop);
+ }
+
return prop;
}
diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c
index f03793c13f..f8121c1ebf 100644
--- a/ext/standard/basic_functions.c
+++ b/ext/standard/basic_functions.c
@@ -3493,8 +3493,8 @@ PHPAPI double php_get_nan(void) /* {{{ */
return HUGE_VAL + -HUGE_VAL;
#elif defined(__i386__) || defined(_X86_) || defined(ALPHA) || defined(_ALPHA) || defined(__alpha)
double val = 0.0;
- ((php_uint32*)&val)[1] = PHP_DOUBLE_QUIET_NAN_HIGH;
- ((php_uint32*)&val)[0] = 0;
+ ((uint32_t*)&val)[1] = PHP_DOUBLE_QUIET_NAN_HIGH;
+ ((uint32_t*)&val)[0] = 0;
return val;
#elif HAVE_ATOF_ACCEPTS_NAN
return atof("NAN");
@@ -3510,8 +3510,8 @@ PHPAPI double php_get_inf(void) /* {{{ */
return HUGE_VAL;
#elif defined(__i386__) || defined(_X86_) || defined(ALPHA) || defined(_ALPHA) || defined(__alpha)
double val = 0.0;
- ((php_uint32*)&val)[1] = PHP_DOUBLE_INFINITY_HIGH;
- ((php_uint32*)&val)[0] = 0;
+ ((uint32_t*)&val)[1] = PHP_DOUBLE_INFINITY_HIGH;
+ ((uint32_t*)&val)[0] = 0;
return val;
#elif HAVE_ATOF_ACCEPTS_INF
return atof("INF");
@@ -3659,6 +3659,7 @@ PHP_MINIT_FUNCTION(basic) /* {{{ */
#ifdef PHP_CAN_SUPPORT_PROC_OPEN
BASIC_MINIT_SUBMODULE(proc_open)
#endif
+ BASIC_MINIT_SUBMODULE(exec)
BASIC_MINIT_SUBMODULE(user_streams)
BASIC_MINIT_SUBMODULE(imagetypes)
@@ -4839,7 +4840,7 @@ PHP_FUNCTION(forward_static_call)
fci.retval = &retval;
called_scope = zend_get_called_scope(execute_data);
- if (called_scope &&
+ if (called_scope && fci_cache.calling_scope &&
instanceof_function(called_scope, fci_cache.calling_scope)) {
fci_cache.called_scope = called_scope;
}
@@ -4867,7 +4868,7 @@ PHP_FUNCTION(forward_static_call_array)
fci.retval = &retval;
called_scope = zend_get_called_scope(execute_data);
- if (called_scope &&
+ if (called_scope && fci_cache.calling_scope &&
instanceof_function(called_scope, fci_cache.calling_scope)) {
fci_cache.called_scope = called_scope;
}
diff --git a/ext/standard/basic_functions.h b/ext/standard/basic_functions.h
index 774f85dd1a..e37bca31d6 100644
--- a/ext/standard/basic_functions.h
+++ b/ext/standard/basic_functions.h
@@ -149,20 +149,12 @@ PHPAPI int _php_error_log(int opt_err, char *message, char *opt, char *headers);
PHPAPI int _php_error_log_ex(int opt_err, char *message, size_t message_len, char *opt, char *headers);
PHPAPI int php_prefix_varname(zval *result, zval *prefix, char *var_name, size_t var_name_len, zend_bool add_underscore);
-#if SIZEOF_INT == 4
-/* Most 32-bit and 64-bit systems have 32-bit ints */
-typedef unsigned int php_uint32;
-typedef signed int php_int32;
-#elif SIZEOF_LONG == 4
-/* 16-bit systems? */
-typedef unsigned long php_uint32;
-typedef signed long php_int32;
-#else
-#error Need type which holds 32 bits
-#endif
-
#define MT_N (624)
+/* Deprecated type aliases -- use the standard types instead */
+typedef uint32_t php_uint32;
+typedef int32_t php_int32;
+
typedef struct _php_basic_globals {
HashTable *user_shutdown_function_names;
HashTable putenv_ht;
@@ -193,8 +185,8 @@ typedef struct _php_basic_globals {
php_stream_statbuf ssb, lssb;
/* rand.c */
- php_uint32 state[MT_N+1]; /* state vector + 1 extra to not violate ANSI C */
- php_uint32 *next; /* next random value is computed from here */
+ uint32_t state[MT_N+1]; /* state vector + 1 extra to not violate ANSI C */
+ uint32_t *next; /* next random value is computed from here */
int left; /* can *next++ this many times before reloading */
unsigned int rand_seed; /* Seed for rand(), in ts version */
diff --git a/ext/standard/crc32.c b/ext/standard/crc32.c
index 45a2eb0667..e6024dcf11 100644
--- a/ext/standard/crc32.c
+++ b/ext/standard/crc32.c
@@ -28,8 +28,8 @@ PHP_NAMED_FUNCTION(php_if_crc32)
{
char *p;
size_t nr;
- php_uint32 crcinit = 0;
- register php_uint32 crc;
+ uint32_t crcinit = 0;
+ register uint32_t crc;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s", &p, &nr) == FAILURE) {
return;
diff --git a/ext/standard/exec.c b/ext/standard/exec.c
index c4afce3337..a73d0b4e6e 100644
--- a/ext/standard/exec.c
+++ b/ext/standard/exec.c
@@ -46,10 +46,43 @@
#include <fcntl.h>
#endif
-#if HAVE_NICE && HAVE_UNISTD_H
+#if HAVE_UNISTD_H
#include <unistd.h>
#endif
+#if HAVE_LIMITS_H
+#include <limits.h>
+#endif
+
+static int cmd_max_len;
+
+/* {{{ PHP_MINIT_FUNCTION(exec) */
+PHP_MINIT_FUNCTION(exec)
+{
+#ifdef _SC_ARG_MAX
+ cmd_max_len = sysconf(_SC_ARG_MAX);
+ if (-1 == cmd_max_len) {
+#ifdef _POSIX_ARG_MAX
+ cmd_max_len = _POSIX_ARG_MAX;
+#else
+ cmd_max_len = 4096;
+#endif
+ }
+#elif defined(ARG_MAX)
+ cmd_max_len = ARG_MAX;
+#elif defined(PHP_WIN32)
+ /* Executed commands will run through cmd.exe. As long as it's the case,
+ it's just the constant limit.*/
+ cmd_max_len = 8192;
+#else
+ /* This is just an arbitrary value for the fallback case. */
+ cmd_max_len = 4096;
+#endif
+
+ return SUCCESS;
+}
+/* }}} */
+
/* {{{ php_exec
* If type==0, only last line of output is returned (exec)
* If type==1, all lines will be printed and last lined returned (system)
@@ -245,13 +278,19 @@ PHP_FUNCTION(passthru)
*/
PHPAPI zend_string *php_escape_shell_cmd(char *str)
{
- register int x, y, l = (int)strlen(str);
- size_t estimate = (2 * l) + 1;
+ register int x, y;
+ size_t l = strlen(str);
+ uint64_t estimate = (2 * (uint64_t)l) + 1;
zend_string *cmd;
#ifndef PHP_WIN32
char *p = NULL;
#endif
+ /* max command line length - two single quotes - \0 byte length */
+ if (l > cmd_max_len - 2 - 1) {
+ php_error_docref(NULL, E_ERROR, "Command exceeds the allowed length of %d bytes", cmd_max_len);
+ return ZSTR_EMPTY_ALLOC();
+ }
cmd = zend_string_safe_alloc(2, l, 0, 0);
@@ -324,6 +363,12 @@ PHPAPI zend_string *php_escape_shell_cmd(char *str)
}
ZSTR_VAL(cmd)[y] = '\0';
+ if (y - 1 > cmd_max_len) {
+ php_error_docref(NULL, E_ERROR, "Escaped command exceeds the allowed length of %d bytes", cmd_max_len);
+ zend_string_release(cmd);
+ return ZSTR_EMPTY_ALLOC();
+ }
+
if ((estimate - y) > 4096) {
/* realloc if the estimate was way overill
* Arbitrary cutoff point of 4096 */
@@ -340,10 +385,16 @@ PHPAPI zend_string *php_escape_shell_cmd(char *str)
*/
PHPAPI zend_string *php_escape_shell_arg(char *str)
{
- int x, y = 0, l = (int)strlen(str);
+ int x, y = 0;
+ size_t l = strlen(str);
zend_string *cmd;
- size_t estimate = (4 * l) + 3;
+ uint64_t estimate = (4 * (uint64_t)l) + 3;
+ /* max command line length - two single quotes - \0 byte length */
+ if (l > cmd_max_len - 2 - 1) {
+ php_error_docref(NULL, E_ERROR, "Argument exceeds the allowed length of %d bytes", cmd_max_len);
+ return ZSTR_EMPTY_ALLOC();
+ }
cmd = zend_string_safe_alloc(4, l, 2, 0); /* worst case */
@@ -399,6 +450,12 @@ PHPAPI zend_string *php_escape_shell_arg(char *str)
#endif
ZSTR_VAL(cmd)[y] = '\0';
+ if (y - 1 > cmd_max_len) {
+ php_error_docref(NULL, E_ERROR, "Escaped argument exceeds the allowed length of %d bytes", cmd_max_len);
+ zend_string_release(cmd);
+ return ZSTR_EMPTY_ALLOC();
+ }
+
if ((estimate - y) > 4096) {
/* realloc if the estimate was way overill
* Arbitrary cutoff point of 4096 */
@@ -421,6 +478,10 @@ PHP_FUNCTION(escapeshellcmd)
}
if (command_len) {
+ if (command_len != strlen(command)) {
+ php_error_docref(NULL, E_ERROR, "Input string contains NULL bytes");
+ return;
+ }
RETVAL_STR(php_escape_shell_cmd(command));
} else {
RETVAL_EMPTY_STRING();
@@ -440,6 +501,10 @@ PHP_FUNCTION(escapeshellarg)
}
if (argument) {
+ if (argument_len != strlen(argument)) {
+ php_error_docref(NULL, E_ERROR, "Input string contains NULL bytes");
+ return;
+ }
RETVAL_STR(php_escape_shell_arg(argument));
}
}
diff --git a/ext/standard/exec.h b/ext/standard/exec.h
index e53abf8145..b1cbf29c13 100644
--- a/ext/standard/exec.h
+++ b/ext/standard/exec.h
@@ -33,6 +33,7 @@ PHP_FUNCTION(proc_close);
PHP_FUNCTION(proc_terminate);
PHP_FUNCTION(proc_nice);
PHP_MINIT_FUNCTION(proc_open);
+PHP_MINIT_FUNCTION(exec);
PHPAPI zend_string *php_escape_shell_cmd(char *);
PHPAPI zend_string *php_escape_shell_arg(char *);
diff --git a/ext/standard/incomplete_class.c b/ext/standard/incomplete_class.c
index 887f209299..d327602e75 100644
--- a/ext/standard/incomplete_class.c
+++ b/ext/standard/incomplete_class.c
@@ -54,7 +54,8 @@ static zval *incomplete_class_get_property(zval *object, zval *member, int type,
incomplete_class_message(object, E_NOTICE);
if (type == BP_VAR_W || type == BP_VAR_RW) {
- return &EG(error_zval);
+ ZVAL_ERROR(rv);
+ return rv;
} else {
return &EG(uninitialized_zval);
}
diff --git a/ext/standard/iptc.c b/ext/standard/iptc.c
index a3547067f6..7e5a8987b4 100644
--- a/ext/standard/iptc.c
+++ b/ext/standard/iptc.c
@@ -38,6 +38,15 @@
#include <sys/stat.h>
+#ifdef PHP_WIN32
+# include "win32/php_stdint.h"
+#else
+# if HAVE_INTTYPES_H
+# include <inttypes.h>
+# elif HAVE_STDINT_H
+# include <stdint.h>
+# endif
+#endif
/* some defines for the different JPEG block types */
#define M_SOF0 0xC0 /* Start Of Frame N */
@@ -196,6 +205,11 @@ PHP_FUNCTION(iptcembed)
RETURN_FALSE;
}
+ if (iptcdata_len >= SIZE_MAX - sizeof(psheader) - 1025) {
+ php_error_docref(NULL, E_WARNING, "IPTC data too large");
+ RETURN_FALSE;
+ }
+
if ((fp = VCWD_FOPEN(jpeg_file, "rb")) == 0) {
php_error_docref(NULL, E_WARNING, "Unable to open %s", jpeg_file);
RETURN_FALSE;
@@ -204,7 +218,7 @@ PHP_FUNCTION(iptcembed)
if (spool < 2) {
zend_fstat(fileno(fp), &sb);
- spoolbuf = zend_string_alloc(iptcdata_len + sizeof(psheader) + sb.st_size + 1024, 0);
+ spoolbuf = zend_string_safe_alloc(1, iptcdata_len + sizeof(psheader) + 1024 + 1, sb.st_size, 0);
poi = (unsigned char*)ZSTR_VAL(spoolbuf);
memset(poi, 0, iptcdata_len + sizeof(psheader) + sb.st_size + 1024 + 1);
}
diff --git a/ext/standard/lcg.c b/ext/standard/lcg.c
index 9f40aba3e2..74b46eadd2 100644
--- a/ext/standard/lcg.c
+++ b/ext/standard/lcg.c
@@ -54,8 +54,8 @@ static void lcg_seed(void);
PHPAPI double php_combined_lcg(void) /* {{{ */
{
- php_int32 q;
- php_int32 z;
+ int32_t q;
+ int32_t z;
if (!LCG(seeded)) {
lcg_seed();
diff --git a/ext/standard/math.c b/ext/standard/math.c
index 7ea8dc1199..ebfee8ead8 100644
--- a/ext/standard/math.c
+++ b/ext/standard/math.c
@@ -146,6 +146,7 @@ PHPAPI double _php_math_round(double value, int places, int mode) {
return value;
}
+ places = places < INT_MIN+1 ? INT_MIN+1 : places;
precision_places = 14 - php_intlog10abs(value);
f1 = php_intpow10(abs(places));
@@ -154,8 +155,10 @@ PHPAPI double _php_math_round(double value, int places, int mode) {
the requested places BUT is small enough to make sure a non-zero value
is returned, pre-round the result to the precision */
if (precision_places > places && precision_places - places < 15) {
- f2 = php_intpow10(abs(precision_places));
- if (precision_places >= 0) {
+ int64_t use_precision = precision_places < INT_MIN+1 ? INT_MIN+1 : precision_places;
+
+ f2 = php_intpow10(abs((int)use_precision));
+ if (use_precision >= 0) {
tmp_value = value * f2;
} else {
tmp_value = value / f2;
@@ -163,8 +166,11 @@ PHPAPI double _php_math_round(double value, int places, int mode) {
/* preround the result (tmp_value will always be something * 1e14,
thus never larger than 1e15 here) */
tmp_value = php_round_helper(tmp_value, mode);
+
+ use_precision = places - precision_places;
+ use_precision = use_precision < INT_MIN+1 ? INT_MIN+1 : use_precision;
/* now correctly move the decimal point */
- f2 = php_intpow10(abs(places - precision_places));
+ f2 = php_intpow10(abs((int)use_precision));
/* because places < precision_places */
tmp_value = tmp_value / f2;
} else {
diff --git a/ext/standard/md5.c b/ext/standard/md5.c
index 2489b9971a..825df21c69 100644
--- a/ext/standard/md5.c
+++ b/ext/standard/md5.c
@@ -169,16 +169,16 @@ PHP_NAMED_FUNCTION(php_if_md5_file)
*/
#if defined(__i386__) || defined(__x86_64__) || defined(__vax__)
# define SET(n) \
- (*(php_uint32 *)&ptr[(n) * 4])
+ (*(uint32_t *)&ptr[(n) * 4])
# define GET(n) \
SET(n)
#else
# define SET(n) \
(ctx->block[(n)] = \
- (php_uint32)ptr[(n) * 4] | \
- ((php_uint32)ptr[(n) * 4 + 1] << 8) | \
- ((php_uint32)ptr[(n) * 4 + 2] << 16) | \
- ((php_uint32)ptr[(n) * 4 + 3] << 24))
+ (uint32_t)ptr[(n) * 4] | \
+ ((uint32_t)ptr[(n) * 4 + 1] << 8) | \
+ ((uint32_t)ptr[(n) * 4 + 2] << 16) | \
+ ((uint32_t)ptr[(n) * 4 + 3] << 24))
# define GET(n) \
(ctx->block[(n)])
#endif
@@ -190,8 +190,8 @@ PHP_NAMED_FUNCTION(php_if_md5_file)
static const void *body(PHP_MD5_CTX *ctx, const void *data, size_t size)
{
const unsigned char *ptr;
- php_uint32 a, b, c, d;
- php_uint32 saved_a, saved_b, saved_c, saved_d;
+ uint32_t a, b, c, d;
+ uint32_t saved_a, saved_b, saved_c, saved_d;
ptr = data;
@@ -307,8 +307,8 @@ PHPAPI void PHP_MD5Init(PHP_MD5_CTX *ctx)
PHPAPI void PHP_MD5Update(PHP_MD5_CTX *ctx, const void *data, size_t size)
{
- php_uint32 saved_lo;
- php_uint32 used, free;
+ uint32_t saved_lo;
+ uint32_t used, free;
saved_lo = ctx->lo;
if ((ctx->lo = (saved_lo + size) & 0x1fffffff) < saved_lo) {
@@ -342,7 +342,7 @@ PHPAPI void PHP_MD5Update(PHP_MD5_CTX *ctx, const void *data, size_t size)
PHPAPI void PHP_MD5Final(unsigned char *result, PHP_MD5_CTX *ctx)
{
- php_uint32 used, free;
+ uint32_t used, free;
used = ctx->lo & 0x3f;
diff --git a/ext/standard/md5.h b/ext/standard/md5.h
index 4210483864..5acd83ecbe 100644
--- a/ext/standard/md5.h
+++ b/ext/standard/md5.h
@@ -42,10 +42,10 @@ PHP_NAMED_FUNCTION(php_if_md5_file);
/* MD5 context. */
typedef struct {
- php_uint32 lo, hi;
- php_uint32 a, b, c, d;
+ uint32_t lo, hi;
+ uint32_t a, b, c, d;
unsigned char buffer[64];
- php_uint32 block[16];
+ uint32_t block[16];
} PHP_MD5_CTX;
PHPAPI void PHP_MD5Init(PHP_MD5_CTX *ctx);
diff --git a/ext/standard/pack.c b/ext/standard/pack.c
index ab7e9c71dc..a24ee69ad2 100644
--- a/ext/standard/pack.c
+++ b/ext/standard/pack.c
@@ -986,7 +986,7 @@ PHP_FUNCTION(unpack)
/* Reached end of input for '*' repeater */
break;
} else {
- php_error_docref(NULL, E_WARNING, "Type %c: not enough input, need %d, have %d", type, size, inputlen - inputpos);
+ php_error_docref(NULL, E_WARNING, "Type %c: not enough input, need %d, have " ZEND_LONG_FMT, type, size, inputlen - inputpos);
zval_dtor(return_value);
RETURN_FALSE;
}
diff --git a/ext/standard/php_crypt_r.c b/ext/standard/php_crypt_r.c
index a8ca39b08e..8b97d4a496 100644
--- a/ext/standard/php_crypt_r.c
+++ b/ext/standard/php_crypt_r.c
@@ -323,7 +323,7 @@ char * php_md5_crypt_r(const char *pw, const char *salt, char *out)
unsigned char final[16];
unsigned int i, sl, pwl;
PHP_MD5_CTX ctx, ctx1;
- php_uint32 l;
+ uint32_t l;
int pl;
pwl = strlen(pw);
diff --git a/ext/standard/php_lcg.h b/ext/standard/php_lcg.h
index 60850d6c7c..2c24756012 100644
--- a/ext/standard/php_lcg.h
+++ b/ext/standard/php_lcg.h
@@ -24,8 +24,8 @@
#include "ext/standard/basic_functions.h"
typedef struct {
- php_int32 s1;
- php_int32 s2;
+ int32_t s1;
+ int32_t s2;
int seeded;
} php_lcg_globals;
diff --git a/ext/standard/php_rand.h b/ext/standard/php_rand.h
index 44a40a7c3b..39ba00eb56 100644
--- a/ext/standard/php_rand.h
+++ b/ext/standard/php_rand.h
@@ -55,7 +55,7 @@
PHPAPI void php_srand(zend_long seed);
PHPAPI zend_long php_rand(void);
-PHPAPI void php_mt_srand(php_uint32 seed);
-PHPAPI php_uint32 php_mt_rand(void);
+PHPAPI void php_mt_srand(uint32_t seed);
+PHPAPI uint32_t php_mt_rand(void);
#endif /* PHP_RAND_H */
diff --git a/ext/standard/php_smart_string.h b/ext/standard/php_smart_string.h
index a832376064..58c319a5a5 100644
--- a/ext/standard/php_smart_string.h
+++ b/ext/standard/php_smart_string.h
@@ -93,7 +93,7 @@
smart_string_append_unsigned_ex((dest), (val), 0)
#define smart_string_appendc_ex(dest, ch, what) do { \
- register size_t __nl; \
+ size_t __nl; \
smart_string_alloc4((dest), 1, (what), __nl); \
(dest)->len = __nl; \
((unsigned char *) (dest)->c)[(dest)->len - 1] = (ch); \
@@ -109,7 +109,7 @@
} while (0)
#define smart_string_appendl_ex(dest, src, nlen, what) do { \
- register size_t __nl; \
+ size_t __nl; \
smart_string *__dest = (smart_string *) (dest); \
\
smart_string_alloc4(__dest, (nlen), (what), __nl); \
diff --git a/ext/standard/rand.c b/ext/standard/rand.c
index 2dd05e70bb..50729f2418 100644
--- a/ext/standard/rand.c
+++ b/ext/standard/rand.c
@@ -146,19 +146,19 @@ PHPAPI zend_long php_rand(void)
#define loBits(u) ((u) & 0x7FFFFFFFU) /* mask the highest bit of u */
#define mixBits(u, v) (hiBit(u)|loBits(v)) /* move hi bit of u to hi bit of v */
-#define twist(m,u,v) (m ^ (mixBits(u,v)>>1) ^ ((php_uint32)(-(php_int32)(loBit(u))) & 0x9908b0dfU))
+#define twist(m,u,v) (m ^ (mixBits(u,v)>>1) ^ ((uint32_t)(-(int32_t)(loBit(u))) & 0x9908b0dfU))
/* {{{ php_mt_initialize
*/
-static inline void php_mt_initialize(php_uint32 seed, php_uint32 *state)
+static inline void php_mt_initialize(uint32_t seed, uint32_t *state)
{
/* Initialize generator state with seed
See Knuth TAOCP Vol 2, 3rd Ed, p.106 for multiplier.
In previous versions, most significant bits (MSBs) of the seed affect
only MSBs of the state array. Modified 9 Jan 2002 by Makoto Matsumoto. */
- register php_uint32 *s = state;
- register php_uint32 *r = state;
+ register uint32_t *s = state;
+ register uint32_t *r = state;
register int i = 1;
*s++ = seed & 0xffffffffU;
@@ -176,8 +176,8 @@ static inline void php_mt_reload(void)
/* Generate N new values in state
Made clearer and faster by Matthew Bellew (matthew.bellew@home.com) */
- register php_uint32 *state = BG(state);
- register php_uint32 *p = state;
+ register uint32_t *state = BG(state);
+ register uint32_t *p = state;
register int i;
for (i = N - M; i--; ++p)
@@ -192,7 +192,7 @@ static inline void php_mt_reload(void)
/* {{{ php_mt_srand
*/
-PHPAPI void php_mt_srand(php_uint32 seed)
+PHPAPI void php_mt_srand(uint32_t seed)
{
/* Seed the generator with a simple uint32 */
php_mt_initialize(seed, BG(state));
@@ -205,12 +205,12 @@ PHPAPI void php_mt_srand(php_uint32 seed)
/* {{{ php_mt_rand
*/
-PHPAPI php_uint32 php_mt_rand(void)
+PHPAPI uint32_t php_mt_rand(void)
{
/* Pull a 32-bit integer from the generator state
Every other access function simply transforms the numbers extracted here */
- register php_uint32 s1;
+ register uint32_t s1;
if (BG(left) == 0) {
php_mt_reload();
diff --git a/ext/standard/sha1.c b/ext/standard/sha1.c
index ad4f4a5603..c4bed51abc 100644
--- a/ext/standard/sha1.c
+++ b/ext/standard/sha1.c
@@ -103,9 +103,9 @@ PHP_FUNCTION(sha1_file)
/* }}} */
-static void SHA1Transform(php_uint32[5], const unsigned char[64]);
-static void SHA1Encode(unsigned char *, php_uint32 *, unsigned int);
-static void SHA1Decode(php_uint32 *, const unsigned char *, unsigned int);
+static void SHA1Transform(uint32_t[5], const unsigned char[64]);
+static void SHA1Encode(unsigned char *, uint32_t *, unsigned int);
+static void SHA1Decode(uint32_t *, const unsigned char *, unsigned int);
static unsigned char PADDING[64] =
{
@@ -133,22 +133,22 @@ static unsigned char PADDING[64] =
/* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4.
*/
#define FF(a, b, c, d, e, w) { \
- (e) += F ((b), (c), (d)) + (w) + (php_uint32)(0x5A827999); \
+ (e) += F ((b), (c), (d)) + (w) + (uint32_t)(0x5A827999); \
(e) += ROTATE_LEFT ((a), 5); \
(b) = ROTATE_LEFT((b), 30); \
}
#define GG(a, b, c, d, e, w) { \
- (e) += G ((b), (c), (d)) + (w) + (php_uint32)(0x6ED9EBA1); \
+ (e) += G ((b), (c), (d)) + (w) + (uint32_t)(0x6ED9EBA1); \
(e) += ROTATE_LEFT ((a), 5); \
(b) = ROTATE_LEFT((b), 30); \
}
#define HH(a, b, c, d, e, w) { \
- (e) += H ((b), (c), (d)) + (w) + (php_uint32)(0x8F1BBCDC); \
+ (e) += H ((b), (c), (d)) + (w) + (uint32_t)(0x8F1BBCDC); \
(e) += ROTATE_LEFT ((a), 5); \
(b) = ROTATE_LEFT((b), 30); \
}
#define II(a, b, c, d, e, w) { \
- (e) += I ((b), (c), (d)) + (w) + (php_uint32)(0xCA62C1D6); \
+ (e) += I ((b), (c), (d)) + (w) + (uint32_t)(0xCA62C1D6); \
(e) += ROTATE_LEFT ((a), 5); \
(b) = ROTATE_LEFT((b), 30); \
}
@@ -184,10 +184,10 @@ PHPAPI void PHP_SHA1Update(PHP_SHA1_CTX * context, const unsigned char *input,
index = (unsigned int) ((context->count[0] >> 3) & 0x3F);
/* Update number of bits */
- if ((context->count[0] += ((php_uint32) inputLen << 3))
- < ((php_uint32) inputLen << 3))
+ if ((context->count[0] += ((uint32_t) inputLen << 3))
+ < ((uint32_t) inputLen << 3))
context->count[1]++;
- context->count[1] += ((php_uint32) inputLen >> 29);
+ context->count[1] += ((uint32_t) inputLen >> 29);
partLen = 64 - index;
@@ -253,11 +253,11 @@ PHPAPI void PHP_SHA1Final(unsigned char digest[20], PHP_SHA1_CTX * context)
* SHA1 basic transformation. Transforms state based on block.
*/
static void SHA1Transform(state, block)
-php_uint32 state[5];
+uint32_t state[5];
const unsigned char block[64];
{
- php_uint32 a = state[0], b = state[1], c = state[2];
- php_uint32 d = state[3], e = state[4], x[16], tmp;
+ uint32_t a = state[0], b = state[1], c = state[2];
+ uint32_t d = state[3], e = state[4], x[16], tmp;
SHA1Decode(x, block, 64);
@@ -361,12 +361,12 @@ const unsigned char block[64];
/* }}} */
/* {{{ SHA1Encode
- Encodes input (php_uint32) into output (unsigned char). Assumes len is
+ Encodes input (uint32_t) into output (unsigned char). Assumes len is
a multiple of 4.
*/
static void SHA1Encode(output, input, len)
unsigned char *output;
-php_uint32 *input;
+uint32_t *input;
unsigned int len;
{
unsigned int i, j;
@@ -381,19 +381,19 @@ unsigned int len;
/* }}} */
/* {{{ SHA1Decode
- Decodes input (unsigned char) into output (php_uint32). Assumes len is
+ Decodes input (unsigned char) into output (uint32_t). Assumes len is
a multiple of 4.
*/
static void SHA1Decode(output, input, len)
-php_uint32 *output;
+uint32_t *output;
const unsigned char *input;
unsigned int len;
{
unsigned int i, j;
for (i = 0, j = 0; j < len; i++, j += 4)
- output[i] = ((php_uint32) input[j + 3]) | (((php_uint32) input[j + 2]) << 8) |
- (((php_uint32) input[j + 1]) << 16) | (((php_uint32) input[j]) << 24);
+ output[i] = ((uint32_t) input[j + 3]) | (((uint32_t) input[j + 2]) << 8) |
+ (((uint32_t) input[j + 1]) << 16) | (((uint32_t) input[j]) << 24);
}
/* }}} */
diff --git a/ext/standard/sha1.h b/ext/standard/sha1.h
index d2cc1b70b9..de338fad38 100644
--- a/ext/standard/sha1.h
+++ b/ext/standard/sha1.h
@@ -25,8 +25,8 @@
/* SHA1 context. */
typedef struct {
- php_uint32 state[5]; /* state (ABCD) */
- php_uint32 count[2]; /* number of bits, modulo 2^64 (lsb first) */
+ uint32_t state[5]; /* state (ABCD) */
+ uint32_t count[2]; /* number of bits, modulo 2^64 (lsb first) */
unsigned char buffer[64]; /* input buffer */
} PHP_SHA1_CTX;
diff --git a/ext/standard/streamsfuncs.c b/ext/standard/streamsfuncs.c
index de0f016947..c2f200eedd 100644
--- a/ext/standard/streamsfuncs.c
+++ b/ext/standard/streamsfuncs.c
@@ -507,6 +507,12 @@ PHP_FUNCTION(stream_get_meta_data)
array_init(return_value);
+ if (!php_stream_populate_meta_data(stream, return_value)) {
+ add_assoc_bool(return_value, "timed_out", 0);
+ add_assoc_bool(return_value, "blocked", 1);
+ add_assoc_bool(return_value, "eof", php_stream_eof(stream));
+ }
+
if (!Z_ISUNDEF(stream->wrapperdata)) {
Z_ADDREF_P(&stream->wrapperdata);
add_assoc_zval(return_value, "wrapper_data", &stream->wrapperdata);
@@ -540,11 +546,6 @@ PHP_FUNCTION(stream_get_meta_data)
add_assoc_string(return_value, "uri", stream->orig_path);
}
- if (!php_stream_populate_meta_data(stream, return_value)) {
- add_assoc_bool(return_value, "timed_out", 0);
- add_assoc_bool(return_value, "blocked", 1);
- add_assoc_bool(return_value, "eof", php_stream_eof(stream));
- }
}
/* }}} */
diff --git a/ext/standard/string.c b/ext/standard/string.c
index 022914625e..82aa97e8cd 100644
--- a/ext/standard/string.c
+++ b/ext/standard/string.c
@@ -998,12 +998,12 @@ PHP_FUNCTION(wordwrap)
/* Multiple character line break or forced cut */
if (linelength > 0) {
chk = (size_t)(ZSTR_LEN(text)/linelength + 1);
- newtext = zend_string_alloc(chk * breakchar_len + ZSTR_LEN(text), 0);
+ newtext = zend_string_safe_alloc(chk, breakchar_len, ZSTR_LEN(text), 0);
alloced = ZSTR_LEN(text) + chk * breakchar_len + 1;
} else {
chk = ZSTR_LEN(text);
alloced = ZSTR_LEN(text) * (breakchar_len + 1) + 1;
- newtext = zend_string_alloc(ZSTR_LEN(text) * (breakchar_len + 1), 0);
+ newtext = zend_string_safe_alloc(ZSTR_LEN(text), breakchar_len + 1, 0, 0);
}
/* now keep track of the actual new text length */
@@ -1245,8 +1245,8 @@ PHPAPI void php_implode(const zend_string *delim, zval *arr, zval *return_value)
len += ZSTR_LEN(*strptr);
}
} ZEND_HASH_FOREACH_END();
-
- str = zend_string_alloc(len + (numelems - 1) * ZSTR_LEN(delim), 0);
+ /* numelems can not be 0, we checked above */
+ str = zend_string_safe_alloc(numelems - 1, ZSTR_LEN(delim), len, 0);
cptr = ZSTR_VAL(str) + ZSTR_LEN(str);
*cptr = 0;
@@ -2344,7 +2344,7 @@ PHP_FUNCTION(chunk_split)
if ((size_t)chunklen > ZSTR_LEN(str)) {
/* to maintain BC, we must return original string + ending */
- result = zend_string_alloc(endlen + ZSTR_LEN(str), 0);
+ result = zend_string_safe_alloc(ZSTR_LEN(str), 1, endlen, 0);
memcpy(ZSTR_VAL(result), ZSTR_VAL(str), ZSTR_LEN(str));
memcpy(ZSTR_VAL(result) + ZSTR_LEN(str), end, endlen);
ZSTR_VAL(result)[ZSTR_LEN(result)] = '\0';
@@ -2710,7 +2710,7 @@ PHP_FUNCTION(quotemeta)
RETURN_FALSE;
}
- str = zend_string_alloc(2 * ZSTR_LEN(old), 0);
+ str = zend_string_safe_alloc(2, ZSTR_LEN(old), 0, 0);
for (p = ZSTR_VAL(old), q = ZSTR_VAL(str); p != old_end; p++) {
c = *p;
@@ -2740,7 +2740,8 @@ PHP_FUNCTION(quotemeta)
/* }}} */
/* {{{ proto int ord(string character)
- Returns ASCII value of character */
+ Returns ASCII value of character
+ Warning: This function is special-cased by zend_compile.c and so is bypassed for constant string argument */
PHP_FUNCTION(ord)
{
char *str;
@@ -2761,7 +2762,8 @@ PHP_FUNCTION(ord)
/* }}} */
/* {{{ proto string chr(int ascii)
- Converts ASCII code to a character */
+ Converts ASCII code to a character
+ Warning: This function is special-cased by zend_compile.c and so is bypassed for constant integer argument */
PHP_FUNCTION(chr)
{
zend_long c;
@@ -3231,7 +3233,11 @@ static zend_string *php_str_to_str_ex(zend_string *haystack,
/* Needle doesn't occur, shortcircuit the actual replacement. */
goto nothing_todo;
}
- new_str = zend_string_alloc(count * (str_len - needle_len) + ZSTR_LEN(haystack), 0);
+ if (str_len > needle_len) {
+ new_str = zend_string_safe_alloc(count, str_len - needle_len, ZSTR_LEN(haystack), 0);
+ } else {
+ new_str = zend_string_alloc(count * (str_len - needle_len) + ZSTR_LEN(haystack), 0);
+ }
e = s = ZSTR_VAL(new_str);
end = ZSTR_VAL(haystack) + ZSTR_LEN(haystack);
@@ -3308,8 +3314,12 @@ static zend_string *php_str_to_str_i_ex(zend_string *haystack, char *lc_haystack
zend_string_release(lc_needle);
goto nothing_todo;
}
-
- new_str = zend_string_alloc(count * (str_len - ZSTR_LEN(lc_needle)) + ZSTR_LEN(haystack), 0);
+
+ if (str_len > ZSTR_LEN(lc_needle)) {
+ new_str = zend_string_safe_alloc(count, str_len - ZSTR_LEN(lc_needle), ZSTR_LEN(haystack), 0);
+ } else {
+ new_str = zend_string_alloc(count * (str_len - ZSTR_LEN(lc_needle)) + ZSTR_LEN(haystack), 0);
+ }
e = s = ZSTR_VAL(new_str);
end = lc_haystack + ZSTR_LEN(haystack);
@@ -3387,7 +3397,11 @@ PHPAPI zend_string *php_str_to_str(char *haystack, size_t length, char *needle,
new_str = zend_string_init(haystack, length, 0);
return new_str;
} else {
- new_str = zend_string_alloc(count * (str_len - needle_len) + length, 0);
+ if (str_len > needle_len) {
+ new_str = zend_string_safe_alloc(count, str_len - needle_len, length, 0);
+ } else {
+ new_str = zend_string_alloc(count * (str_len - needle_len) + length, 0);
+ }
}
}
@@ -3815,7 +3829,7 @@ PHPAPI zend_string *php_addcslashes(zend_string *str, int should_free, char *wha
char *end;
char c;
size_t newlen;
- zend_string *new_str = zend_string_alloc(4 * ZSTR_LEN(str), 0);
+ zend_string *new_str = zend_string_safe_alloc(4, ZSTR_LEN(str), 0, 0);
php_charmask((unsigned char *)what, wlength, flags);
@@ -3890,7 +3904,7 @@ PHPAPI zend_string *php_addslashes(zend_string *str, int should_free)
do_escape:
offset = source - (char *)ZSTR_VAL(str);
- new_str = zend_string_alloc(offset + (2 * (ZSTR_LEN(str) - offset)), 0);
+ new_str = zend_string_safe_alloc(2, ZSTR_LEN(str) - offset, offset, 0);
memcpy(ZSTR_VAL(new_str), ZSTR_VAL(str), offset);
target = ZSTR_VAL(new_str) + offset;
@@ -4412,7 +4426,7 @@ PHP_FUNCTION(nl2br)
{
size_t repl_len = is_xhtml ? (sizeof("<br />") - 1) : (sizeof("<br>") - 1);
- result = zend_string_alloc(repl_cnt * repl_len + ZSTR_LEN(str), 0);
+ result = zend_string_safe_alloc(repl_cnt, repl_len, ZSTR_LEN(str), 0);
target = ZSTR_VAL(result);
}
@@ -4699,6 +4713,7 @@ PHPAPI size_t php_strip_tags_ex(char *rbuf, size_t len, int *stateptr, const cha
size_t pos, i = 0;
char *allow_free = NULL;
const char *allow_actual;
+ char is_xml = 0;
if (stateptr)
state = *stateptr;
@@ -4794,10 +4809,10 @@ PHPAPI size_t php_strip_tags_ex(char *rbuf, size_t len, int *stateptr, const cha
switch (state) {
case 1: /* HTML/XML */
lc = '>';
- if (*(p -1) == '-') {
+ if (is_xml && *(p -1) == '-') {
break;
}
- in_q = state = 0;
+ in_q = state = is_xml = 0;
if (allow) {
if (tp - tbuf >= PHP_TAG_BUF_SIZE) {
pos = tp - tbuf;
@@ -4926,8 +4941,8 @@ PHPAPI size_t php_strip_tags_ex(char *rbuf, size_t len, int *stateptr, const cha
* state == 2 (PHP). Switch back to HTML.
*/
- if (state == 2 && p > buf+2 && strncasecmp(p-4, "<?xm", 4) == 0) {
- state = 1;
+ if (state == 2 && p > buf+4 && strncasecmp(p-4, "<?xm", 4) == 0) {
+ state = 1; is_xml=1;
break;
}
@@ -5596,7 +5611,7 @@ PHP_FUNCTION(money_format)
}
}
- str = zend_string_alloc(format_len + 1024, 0);
+ str = zend_string_safe_alloc(format_len, 1, 1024, 0);
if ((res_len = strfmon(ZSTR_VAL(str), ZSTR_LEN(str), format, value)) < 0) {
zend_string_free(str);
RETURN_FALSE;
diff --git a/ext/standard/tests/array/bug71603.phpt b/ext/standard/tests/array/bug71603.phpt
new file mode 100644
index 0000000000..0c25be660c
--- /dev/null
+++ b/ext/standard/tests/array/bug71603.phpt
@@ -0,0 +1,15 @@
+--TEST--
+Bug #71603 (compact() maintains references in php7)
+--FILE--
+<?php
+$foo = "okey";
+$foo_reference =& $foo;
+
+$array = compact('foo_reference');
+
+$foo = 'changed!';
+
+var_dump($array['foo_reference']);
+
+--EXPECT--
+string(4) "okey"
diff --git a/ext/standard/tests/array/bug71660.phpt b/ext/standard/tests/array/bug71660.phpt
new file mode 100644
index 0000000000..c2d7192378
--- /dev/null
+++ b/ext/standard/tests/array/bug71660.phpt
@@ -0,0 +1,18 @@
+--TEST--
+Bug #71660 (array_column behaves incorrectly after foreach by reference)
+--FILE--
+<?php
+$arr = array('id' => 12345, 'name' => 'sam');
+foreach ($arr as &$v) {
+ $v = $v;
+}
+
+$arr = [$arr];
+
+var_dump(array_column($arr, 'name', 'id'));
+?>
+--EXPECT--
+array(1) {
+ [12345]=>
+ string(3) "sam"
+}
diff --git a/ext/standard/tests/array/range_bug71132.phpt b/ext/standard/tests/array/range_bug71132.phpt
new file mode 100644
index 0000000000..5e3bcc8f31
--- /dev/null
+++ b/ext/standard/tests/array/range_bug71132.phpt
@@ -0,0 +1,10 @@
+--TEST--
+Bug #71132 (range function produces 2 segfaults with long integers)
+--FILE--
+<?php
+var_dump(count(range(PHP_INT_MIN + 513, PHP_INT_MIN)));
+var_dump(count(range(PHP_INT_MIN, PHP_INT_MIN + 513)));
+?>
+--EXPECT--
+int(514)
+int(514)
diff --git a/ext/standard/tests/array/range_bug71197.phpt b/ext/standard/tests/array/range_bug71197.phpt
new file mode 100644
index 0000000000..2031ec7c09
--- /dev/null
+++ b/ext/standard/tests/array/range_bug71197.phpt
@@ -0,0 +1,8 @@
+--TEST--
+Bug #71197 (range function produces another 2 segfaults with long integers)
+--FILE--
+<?php
+range(PHP_INT_MIN, PHP_INT_MIN + 513, .01);
+range(PHP_INT_MIN + 513, PHP_INT_MIN, .01);
+?>
+--EXPECT--
diff --git a/ext/standard/tests/class_object/bug71442.phpt b/ext/standard/tests/class_object/bug71442.phpt
new file mode 100644
index 0000000000..d6b3d6699b
--- /dev/null
+++ b/ext/standard/tests/class_object/bug71442.phpt
@@ -0,0 +1,37 @@
+--TEST--
+Bug #71442 (forward_static_call crash)
+--FILE--
+<?php
+
+class A
+{
+ const NAME = 'A';
+ public static function test() {
+ $args = func_get_args();
+ echo static::NAME, " ".join(',', $args)." \n";
+ }
+}
+
+class B extends A
+{
+ const NAME = 'B';
+
+ public static function test() {
+ echo self::NAME, "\n";
+ forward_static_call(array('A', 'test'), 'more', 'args');
+ forward_static_call( 'test', 'other', 'args');
+ }
+}
+
+B::test('foo');
+
+function test() {
+ $args = func_get_args();
+ echo "C ".join(',', $args)." \n";
+}
+
+?>
+--EXPECT--
+B
+B more,args
+C other,args
diff --git a/ext/standard/tests/file/stream_rfc2397_002.phpt b/ext/standard/tests/file/stream_rfc2397_002.phpt
index 980863bb5c..1dce5adf6c 100644
--- a/ext/standard/tests/file/stream_rfc2397_002.phpt
+++ b/ext/standard/tests/file/stream_rfc2397_002.phpt
@@ -34,6 +34,8 @@ foreach($streams as $stream)
<?php exit(0); ?>
--EXPECTF--
array(7) {
+ ["base64"]=>
+ bool(false)
["wrapper_type"]=>
string(7) "RFC2397"
["stream_type"]=>
@@ -46,8 +48,6 @@ array(7) {
bool(true)
["uri"]=>
string(8) "data://,"
- ["base64"]=>
- bool(false)
}
NULL
@@ -55,6 +55,8 @@ Warning: fopen(data://): failed to open stream: rfc2397: no comma in URL in %sst
NULL
NULL
array(7) {
+ ["base64"]=>
+ bool(true)
["wrapper_type"]=>
string(7) "RFC2397"
["stream_type"]=>
@@ -67,8 +69,6 @@ array(7) {
bool(true)
["uri"]=>
string(15) "data://;base64,"
- ["base64"]=>
- bool(true)
}
NULL
@@ -84,6 +84,10 @@ Warning: fopen(data://foo=bar,): failed to open stream: rfc2397: illegal media t
NULL
NULL
array(8) {
+ ["mediatype"]=>
+ string(10) "text/plain"
+ ["base64"]=>
+ bool(false)
["wrapper_type"]=>
string(7) "RFC2397"
["stream_type"]=>
@@ -96,10 +100,6 @@ array(8) {
bool(true)
["uri"]=>
string(18) "data://text/plain,"
- ["mediatype"]=>
- string(10) "text/plain"
- ["base64"]=>
- bool(false)
}
NULL
@@ -107,6 +107,12 @@ Warning: fopen(data://text/plain;foo,): failed to open stream: rfc2397: illegal
NULL
NULL
array(9) {
+ ["mediatype"]=>
+ string(10) "text/plain"
+ ["foo"]=>
+ string(3) "bar"
+ ["base64"]=>
+ bool(false)
["wrapper_type"]=>
string(7) "RFC2397"
["stream_type"]=>
@@ -119,12 +125,6 @@ array(9) {
bool(true)
["uri"]=>
string(26) "data://text/plain;foo=bar,"
- ["mediatype"]=>
- string(10) "text/plain"
- ["foo"]=>
- string(3) "bar"
- ["base64"]=>
- bool(false)
}
string(3) "bar"
@@ -132,6 +132,12 @@ Warning: fopen(data://text/plain;foo=bar;bla,): failed to open stream: rfc2397:
NULL
NULL
array(9) {
+ ["mediatype"]=>
+ string(10) "text/plain"
+ ["foo"]=>
+ string(3) "bar"
+ ["base64"]=>
+ bool(true)
["wrapper_type"]=>
string(7) "RFC2397"
["stream_type"]=>
@@ -144,12 +150,6 @@ array(9) {
bool(true)
["uri"]=>
string(33) "data://text/plain;foo=bar;base64,"
- ["mediatype"]=>
- string(10) "text/plain"
- ["foo"]=>
- string(3) "bar"
- ["base64"]=>
- bool(true)
}
string(3) "bar"
@@ -157,6 +157,14 @@ Warning: fopen(data://text/plain;foo=bar;bar=baz): failed to open stream: rfc239
NULL
NULL
array(10) {
+ ["mediatype"]=>
+ string(10) "text/plain"
+ ["foo"]=>
+ string(3) "bar"
+ ["bar"]=>
+ string(3) "baz"
+ ["base64"]=>
+ bool(false)
["wrapper_type"]=>
string(7) "RFC2397"
["stream_type"]=>
@@ -169,14 +177,6 @@ array(10) {
bool(true)
["uri"]=>
string(34) "data://text/plain;foo=bar;bar=baz,"
- ["mediatype"]=>
- string(10) "text/plain"
- ["foo"]=>
- string(3) "bar"
- ["bar"]=>
- string(3) "baz"
- ["base64"]=>
- bool(false)
}
string(3) "bar"
===DONE===
diff --git a/ext/standard/tests/general_functions/escapeshellarg_bug71039.phpt b/ext/standard/tests/general_functions/escapeshellarg_bug71039.phpt
new file mode 100644
index 0000000000..cbb3f6fcc4
--- /dev/null
+++ b/ext/standard/tests/general_functions/escapeshellarg_bug71039.phpt
@@ -0,0 +1,10 @@
+--TEST--
+Test escapeshellarg() string with \0 bytes
+--FILE--
+<?php
+escapeshellarg("hello\0world");
+
+?>
+===DONE===
+--EXPECTF--
+Fatal error: escapeshellarg(): Input string contains NULL bytes in %s on line %d
diff --git a/ext/standard/tests/general_functions/escapeshellarg_bug71270.phpt b/ext/standard/tests/general_functions/escapeshellarg_bug71270.phpt
new file mode 100644
index 0000000000..c57da3691c
--- /dev/null
+++ b/ext/standard/tests/general_functions/escapeshellarg_bug71270.phpt
@@ -0,0 +1,12 @@
+--TEST--
+Test escapeshellarg() allowed argument length
+--FILE--
+<?php
+ini_set('memory_limit', -1);
+$var_2 = str_repeat('A', 1024*1024*64);
+escapeshellarg($var_2);
+
+?>
+===DONE===
+--EXPECTF--
+Fatal error: escapeshellarg(): Argument exceeds the allowed length of %d bytes in %s on line %d
diff --git a/ext/standard/tests/general_functions/escapeshellcmd_bug71039.phpt b/ext/standard/tests/general_functions/escapeshellcmd_bug71039.phpt
new file mode 100644
index 0000000000..0a4d7eacff
--- /dev/null
+++ b/ext/standard/tests/general_functions/escapeshellcmd_bug71039.phpt
@@ -0,0 +1,10 @@
+--TEST--
+Test escapeshellcmd() string with \0 bytes
+--FILE--
+<?php
+escapeshellcmd("hello\0world");
+
+?>
+===DONE===
+--EXPECTF--
+Fatal error: escapeshellcmd(): Input string contains NULL bytes in %s on line %d
diff --git a/ext/standard/tests/general_functions/escapeshellcmd_bug71270.phpt b/ext/standard/tests/general_functions/escapeshellcmd_bug71270.phpt
new file mode 100644
index 0000000000..4686193d41
--- /dev/null
+++ b/ext/standard/tests/general_functions/escapeshellcmd_bug71270.phpt
@@ -0,0 +1,12 @@
+--TEST--
+Test escapeshellcmd() allowed argument length
+--FILE--
+<?php
+ini_set('memory_limit', -1);
+$var_2 = str_repeat('A', 1024*1024*64);
+escapeshellcmd($var_2);
+
+?>
+===DONE===
+--EXPECTF--
+Fatal error: escapeshellcmd(): Command exceeds the allowed length of %d bytes in %s on line %d
diff --git a/ext/standard/tests/general_functions/var_export_bug71314.phpt b/ext/standard/tests/general_functions/var_export_bug71314.phpt
new file mode 100644
index 0000000000..aaa8f794c0
--- /dev/null
+++ b/ext/standard/tests/general_functions/var_export_bug71314.phpt
@@ -0,0 +1,15 @@
+--TEST--
+Bug #71314 (var_export(INF) prints INF.0)
+--FILE--
+<?php
+
+var_export(INF);
+echo PHP_EOL;
+var_export(-INF);
+echo PHP_EOL;
+var_export(NAN);
+echo PHP_EOL;
+--EXPECT--
+INF
+-INF
+NAN
diff --git a/ext/standard/tests/math/mt_rand_value.phpt b/ext/standard/tests/math/mt_rand_value.phpt
new file mode 100644
index 0000000000..772305ad63
--- /dev/null
+++ b/ext/standard/tests/math/mt_rand_value.phpt
@@ -0,0 +1,44 @@
+--TEST--
+Test mt_rand() output
+--FILE--
+<?php
+
+mt_srand(12345678);
+
+for ($i=0; $i<16; $i++) {
+ echo mt_rand().PHP_EOL;
+}
+echo PHP_EOL;
+
+$x = 0;
+for ($i=0; $i<1024; $i++) {
+ $x ^= mt_rand();
+}
+echo $x.PHP_EOL;
+
+/*
+ * Note that the output will be different from the original mt19937ar.c,
+ * because PHP's implementation contains a bug. Thus, this test actually
+ * checks to make sure that PHP's behaviour is wrong, but consistently so.
+ */
+
+?>
+--EXPECTF--
+1614640687
+1711027313
+857485497
+688176834
+1386682158
+412773096
+813703253
+898651287
+2087374214
+1382556330
+1640700129
+1863374167
+1324097651
+1923803667
+676334965
+853386222
+
+1571178311
diff --git a/ext/standard/tests/network/socket_get_status_basic.phpt b/ext/standard/tests/network/socket_get_status_basic.phpt
index 46215f9838..32a8d9ce6f 100644
--- a/ext/standard/tests/network/socket_get_status_basic.phpt
+++ b/ext/standard/tests/network/socket_get_status_basic.phpt
@@ -18,6 +18,12 @@ fclose($server);
?>
--EXPECTF--
array(7) {
+ ["timed_out"]=>
+ bool(false)
+ ["blocked"]=>
+ bool(true)
+ ["eof"]=>
+ bool(false)
["stream_type"]=>
string(%d) "tcp_socket%S"
["mode"]=>
@@ -26,10 +32,4 @@ array(7) {
int(0)
["seekable"]=>
bool(false)
- ["timed_out"]=>
- bool(false)
- ["blocked"]=>
- bool(true)
- ["eof"]=>
- bool(false)
}
diff --git a/ext/standard/tests/serialize/bug71311.phpt b/ext/standard/tests/serialize/bug71311.phpt
new file mode 100644
index 0000000000..3c70783d37
--- /dev/null
+++ b/ext/standard/tests/serialize/bug71311.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Bug #71311 Use-after-free vulnerability in SPL(ArrayObject, unserialize)
+--FILE--
+<?php
+$data = unserialize("C:11:\"ArrayObject\":11:{x:i:0;r:3;XX");
+var_dump($data);
+?>
+--EXPECTF--
+Fatal error: Uncaught UnexpectedValueException: Error at offset 10 of 11 bytes in %s%ebug71311.php:2
+Stack trace:
+#0 [internal function]: ArrayObject->unserialize('x:i:0;r:3;X')
+#1 %s%ebug71311.php(2): unserialize('%s')
+#2 {main}
+ thrown in %s%ebug71311.php on line 2
+
+
diff --git a/ext/standard/tests/serialize/bug71313.phpt b/ext/standard/tests/serialize/bug71313.phpt
new file mode 100644
index 0000000000..2ad429227d
--- /dev/null
+++ b/ext/standard/tests/serialize/bug71313.phpt
@@ -0,0 +1,14 @@
+--TEST--
+Bug #71311 Use-after-free vulnerability in SPL(SplObjectStorage, unserialize)
+--FILE--
+<?php
+$data = unserialize("C:16:\"SplObjectStorage\":113:{x:i:2;O:8:\"stdClass\":0:{},a:2:{s:4:\"prev\";i:2;s:4:\"next\";O:8:\"stdClass\":0:{}};r:7;,R:2;s:4:\"next\";;r:3;};m:a:0:{}}");
+var_dump($data);
+?>
+--EXPECTF--
+Fatal error: Uncaught UnexpectedValueException: Error at offset 82 of 113 bytes in %s%ebug71313.php:2
+Stack trace:
+#0 [internal function]: SplObjectStorage->unserialize('%s')
+#1 %s%ebug71313.php(2): unserialize('%s')
+#2 {main}
+ thrown in %s%ebug71313.php on line 2
diff --git a/ext/standard/tests/streams/bug71323.phpt b/ext/standard/tests/streams/bug71323.phpt
new file mode 100644
index 0000000000..dfe0bd8afe
--- /dev/null
+++ b/ext/standard/tests/streams/bug71323.phpt
@@ -0,0 +1,31 @@
+--TEST--
+Bug #71323: Output of stream_get_meta_data can be falsified by its input
+--FILE--
+<?php
+$file = 'data:text/plain;z=y;uri=eviluri;mediatype=wut?;mediatype2=hello,somedata';
+$meta = stream_get_meta_data(fopen($file, "r"));
+var_dump($meta);
+?>
+--EXPECTF--
+array(10) {
+ ["mediatype"]=>
+ string(10) "text/plain"
+ ["z"]=>
+ string(1) "y"
+ ["uri"]=>
+ string(72) "data:text/plain;z=y;uri=eviluri;mediatype=wut?;mediatype2=hello,somedata"
+ ["mediatype2"]=>
+ string(5) "hello"
+ ["base64"]=>
+ bool(false)
+ ["wrapper_type"]=>
+ string(7) "RFC2397"
+ ["stream_type"]=>
+ string(7) "RFC2397"
+ ["mode"]=>
+ string(1) "r"
+ ["unread_bytes"]=>
+ int(0)
+ ["seekable"]=>
+ bool(true)
+}
diff --git a/ext/standard/tests/streams/stream_get_meta_data_dir_basic.phpt b/ext/standard/tests/streams/stream_get_meta_data_dir_basic.phpt
index f46c8fd70b..6658d69a4b 100644
--- a/ext/standard/tests/streams/stream_get_meta_data_dir_basic.phpt
+++ b/ext/standard/tests/streams/stream_get_meta_data_dir_basic.phpt
@@ -13,6 +13,12 @@ var_dump(stream_get_meta_data($dirObject->handle));
?>
--EXPECT--
array(8) {
+ ["timed_out"]=>
+ bool(false)
+ ["blocked"]=>
+ bool(true)
+ ["eof"]=>
+ bool(false)
["wrapper_type"]=>
string(9) "plainfile"
["stream_type"]=>
@@ -23,14 +29,14 @@ array(8) {
int(0)
["seekable"]=>
bool(true)
+}
+array(8) {
["timed_out"]=>
bool(false)
["blocked"]=>
bool(true)
["eof"]=>
bool(false)
-}
-array(8) {
["wrapper_type"]=>
string(9) "plainfile"
["stream_type"]=>
@@ -41,10 +47,4 @@ array(8) {
int(0)
["seekable"]=>
bool(true)
- ["timed_out"]=>
- bool(false)
- ["blocked"]=>
- bool(true)
- ["eof"]=>
- bool(false)
}
diff --git a/ext/standard/tests/streams/stream_get_meta_data_file_basic.phpt b/ext/standard/tests/streams/stream_get_meta_data_file_basic.phpt
index 4758c750f9..bad5987990 100644
--- a/ext/standard/tests/streams/stream_get_meta_data_file_basic.phpt
+++ b/ext/standard/tests/streams/stream_get_meta_data_file_basic.phpt
@@ -12,6 +12,12 @@ fclose($fp);
?>
--EXPECTF--
array(9) {
+ ["timed_out"]=>
+ bool(false)
+ ["blocked"]=>
+ bool(true)
+ ["eof"]=>
+ bool(false)
["wrapper_type"]=>
string(9) "plainfile"
["stream_type"]=>
@@ -24,10 +30,4 @@ array(9) {
bool(true)
["uri"]=>
string(%i) "%sstream_get_meta_data_file_basic.php"
- ["timed_out"]=>
- bool(false)
- ["blocked"]=>
- bool(true)
- ["eof"]=>
- bool(false)
}
diff --git a/ext/standard/tests/streams/stream_get_meta_data_file_variation1.phpt b/ext/standard/tests/streams/stream_get_meta_data_file_variation1.phpt
index 572653e3db..d54eb04410 100644
--- a/ext/standard/tests/streams/stream_get_meta_data_file_variation1.phpt
+++ b/ext/standard/tests/streams/stream_get_meta_data_file_variation1.phpt
@@ -29,6 +29,12 @@ unlink($filename);
?>
--EXPECTF--
array(9) {
+ ["timed_out"]=>
+ bool(false)
+ ["blocked"]=>
+ bool(true)
+ ["eof"]=>
+ bool(false)
["wrapper_type"]=>
string(9) "plainfile"
["stream_type"]=>
@@ -41,14 +47,14 @@ array(9) {
bool(true)
["uri"]=>
string(%i) "%s.tmp"
+}
+array(9) {
["timed_out"]=>
bool(false)
["blocked"]=>
bool(true)
["eof"]=>
bool(false)
-}
-array(9) {
["wrapper_type"]=>
string(9) "plainfile"
["stream_type"]=>
@@ -61,14 +67,14 @@ array(9) {
bool(true)
["uri"]=>
string(%i) "%s.tmp"
+}
+array(9) {
["timed_out"]=>
bool(false)
["blocked"]=>
bool(true)
["eof"]=>
bool(false)
-}
-array(9) {
["wrapper_type"]=>
string(9) "plainfile"
["stream_type"]=>
@@ -81,14 +87,14 @@ array(9) {
bool(true)
["uri"]=>
string(%i) "%s.tmp"
+}
+array(9) {
["timed_out"]=>
bool(false)
["blocked"]=>
bool(true)
["eof"]=>
bool(false)
-}
-array(9) {
["wrapper_type"]=>
string(9) "plainfile"
["stream_type"]=>
@@ -101,14 +107,14 @@ array(9) {
bool(true)
["uri"]=>
string(%i) "%s.tmp"
+}
+array(9) {
["timed_out"]=>
bool(false)
["blocked"]=>
bool(true)
["eof"]=>
bool(false)
-}
-array(9) {
["wrapper_type"]=>
string(9) "plainfile"
["stream_type"]=>
@@ -121,14 +127,14 @@ array(9) {
bool(true)
["uri"]=>
string(%i) "%s.tmp"
+}
+array(9) {
["timed_out"]=>
bool(false)
["blocked"]=>
bool(true)
["eof"]=>
bool(false)
-}
-array(9) {
["wrapper_type"]=>
string(9) "plainfile"
["stream_type"]=>
@@ -141,14 +147,14 @@ array(9) {
bool(true)
["uri"]=>
string(%i) "%s.tmp"
+}
+array(9) {
["timed_out"]=>
bool(false)
["blocked"]=>
bool(true)
["eof"]=>
bool(false)
-}
-array(9) {
["wrapper_type"]=>
string(9) "plainfile"
["stream_type"]=>
@@ -161,14 +167,14 @@ array(9) {
bool(true)
["uri"]=>
string(%i) "%s.tmp"
+}
+array(9) {
["timed_out"]=>
bool(false)
["blocked"]=>
bool(true)
["eof"]=>
bool(false)
-}
-array(9) {
["wrapper_type"]=>
string(9) "plainfile"
["stream_type"]=>
@@ -181,14 +187,14 @@ array(9) {
bool(true)
["uri"]=>
string(%i) "%s.tmp"
+}
+array(9) {
["timed_out"]=>
bool(false)
["blocked"]=>
bool(true)
["eof"]=>
bool(false)
-}
-array(9) {
["wrapper_type"]=>
string(9) "plainfile"
["stream_type"]=>
@@ -201,14 +207,14 @@ array(9) {
bool(true)
["uri"]=>
string(%i) "%s.tmp"
+}
+array(9) {
["timed_out"]=>
bool(false)
["blocked"]=>
bool(true)
["eof"]=>
bool(false)
-}
-array(9) {
["wrapper_type"]=>
string(9) "plainfile"
["stream_type"]=>
@@ -221,14 +227,14 @@ array(9) {
bool(true)
["uri"]=>
string(%i) "%s.tmp"
+}
+array(9) {
["timed_out"]=>
bool(false)
["blocked"]=>
bool(true)
["eof"]=>
bool(false)
-}
-array(9) {
["wrapper_type"]=>
string(9) "plainfile"
["stream_type"]=>
@@ -241,14 +247,14 @@ array(9) {
bool(true)
["uri"]=>
string(%i) "%s.tmp"
+}
+array(9) {
["timed_out"]=>
bool(false)
["blocked"]=>
bool(true)
["eof"]=>
bool(false)
-}
-array(9) {
["wrapper_type"]=>
string(9) "plainfile"
["stream_type"]=>
@@ -261,14 +267,14 @@ array(9) {
bool(true)
["uri"]=>
string(%i) "%s.tmp"
+}
+array(9) {
["timed_out"]=>
bool(false)
["blocked"]=>
bool(true)
["eof"]=>
bool(false)
-}
-array(9) {
["wrapper_type"]=>
string(9) "plainfile"
["stream_type"]=>
@@ -281,14 +287,14 @@ array(9) {
bool(true)
["uri"]=>
string(%i) "%s.tmp"
+}
+array(9) {
["timed_out"]=>
bool(false)
["blocked"]=>
bool(true)
["eof"]=>
bool(false)
-}
-array(9) {
["wrapper_type"]=>
string(9) "plainfile"
["stream_type"]=>
@@ -301,14 +307,14 @@ array(9) {
bool(true)
["uri"]=>
string(%i) "%s.tmp"
+}
+array(9) {
["timed_out"]=>
bool(false)
["blocked"]=>
bool(true)
["eof"]=>
bool(false)
-}
-array(9) {
["wrapper_type"]=>
string(9) "plainfile"
["stream_type"]=>
@@ -321,14 +327,14 @@ array(9) {
bool(true)
["uri"]=>
string(%i) "%s.tmp"
+}
+array(9) {
["timed_out"]=>
bool(false)
["blocked"]=>
bool(true)
["eof"]=>
bool(false)
-}
-array(9) {
["wrapper_type"]=>
string(9) "plainfile"
["stream_type"]=>
@@ -341,14 +347,14 @@ array(9) {
bool(true)
["uri"]=>
string(%i) "%s.tmp"
+}
+array(9) {
["timed_out"]=>
bool(false)
["blocked"]=>
bool(true)
["eof"]=>
bool(false)
-}
-array(9) {
["wrapper_type"]=>
string(9) "plainfile"
["stream_type"]=>
@@ -361,14 +367,14 @@ array(9) {
bool(true)
["uri"]=>
string(%i) "%s.tmp"
+}
+array(9) {
["timed_out"]=>
bool(false)
["blocked"]=>
bool(true)
["eof"]=>
bool(false)
-}
-array(9) {
["wrapper_type"]=>
string(9) "plainfile"
["stream_type"]=>
@@ -381,14 +387,14 @@ array(9) {
bool(true)
["uri"]=>
string(%i) "%s.tmp"
+}
+array(9) {
["timed_out"]=>
bool(false)
["blocked"]=>
bool(true)
["eof"]=>
bool(false)
-}
-array(9) {
["wrapper_type"]=>
string(9) "plainfile"
["stream_type"]=>
@@ -401,14 +407,14 @@ array(9) {
bool(true)
["uri"]=>
string(%i) "%s.tmp"
+}
+array(9) {
["timed_out"]=>
bool(false)
["blocked"]=>
bool(true)
["eof"]=>
bool(false)
-}
-array(9) {
["wrapper_type"]=>
string(9) "plainfile"
["stream_type"]=>
@@ -421,14 +427,14 @@ array(9) {
bool(true)
["uri"]=>
string(%i) "%s.tmp"
+}
+array(9) {
["timed_out"]=>
bool(false)
["blocked"]=>
bool(true)
["eof"]=>
bool(false)
-}
-array(9) {
["wrapper_type"]=>
string(9) "plainfile"
["stream_type"]=>
@@ -441,14 +447,14 @@ array(9) {
bool(true)
["uri"]=>
string(%i) "%s.tmp"
+}
+array(9) {
["timed_out"]=>
bool(false)
["blocked"]=>
bool(true)
["eof"]=>
bool(false)
-}
-array(9) {
["wrapper_type"]=>
string(9) "plainfile"
["stream_type"]=>
@@ -461,14 +467,14 @@ array(9) {
bool(true)
["uri"]=>
string(%i) "%s.tmp"
+}
+array(9) {
["timed_out"]=>
bool(false)
["blocked"]=>
bool(true)
["eof"]=>
bool(false)
-}
-array(9) {
["wrapper_type"]=>
string(9) "plainfile"
["stream_type"]=>
@@ -481,14 +487,14 @@ array(9) {
bool(true)
["uri"]=>
string(%i) "%s.tmp"
+}
+array(9) {
["timed_out"]=>
bool(false)
["blocked"]=>
bool(true)
["eof"]=>
bool(false)
-}
-array(9) {
["wrapper_type"]=>
string(9) "plainfile"
["stream_type"]=>
@@ -501,10 +507,4 @@ array(9) {
bool(true)
["uri"]=>
string(%i) "%s.tmp"
- ["timed_out"]=>
- bool(false)
- ["blocked"]=>
- bool(true)
- ["eof"]=>
- bool(false)
}
diff --git a/ext/standard/tests/streams/stream_get_meta_data_file_variation2.phpt b/ext/standard/tests/streams/stream_get_meta_data_file_variation2.phpt
index d186cb7e9b..6b3fde203a 100644
--- a/ext/standard/tests/streams/stream_get_meta_data_file_variation2.phpt
+++ b/ext/standard/tests/streams/stream_get_meta_data_file_variation2.phpt
@@ -43,6 +43,12 @@ unlink($filename);
--EXPECTF--
Write some data to the file:
array(9) {
+ ["timed_out"]=>
+ bool(false)
+ ["blocked"]=>
+ bool(true)
+ ["eof"]=>
+ bool(false)
["wrapper_type"]=>
string(9) "plainfile"
["stream_type"]=>
@@ -55,12 +61,6 @@ array(9) {
bool(true)
["uri"]=>
string(%i) "%s.tmp"
- ["timed_out"]=>
- bool(false)
- ["blocked"]=>
- bool(true)
- ["eof"]=>
- bool(false)
}
@@ -68,6 +68,12 @@ Read a line of the file, causing data to be buffered:
string(15) "a line of data
"
array(9) {
+ ["timed_out"]=>
+ bool(false)
+ ["blocked"]=>
+ bool(true)
+ ["eof"]=>
+ bool(false)
["wrapper_type"]=>
string(9) "plainfile"
["stream_type"]=>
@@ -80,17 +86,17 @@ array(9) {
bool(true)
["uri"]=>
string(%i) "%s.tmp"
+}
+
+
+Read 20 bytes from the file:
+array(9) {
["timed_out"]=>
bool(false)
["blocked"]=>
bool(true)
["eof"]=>
bool(false)
-}
-
-
-Read 20 bytes from the file:
-array(9) {
["wrapper_type"]=>
string(9) "plainfile"
["stream_type"]=>
@@ -103,17 +109,17 @@ array(9) {
bool(true)
["uri"]=>
string(%i) "%s.tmp"
- ["timed_out"]=>
- bool(false)
- ["blocked"]=>
- bool(true)
- ["eof"]=>
- bool(false)
}
Read entire file:
array(9) {
+ ["timed_out"]=>
+ bool(false)
+ ["blocked"]=>
+ bool(true)
+ ["eof"]=>
+ bool(true)
["wrapper_type"]=>
string(9) "plainfile"
["stream_type"]=>
@@ -126,10 +132,4 @@ array(9) {
bool(true)
["uri"]=>
string(%i) "%s.tmp"
- ["timed_out"]=>
- bool(false)
- ["blocked"]=>
- bool(true)
- ["eof"]=>
- bool(true)
}
diff --git a/ext/standard/tests/streams/stream_get_meta_data_file_variation4.phpt b/ext/standard/tests/streams/stream_get_meta_data_file_variation4.phpt
index c51d9bd087..46a5ba5b37 100644
--- a/ext/standard/tests/streams/stream_get_meta_data_file_variation4.phpt
+++ b/ext/standard/tests/streams/stream_get_meta_data_file_variation4.phpt
@@ -28,6 +28,12 @@ unlink($filename);
--EXPECTF--
Create a file:
array(9) {
+ ["timed_out"]=>
+ bool(false)
+ ["blocked"]=>
+ bool(true)
+ ["eof"]=>
+ bool(false)
["wrapper_type"]=>
string(9) "plainfile"
["stream_type"]=>
@@ -40,16 +46,16 @@ array(9) {
bool(true)
["uri"]=>
string(%i) "File://%sstream_get_meta_data_file_variation4.php.tmp"
+}
+
+Change to file's directory and open with a relative path:
+array(9) {
["timed_out"]=>
bool(false)
["blocked"]=>
bool(true)
["eof"]=>
bool(false)
-}
-
-Change to file's directory and open with a relative path:
-array(9) {
["wrapper_type"]=>
string(9) "plainfile"
["stream_type"]=>
@@ -62,10 +68,4 @@ array(9) {
bool(true)
["uri"]=>
string(%i) "stream_get_meta_data_file_variation4.php.tmp"
- ["timed_out"]=>
- bool(false)
- ["blocked"]=>
- bool(true)
- ["eof"]=>
- bool(false)
}
diff --git a/ext/standard/tests/streams/stream_get_meta_data_file_variation5.phpt b/ext/standard/tests/streams/stream_get_meta_data_file_variation5.phpt
index 386b92f421..22fcee4b6f 100644
--- a/ext/standard/tests/streams/stream_get_meta_data_file_variation5.phpt
+++ b/ext/standard/tests/streams/stream_get_meta_data_file_variation5.phpt
@@ -33,6 +33,12 @@ unlink($filename);
--EXPECTF--
Write some data to the file:
array(9) {
+ ["timed_out"]=>
+ bool(false)
+ ["blocked"]=>
+ bool(true)
+ ["eof"]=>
+ bool(false)
["wrapper_type"]=>
string(9) "plainfile"
["stream_type"]=>
@@ -45,17 +51,17 @@ array(9) {
bool(true)
["uri"]=>
string(%i) "%s"
- ["timed_out"]=>
- bool(false)
- ["blocked"]=>
- bool(true)
- ["eof"]=>
- bool(false)
}
Read entire file:
array(9) {
+ ["timed_out"]=>
+ bool(false)
+ ["blocked"]=>
+ bool(true)
+ ["eof"]=>
+ bool(true)
["wrapper_type"]=>
string(9) "plainfile"
["stream_type"]=>
@@ -68,10 +74,4 @@ array(9) {
bool(true)
["uri"]=>
string(%i) "%s"
- ["timed_out"]=>
- bool(false)
- ["blocked"]=>
- bool(true)
- ["eof"]=>
- bool(true)
}
diff --git a/ext/standard/tests/streams/stream_get_meta_data_process_basic.phpt b/ext/standard/tests/streams/stream_get_meta_data_process_basic.phpt
index 3f4dfbc43a..b7ab37c7c5 100644
--- a/ext/standard/tests/streams/stream_get_meta_data_process_basic.phpt
+++ b/ext/standard/tests/streams/stream_get_meta_data_process_basic.phpt
@@ -18,6 +18,12 @@ echo "Done";
?>
--EXPECT--
array(7) {
+ ["timed_out"]=>
+ bool(false)
+ ["blocked"]=>
+ bool(true)
+ ["eof"]=>
+ bool(false)
["stream_type"]=>
string(5) "STDIO"
["mode"]=>
@@ -26,11 +32,5 @@ array(7) {
int(0)
["seekable"]=>
bool(false)
- ["timed_out"]=>
- bool(false)
- ["blocked"]=>
- bool(true)
- ["eof"]=>
- bool(false)
}
Done
diff --git a/ext/standard/tests/streams/stream_get_meta_data_socket_basic.phpt b/ext/standard/tests/streams/stream_get_meta_data_socket_basic.phpt
index 86c9cd77c8..66658bd5d0 100644
--- a/ext/standard/tests/streams/stream_get_meta_data_socket_basic.phpt
+++ b/ext/standard/tests/streams/stream_get_meta_data_socket_basic.phpt
@@ -10,6 +10,12 @@ fclose($tcp_socket);
?>
--EXPECTF--
array(7) {
+ ["timed_out"]=>
+ bool(false)
+ ["blocked"]=>
+ bool(true)
+ ["eof"]=>
+ bool(false)
["stream_type"]=>
string(%d) "tcp_socke%s"
["mode"]=>
@@ -18,10 +24,4 @@ array(7) {
int(0)
["seekable"]=>
bool(false)
- ["timed_out"]=>
- bool(false)
- ["blocked"]=>
- bool(true)
- ["eof"]=>
- bool(false)
}
diff --git a/ext/standard/tests/streams/stream_get_meta_data_socket_variation1.phpt b/ext/standard/tests/streams/stream_get_meta_data_socket_variation1.phpt
index 88d354b378..1c7f1fd256 100644
--- a/ext/standard/tests/streams/stream_get_meta_data_socket_variation1.phpt
+++ b/ext/standard/tests/streams/stream_get_meta_data_socket_variation1.phpt
@@ -39,6 +39,12 @@ var_dump(stream_get_meta_data($client));
--EXPECTF--
Write some data:
array(7) {
+ ["timed_out"]=>
+ bool(false)
+ ["blocked"]=>
+ bool(true)
+ ["eof"]=>
+ bool(false)
["stream_type"]=>
string(%d) "tcp_socke%s"
["mode"]=>
@@ -47,17 +53,17 @@ array(7) {
int(0)
["seekable"]=>
bool(false)
+}
+
+
+Read a line from the client, causing data to be buffered:
+array(7) {
["timed_out"]=>
bool(false)
["blocked"]=>
bool(true)
["eof"]=>
bool(false)
-}
-
-
-Read a line from the client, causing data to be buffered:
-array(7) {
["stream_type"]=>
string(%d) "tcp_socke%s"
["mode"]=>
@@ -66,17 +72,17 @@ array(7) {
int(15)
["seekable"]=>
bool(false)
+}
+
+
+Read 3 bytes of data from the client:
+array(7) {
["timed_out"]=>
bool(false)
["blocked"]=>
bool(true)
["eof"]=>
bool(false)
-}
-
-
-Read 3 bytes of data from the client:
-array(7) {
["stream_type"]=>
string(%d) "tcp_socke%s"
["mode"]=>
@@ -85,17 +91,17 @@ array(7) {
int(12)
["seekable"]=>
bool(false)
- ["timed_out"]=>
- bool(false)
- ["blocked"]=>
- bool(true)
- ["eof"]=>
- bool(false)
}
Close the server side socket and read the remaining data from the client:
array(7) {
+ ["timed_out"]=>
+ bool(false)
+ ["blocked"]=>
+ bool(true)
+ ["eof"]=>
+ bool(true)
["stream_type"]=>
string(%d) "tcp_socke%s"
["mode"]=>
@@ -104,10 +110,4 @@ array(7) {
int(0)
["seekable"]=>
bool(false)
- ["timed_out"]=>
- bool(false)
- ["blocked"]=>
- bool(true)
- ["eof"]=>
- bool(true)
}
diff --git a/ext/standard/tests/streams/stream_get_meta_data_socket_variation2.phpt b/ext/standard/tests/streams/stream_get_meta_data_socket_variation2.phpt
index e8e39209c9..cb713c8525 100644
--- a/ext/standard/tests/streams/stream_get_meta_data_socket_variation2.phpt
+++ b/ext/standard/tests/streams/stream_get_meta_data_socket_variation2.phpt
@@ -37,25 +37,12 @@ fclose($server);
?>
--EXPECTF--
array(7) {
- ["stream_type"]=>
- string(%d) "tcp_socke%s"
- ["mode"]=>
- string(2) "r+"
- ["unread_bytes"]=>
- int(0)
- ["seekable"]=>
- bool(false)
["timed_out"]=>
bool(false)
["blocked"]=>
bool(true)
["eof"]=>
bool(false)
-}
-
-
-Set a timeout on the client and attempt a read:
-array(7) {
["stream_type"]=>
string(%d) "tcp_socke%s"
["mode"]=>
@@ -64,17 +51,17 @@ array(7) {
int(0)
["seekable"]=>
bool(false)
+}
+
+
+Set a timeout on the client and attempt a read:
+array(7) {
["timed_out"]=>
bool(true)
["blocked"]=>
bool(true)
["eof"]=>
bool(false)
-}
-
-
-Write some data from the server:
-array(7) {
["stream_type"]=>
string(%d) "tcp_socke%s"
["mode"]=>
@@ -83,17 +70,17 @@ array(7) {
int(0)
["seekable"]=>
bool(false)
+}
+
+
+Write some data from the server:
+array(7) {
["timed_out"]=>
bool(true)
["blocked"]=>
bool(true)
["eof"]=>
bool(false)
-}
-
-
-Read some data from the client:
-array(7) {
["stream_type"]=>
string(%d) "tcp_socke%s"
["mode"]=>
@@ -102,10 +89,23 @@ array(7) {
int(0)
["seekable"]=>
bool(false)
+}
+
+
+Read some data from the client:
+array(7) {
["timed_out"]=>
bool(false)
["blocked"]=>
bool(true)
["eof"]=>
bool(false)
+ ["stream_type"]=>
+ string(%d) "tcp_socke%s"
+ ["mode"]=>
+ string(2) "r+"
+ ["unread_bytes"]=>
+ int(0)
+ ["seekable"]=>
+ bool(false)
}
diff --git a/ext/standard/tests/streams/stream_get_meta_data_socket_variation3.phpt b/ext/standard/tests/streams/stream_get_meta_data_socket_variation3.phpt
index 5b68eba25d..c7f08cbe12 100644
--- a/ext/standard/tests/streams/stream_get_meta_data_socket_variation3.phpt
+++ b/ext/standard/tests/streams/stream_get_meta_data_socket_variation3.phpt
@@ -32,6 +32,12 @@ fclose($server);
?>
--EXPECTF--
array(7) {
+ ["timed_out"]=>
+ bool(false)
+ ["blocked"]=>
+ bool(true)
+ ["eof"]=>
+ bool(false)
["stream_type"]=>
string(%d) "tcp_socke%s"
["mode"]=>
@@ -40,18 +46,18 @@ array(7) {
int(0)
["seekable"]=>
bool(false)
- ["timed_out"]=>
- bool(false)
- ["blocked"]=>
- bool(true)
- ["eof"]=>
- bool(false)
}
Set blocking to false:
bool(true)
array(7) {
+ ["timed_out"]=>
+ bool(false)
+ ["blocked"]=>
+ bool(false)
+ ["eof"]=>
+ bool(false)
["stream_type"]=>
string(%d) "tcp_socke%s"
["mode"]=>
@@ -60,18 +66,18 @@ array(7) {
int(0)
["seekable"]=>
bool(false)
- ["timed_out"]=>
- bool(false)
- ["blocked"]=>
- bool(false)
- ["eof"]=>
- bool(false)
}
Set blocking to true:
bool(true)
array(7) {
+ ["timed_out"]=>
+ bool(false)
+ ["blocked"]=>
+ bool(true)
+ ["eof"]=>
+ bool(false)
["stream_type"]=>
string(%d) "tcp_socke%s"
["mode"]=>
@@ -80,10 +86,4 @@ array(7) {
int(0)
["seekable"]=>
bool(false)
- ["timed_out"]=>
- bool(false)
- ["blocked"]=>
- bool(true)
- ["eof"]=>
- bool(false)
}
diff --git a/ext/standard/tests/streams/stream_get_meta_data_socket_variation4.phpt b/ext/standard/tests/streams/stream_get_meta_data_socket_variation4.phpt
index e3f59d10dc..e37e991f16 100644
--- a/ext/standard/tests/streams/stream_get_meta_data_socket_variation4.phpt
+++ b/ext/standard/tests/streams/stream_get_meta_data_socket_variation4.phpt
@@ -37,6 +37,12 @@ fclose($client);
--EXPECTF--
Write some data:
array(7) {
+ ["timed_out"]=>
+ bool(false)
+ ["blocked"]=>
+ bool(true)
+ ["eof"]=>
+ bool(false)
["stream_type"]=>
string(%d) "tcp_socke%s"
["mode"]=>
@@ -45,17 +51,17 @@ array(7) {
int(%i)
["seekable"]=>
bool(false)
+}
+
+
+Read a line from the client:
+array(7) {
["timed_out"]=>
bool(false)
["blocked"]=>
bool(true)
["eof"]=>
bool(false)
-}
-
-
-Read a line from the client:
-array(7) {
["stream_type"]=>
string(%d) "tcp_socke%s"
["mode"]=>
@@ -64,17 +70,17 @@ array(7) {
int(%i)
["seekable"]=>
bool(false)
- ["timed_out"]=>
- bool(false)
- ["blocked"]=>
- bool(true)
- ["eof"]=>
- bool(false)
}
Close the server side socket and read the remaining data from the client:
array(7) {
+ ["timed_out"]=>
+ bool(false)
+ ["blocked"]=>
+ bool(true)
+ ["eof"]=>
+ bool(true)
["stream_type"]=>
string(%d) "tcp_socke%s"
["mode"]=>
@@ -83,10 +89,4 @@ array(7) {
int(%i)
["seekable"]=>
bool(false)
- ["timed_out"]=>
- bool(false)
- ["blocked"]=>
- bool(true)
- ["eof"]=>
- bool(true)
}
diff --git a/ext/standard/tests/streams/stream_socket_enable_crypto-win32.phpt b/ext/standard/tests/streams/stream_socket_enable_crypto-win32.phpt
new file mode 100644
index 0000000000..c61e93d038
--- /dev/null
+++ b/ext/standard/tests/streams/stream_socket_enable_crypto-win32.phpt
@@ -0,0 +1,70 @@
+--TEST--
+mixed stream_socket_enable_crypto(resource $stream , bool $enable [, int $crypto_type [, resource $session_stream ]] ) ;
+--CREDITS--
+marcosptf - <marcosptf@yahoo.com.br> - #phparty7 - @phpsp - novatec/2015 - sao paulo - br
+--SKIPIF--
+<?php
+if (!extension_loaded('openssl')) {
+ die('skip ext openssl required');
+}
+if (substr(PHP_OS, 0, 3) != 'WIN' ) {
+ die('skip windows only test');
+}
+?>
+--FILE--
+<?php
+$serverUri = "tcp://127.0.0.1:31854";
+$sock = stream_socket_server($serverUri, $errno, $errstr);
+
+if (is_resource($sock)) {
+ var_dump(stream_socket_enable_crypto($sock, false));
+ var_dump(stream_socket_enable_crypto($sock, true));
+ var_dump(stream_socket_enable_crypto($sock, true, STREAM_CRYPTO_METHOD_SSLv2_CLIENT));
+ var_dump(stream_socket_enable_crypto($sock, true, STREAM_CRYPTO_METHOD_SSLv3_CLIENT));
+ var_dump(stream_socket_enable_crypto($sock, true, STREAM_CRYPTO_METHOD_SSLv23_CLIENT));
+ var_dump(stream_socket_enable_crypto($sock, true, STREAM_CRYPTO_METHOD_TLS_CLIENT));
+ var_dump(stream_socket_enable_crypto($sock, true, STREAM_CRYPTO_METHOD_SSLv2_SERVER));
+ var_dump(stream_socket_enable_crypto($sock, true, STREAM_CRYPTO_METHOD_SSLv3_SERVER));
+ var_dump(stream_socket_enable_crypto($sock, true, STREAM_CRYPTO_METHOD_SSLv23_SERVER));
+ var_dump(stream_socket_enable_crypto($sock, true, STREAM_CRYPTO_METHOD_TLS_SERVER));
+} else {
+ die("Test stream_socket_enable_crypto has failed; Unable to connect: {$errstr} ({$errno})");
+}
+?>
+--CLEAN--
+<?php
+unset($serverUri);
+unset($sock);
+unset($errno);
+unset($errstr);
+?>
+--EXPECTF--
+bool(false)
+
+Warning: stream_socket_enable_crypto(): When enabling encryption you must specify the crypto type in %s on line %d
+bool(false)
+
+Warning: stream_socket_enable_crypto(): SSLv2 unavailable in the OpenSSL library against which PHP is linked in %s on line %d
+bool(false)
+
+Warning: stream_socket_enable_crypto(): SSL: A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using a sendto call) no address was supplied.
+ in %s on line %d
+bool(false)
+
+Warning: stream_socket_enable_crypto(): SSL/TLS already set-up for this stream in %s on line %d
+bool(false)
+
+Warning: stream_socket_enable_crypto(): SSL/TLS already set-up for this stream in %s on line %d
+bool(false)
+
+Warning: stream_socket_enable_crypto(): SSL/TLS already set-up for this stream in %s on line %d
+bool(false)
+
+Warning: stream_socket_enable_crypto(): SSL/TLS already set-up for this stream in %s on line %d
+bool(false)
+
+Warning: stream_socket_enable_crypto(): SSL/TLS already set-up for this stream in %s on line %d
+bool(false)
+
+Warning: stream_socket_enable_crypto(): SSL/TLS already set-up for this stream in %s on line %d
+bool(false)
diff --git a/ext/standard/tests/streams/stream_socket_enable_crypto.phpt b/ext/standard/tests/streams/stream_socket_enable_crypto.phpt
index 47d6c62893..e7ee3e5b3b 100644
--- a/ext/standard/tests/streams/stream_socket_enable_crypto.phpt
+++ b/ext/standard/tests/streams/stream_socket_enable_crypto.phpt
@@ -4,8 +4,12 @@ mixed stream_socket_enable_crypto(resource $stream , bool $enable [, int $crypto
marcosptf - <marcosptf@yahoo.com.br> - #phparty7 - @phpsp - novatec/2015 - sao paulo - br
--SKIPIF--
<?php
-if (phpversion() < "5.3.0") { die('SKIP php version so lower.'); }
-if (!extension_loaded('openssl')) { die('ext/openssl required'); }
+if (!extension_loaded('openssl')) {
+ die('skip ext/openssl required');
+}
+if(substr(PHP_OS, 0, 3) == 'WIN' ) {
+ die('skip not for windows');
+}
?>
--FILE--
<?php
@@ -15,8 +19,8 @@ $sock = stream_socket_server($serverUri, $errno, $errstr);
if (is_resource($sock)) {
var_dump(stream_socket_enable_crypto($sock, false));
var_dump(stream_socket_enable_crypto($sock, true));
- var_dump(stream_socket_enable_crypto($sock, true, STREAM_CRYPTO_METHOD_SSLv2_CLIENT));
var_dump(stream_socket_enable_crypto($sock, true, STREAM_CRYPTO_METHOD_SSLv3_CLIENT));
+ var_dump(stream_socket_enable_crypto($sock, true, STREAM_CRYPTO_METHOD_SSLv2_CLIENT));
var_dump(stream_socket_enable_crypto($sock, true, STREAM_CRYPTO_METHOD_SSLv23_CLIENT));
var_dump(stream_socket_enable_crypto($sock, true, STREAM_CRYPTO_METHOD_TLS_CLIENT));
var_dump(stream_socket_enable_crypto($sock, true, STREAM_CRYPTO_METHOD_SSLv2_SERVER));
@@ -40,10 +44,10 @@ bool(false)
Warning: stream_socket_enable_crypto(): When enabling encryption you must specify the crypto type in %s on line %d
bool(false)
-Warning: stream_socket_enable_crypto(): SSLv2 %s in %s on line %d
+Warning: stream_socket_enable_crypto(): SSL: Broken pipe in %s on line %d
bool(false)
-Warning: stream_socket_enable_crypto(): SSL: Broken pipe in %s on line %d
+Warning: stream_socket_enable_crypto(): SSL/TLS already set-up for this stream in %s on line %d
bool(false)
Warning: stream_socket_enable_crypto(): SSL/TLS already set-up for this stream in %s on line %d
diff --git a/ext/standard/tests/strings/bug53021.phpt b/ext/standard/tests/strings/bug53021.phpt
index 4a8fbe4f76..38d904761d 100644
--- a/ext/standard/tests/strings/bug53021.phpt
+++ b/ext/standard/tests/strings/bug53021.phpt
@@ -10,11 +10,14 @@ echo html_entity_decode("&quot;", ENT_QUOTES, 'UTF-8'), "\n";
echo html_entity_decode("&#34;", ENT_QUOTES, 'UTF-8'), "\n";
echo html_entity_decode("&quot;", ENT_COMPAT, 'UTF-8'), "\n";
echo html_entity_decode("&#34;", ENT_COMPAT, 'UTF-8'), "\n";
+echo html_entity_decode("&quot;"), "\n";
+echo html_entity_decode("&#34;"), "\n";
echo "\nsingle quotes variations:", "\n";
echo html_entity_decode("&#39;", ENT_NOQUOTES, 'UTF-8'), "\n";
echo html_entity_decode("&#39;", ENT_QUOTES, 'UTF-8'), "\n";
echo html_entity_decode("&#39;", ENT_COMPAT, 'UTF-8'), "\n";
+echo html_entity_decode("&#39;"), "\n";
--EXPECT--
array(1) {
[1]=>
@@ -27,8 +30,11 @@ double quotes variations:
"
"
"
+"
+"
single quotes variations:
&#39;
'
&#39;
+&#39;
diff --git a/ext/standard/tests/strings/bug70720.phpt b/ext/standard/tests/strings/bug70720.phpt
index edf60080ac..6cdc600c2d 100644
--- a/ext/standard/tests/strings/bug70720.phpt
+++ b/ext/standard/tests/strings/bug70720.phpt
@@ -5,8 +5,12 @@ Bug #70720 (strip_tags() doesnt handle "xml" correctly)
var_dump(strip_tags('<?php $dom->test(); ?> this is a test'));
var_dump(strip_tags('<?php $xml->test(); ?> this is a test'));
var_dump(strip_tags('<?xml $xml->test(); ?> this is a test'));
+
+/* "->" case in HTML */
+var_dump(strip_tags("<span class=sf-dump-> this is a test</span>"));
?>
--EXPECTF--
string(15) " this is a test"
string(15) " this is a test"
-string(15) " this is a test" \ No newline at end of file
+string(15) " this is a test"
+string(15) " this is a test"
diff --git a/ext/standard/tests/strings/html_entity_decode3.phpt b/ext/standard/tests/strings/html_entity_decode3.phpt
index fcf2710679..48cff17bda 100644
--- a/ext/standard/tests/strings/html_entity_decode3.phpt
+++ b/ext/standard/tests/strings/html_entity_decode3.phpt
@@ -14,6 +14,7 @@ $tests = array(
"&#x0E;",
"&#x1F;",
"&#x20;", //allowed always
+ "&#x27;", //single quote, depends on flags
"&#x7F;", //DEL
"&#x80;", //C1
"&#x9F;",
@@ -76,6 +77,17 @@ foreach ($tests as $t) {
}
}
+echo "\n*** Default options ***\n";
+
+foreach ($tests as $t) {
+ $dec = html_entity_decode($t);
+ if ($t == $dec) {
+ echo "$t\tNOT DECODED\n";
+ } else {
+ echo "$t\tDECODED\n";
+ }
+}
+
echo "\nDone.\n";
--EXPECT--
*** HTML 4.01 ***
@@ -89,6 +101,7 @@ echo "\nDone.\n";
&#x0E; NOT DECODED
&#x1F; NOT DECODED
&#x20; DECODED
+&#x27; DECODED
&#x7F; NOT DECODED
&#x80; NOT DECODED
&#x9F; NOT DECODED
@@ -117,6 +130,7 @@ echo "\nDone.\n";
&#x0E; NOT DECODED
&#x1F; NOT DECODED
&#x20; DECODED
+&#x27; DECODED
&#x7F; DECODED
&#x80; DECODED
&#x9F; DECODED
@@ -145,6 +159,7 @@ echo "\nDone.\n";
&#x0E; NOT DECODED
&#x1F; NOT DECODED
&#x20; DECODED
+&#x27; DECODED
&#x7F; NOT DECODED
&#x80; NOT DECODED
&#x9F; NOT DECODED
@@ -173,6 +188,7 @@ echo "\nDone.\n";
&#x0E; NOT DECODED
&#x1F; NOT DECODED
&#x20; DECODED
+&#x27; DECODED
&#x7F; DECODED
&#x80; DECODED
&#x9F; DECODED
@@ -190,4 +206,33 @@ echo "\nDone.\n";
&#x2FFFE; DECODED
&#x2FFFF; DECODED
+*** Default options ***
+&#0; NOT DECODED
+&#1; NOT DECODED
+&#x09; DECODED
+&#x0A; DECODED
+&#x0B; NOT DECODED
+&#x0C; NOT DECODED
+&#x0D; DECODED
+&#x0E; NOT DECODED
+&#x1F; NOT DECODED
+&#x20; DECODED
+&#x27; NOT DECODED
+&#x7F; NOT DECODED
+&#x80; NOT DECODED
+&#x9F; NOT DECODED
+&#xA0; DECODED
+&#xD7FF; DECODED
+&#xD800; NOT DECODED
+&#xDFFF; NOT DECODED
+&#xE000; DECODED
+&#xFFFE; DECODED
+&#xFFFF; DECODED
+&#xFDCF; DECODED
+&#xFDD0; DECODED
+&#xFDEF; DECODED
+&#xFDF0; DECODED
+&#x2FFFE; DECODED
+&#x2FFFF; DECODED
+
Done.
diff --git a/ext/standard/var.c b/ext/standard/var.c
index 3b03c32ca2..fcee7a9cc6 100644
--- a/ext/standard/var.c
+++ b/ext/standard/var.c
@@ -108,7 +108,7 @@ again:
php_printf("%sfloat(%.*G)\n", COMMON, (int) EG(precision), Z_DVAL_P(struc));
break;
case IS_STRING:
- php_printf("%sstring(%d) \"", COMMON, Z_STRLEN_P(struc));
+ php_printf("%sstring(%zd) \"", COMMON, Z_STRLEN_P(struc));
PHPWRITE(Z_STRVAL_P(struc), Z_STRLEN_P(struc));
PUTS("\"\n");
break;
@@ -278,7 +278,7 @@ again:
php_printf("%sfloat(%.*G)\n", COMMON, (int) EG(precision), Z_DVAL_P(struc));
break;
case IS_STRING:
- php_printf("%sstring(%d) \"", COMMON, Z_STRLEN_P(struc));
+ php_printf("%sstring(%zd) \"", COMMON, Z_STRLEN_P(struc));
PHPWRITE(Z_STRVAL_P(struc), Z_STRLEN_P(struc));
php_printf("\" refcount(%u)\n", Z_REFCOUNTED_P(struc) ? Z_REFCOUNT_P(struc) : 1);
break;
@@ -336,7 +336,7 @@ again:
break;
case IS_RESOURCE: {
const char *type_name = zend_rsrc_list_get_rsrc_type(Z_RES_P(struc));
- php_printf("%sresource(" ZEND_LONG_FMT ") of type (%s) refcount(%u)\n", COMMON, Z_RES_P(struc)->handle, type_name ? type_name : "Unknown", Z_REFCOUNT_P(struc));
+ php_printf("%sresource(%d) of type (%s) refcount(%u)\n", COMMON, Z_RES_P(struc)->handle, type_name ? type_name : "Unknown", Z_REFCOUNT_P(struc));
break;
}
case IS_REFERENCE:
@@ -463,8 +463,10 @@ again:
/* Without a decimal point, PHP treats a number literal as an int.
* This check even works for scientific notation, because the
* mantissa always contains a decimal point.
+ * We need to check for finiteness, because INF, -INF and NAN
+ * must not have a decimal point added.
*/
- if (NULL == strchr(tmp_str, '.')) {
+ if (zend_finite(Z_DVAL_P(struc)) && NULL == strchr(tmp_str, '.')) {
smart_str_appendl(buf, ".0", 2);
}
efree(tmp_str);
@@ -1043,7 +1045,8 @@ PHP_FUNCTION(unserialize)
}
zval_ptr_dtor(return_value);
if (!EG(exception)) {
- php_error_docref(NULL, E_NOTICE, "Error at offset " ZEND_LONG_FMT " of %d bytes", (zend_long)((char*)p - buf), buf_len);
+ php_error_docref(NULL, E_NOTICE, "Error at offset " ZEND_LONG_FMT " of %zd bytes",
+ (zend_long)((char*)p - buf), buf_len);
}
RETURN_FALSE;
}
diff --git a/ext/standard/var_unserializer.c b/ext/standard/var_unserializer.c
index 20709eee81..12a15c3a69 100644
--- a/ext/standard/var_unserializer.c
+++ b/ext/standard/var_unserializer.c
@@ -1,4 +1,4 @@
-/* Generated by re2c 0.13.5 */
+/* Generated by re2c 0.13.7.5 */
#line 1 "ext/standard/var_unserializer.re"
/*
+----------------------------------------------------------------------+
@@ -574,7 +574,7 @@ yy2:
yych = *(YYMARKER = ++YYCURSOR);
if (yych == ':') goto yy95;
yy3:
-#line 869 "ext/standard/var_unserializer.re"
+#line 873 "ext/standard/var_unserializer.re"
{ return 0; }
#line 580 "ext/standard/var_unserializer.c"
yy4:
@@ -619,7 +619,7 @@ yy13:
goto yy3;
yy14:
++YYCURSOR;
-#line 863 "ext/standard/var_unserializer.re"
+#line 867 "ext/standard/var_unserializer.re"
{
/* this is the case where we have less data than planned */
php_error_docref(NULL, E_NOTICE, "Unexpected end of serialized data");
@@ -651,11 +651,12 @@ yy20:
if (yybm[0+yych] & 128) {
goto yy20;
}
- if (yych != ':') goto yy18;
+ if (yych <= '/') goto yy18;
+ if (yych >= ';') goto yy18;
yych = *++YYCURSOR;
if (yych != '"') goto yy18;
++YYCURSOR;
-#line 718 "ext/standard/var_unserializer.re"
+#line 722 "ext/standard/var_unserializer.re"
{
size_t len, len2, len3, maxlen;
zend_long elements;
@@ -800,7 +801,7 @@ yy20:
return object_common2(UNSERIALIZE_PASSTHRU, elements);
}
-#line 804 "ext/standard/var_unserializer.c"
+#line 805 "ext/standard/var_unserializer.c"
yy25:
yych = *++YYCURSOR;
if (yych <= ',') {
@@ -825,14 +826,14 @@ yy27:
yych = *++YYCURSOR;
if (yych != '"') goto yy18;
++YYCURSOR;
-#line 711 "ext/standard/var_unserializer.re"
+#line 715 "ext/standard/var_unserializer.re"
{
if (!var_hash) return 0;
return object_common2(UNSERIALIZE_PASSTHRU,
object_common1(UNSERIALIZE_PASSTHRU, ZEND_STANDARD_CLASS_DEF_PTR));
}
-#line 836 "ext/standard/var_unserializer.c"
+#line 837 "ext/standard/var_unserializer.c"
yy32:
yych = *++YYCURSOR;
if (yych == '+') goto yy33;
@@ -853,7 +854,7 @@ yy34:
yych = *++YYCURSOR;
if (yych != '{') goto yy18;
++YYCURSOR;
-#line 687 "ext/standard/var_unserializer.re"
+#line 691 "ext/standard/var_unserializer.re"
{
zend_long elements = parse_iv(start + 2);
/* use iv() not uiv() in order to check data range */
@@ -877,7 +878,7 @@ yy34:
return finish_nested_data(UNSERIALIZE_PASSTHRU);
}
-#line 881 "ext/standard/var_unserializer.c"
+#line 882 "ext/standard/var_unserializer.c"
yy39:
yych = *++YYCURSOR;
if (yych == '+') goto yy40;
@@ -898,7 +899,7 @@ yy41:
yych = *++YYCURSOR;
if (yych != '"') goto yy18;
++YYCURSOR;
-#line 659 "ext/standard/var_unserializer.re"
+#line 663 "ext/standard/var_unserializer.re"
{
size_t len, maxlen;
zend_string *str;
@@ -926,7 +927,7 @@ yy41:
ZVAL_STR(rval, str);
return 1;
}
-#line 930 "ext/standard/var_unserializer.c"
+#line 931 "ext/standard/var_unserializer.c"
yy46:
yych = *++YYCURSOR;
if (yych == '+') goto yy47;
@@ -947,7 +948,7 @@ yy48:
yych = *++YYCURSOR;
if (yych != '"') goto yy18;
++YYCURSOR;
-#line 632 "ext/standard/var_unserializer.re"
+#line 636 "ext/standard/var_unserializer.re"
{
size_t len, maxlen;
char *str;
@@ -974,7 +975,7 @@ yy48:
ZVAL_STRINGL(rval, str, len);
return 1;
}
-#line 978 "ext/standard/var_unserializer.c"
+#line 979 "ext/standard/var_unserializer.c"
yy53:
yych = *++YYCURSOR;
if (yych <= '/') {
@@ -1062,7 +1063,7 @@ yy61:
}
yy63:
++YYCURSOR;
-#line 623 "ext/standard/var_unserializer.re"
+#line 627 "ext/standard/var_unserializer.re"
{
#if SIZEOF_ZEND_LONG == 4
use_double:
@@ -1071,7 +1072,7 @@ use_double:
ZVAL_DOUBLE(rval, zend_strtod((const char *)start + 2, NULL));
return 1;
}
-#line 1075 "ext/standard/var_unserializer.c"
+#line 1076 "ext/standard/var_unserializer.c"
yy65:
yych = *++YYCURSOR;
if (yych <= ',') {
@@ -1130,7 +1131,7 @@ yy73:
yych = *++YYCURSOR;
if (yych != ';') goto yy18;
++YYCURSOR;
-#line 607 "ext/standard/var_unserializer.re"
+#line 611 "ext/standard/var_unserializer.re"
{
*p = YYCURSOR;
@@ -1146,7 +1147,7 @@ yy73:
return 1;
}
-#line 1150 "ext/standard/var_unserializer.c"
+#line 1151 "ext/standard/var_unserializer.c"
yy76:
yych = *++YYCURSOR;
if (yych == 'N') goto yy73;
@@ -1173,7 +1174,7 @@ yy79:
if (yych <= '9') goto yy79;
if (yych != ';') goto yy18;
++YYCURSOR;
-#line 581 "ext/standard/var_unserializer.re"
+#line 585 "ext/standard/var_unserializer.re"
{
#if SIZEOF_ZEND_LONG == 4
int digits = YYCURSOR - start - 3;
@@ -1199,7 +1200,7 @@ yy79:
ZVAL_LONG(rval, parse_iv(start + 2));
return 1;
}
-#line 1203 "ext/standard/var_unserializer.c"
+#line 1204 "ext/standard/var_unserializer.c"
yy83:
yych = *++YYCURSOR;
if (yych <= '/') goto yy18;
@@ -1207,22 +1208,22 @@ yy83:
yych = *++YYCURSOR;
if (yych != ';') goto yy18;
++YYCURSOR;
-#line 575 "ext/standard/var_unserializer.re"
+#line 579 "ext/standard/var_unserializer.re"
{
*p = YYCURSOR;
ZVAL_BOOL(rval, parse_iv(start + 2));
return 1;
}
-#line 1217 "ext/standard/var_unserializer.c"
+#line 1218 "ext/standard/var_unserializer.c"
yy87:
++YYCURSOR;
-#line 569 "ext/standard/var_unserializer.re"
+#line 573 "ext/standard/var_unserializer.re"
{
*p = YYCURSOR;
ZVAL_NULL(rval);
return 1;
}
-#line 1226 "ext/standard/var_unserializer.c"
+#line 1227 "ext/standard/var_unserializer.c"
yy89:
yych = *++YYCURSOR;
if (yych <= ',') {
@@ -1257,6 +1258,10 @@ yy91:
return 0;
}
+ if (rval_ref == rval) {
+ return 0;
+ }
+
if (Z_ISUNDEF_P(rval_ref) || (Z_ISREF_P(rval_ref) && Z_ISUNDEF_P(Z_REFVAL_P(rval_ref)))) {
ZVAL_UNDEF(rval);
return 1;
@@ -1266,7 +1271,7 @@ yy91:
return 1;
}
-#line 1270 "ext/standard/var_unserializer.c"
+#line 1275 "ext/standard/var_unserializer.c"
yy95:
yych = *++YYCURSOR;
if (yych <= ',') {
@@ -1315,9 +1320,9 @@ yy97:
return 1;
}
-#line 1319 "ext/standard/var_unserializer.c"
+#line 1324 "ext/standard/var_unserializer.c"
}
-#line 871 "ext/standard/var_unserializer.re"
+#line 875 "ext/standard/var_unserializer.re"
return 0;
diff --git a/ext/standard/var_unserializer.re b/ext/standard/var_unserializer.re
index 18e3cb381f..e4db9090b9 100644
--- a/ext/standard/var_unserializer.re
+++ b/ext/standard/var_unserializer.re
@@ -556,6 +556,10 @@ PHPAPI int php_var_unserialize_ex(UNSERIALIZE_PARAMETER)
return 0;
}
+ if (rval_ref == rval) {
+ return 0;
+ }
+
if (Z_ISUNDEF_P(rval_ref) || (Z_ISREF_P(rval_ref) && Z_ISUNDEF_P(Z_REFVAL_P(rval_ref)))) {
ZVAL_UNDEF(rval);
return 1;