summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
Diffstat (limited to 'main')
-rw-r--r--main/SAPI.c45
-rw-r--r--main/SAPI.h23
-rw-r--r--main/build-defs.h.in2
-rw-r--r--main/explicit_bzero.c4
-rw-r--r--main/fastcgi.c2
-rw-r--r--main/fastcgi.h4
-rw-r--r--main/fopen_wrappers.c36
-rw-r--r--main/fopen_wrappers.h2
-rw-r--r--main/getopt.c2
-rw-r--r--main/http_status_codes.h2
-rw-r--r--main/internal_functions.c.in2
-rw-r--r--main/internal_functions_win32.c8
-rw-r--r--main/main.c558
-rw-r--r--main/mergesort.c347
-rw-r--r--main/network.c20
-rw-r--r--main/output.c113
-rw-r--r--main/php.h18
-rw-r--r--main/php_compat.h2
-rw-r--r--main/php_content_types.c14
-rw-r--r--main/php_content_types.h2
-rw-r--r--main/php_getopt.h2
-rw-r--r--main/php_globals.h8
-rw-r--r--main/php_ini.c75
-rw-r--r--main/php_ini.h4
-rw-r--r--main/php_main.h2
-rw-r--r--main/php_memory_streams.h6
-rw-r--r--main/php_network.h6
-rw-r--r--main/php_open_temporary_file.c2
-rw-r--r--main/php_open_temporary_file.h2
-rw-r--r--main/php_output.h2
-rw-r--r--main/php_reentrancy.h8
-rw-r--r--main/php_scandir.c2
-rw-r--r--main/php_scandir.h2
-rw-r--r--main/php_stdint.h181
-rw-r--r--main/php_streams.h6
-rw-r--r--main/php_syslog.c2
-rw-r--r--main/php_syslog.h2
-rw-r--r--main/php_ticks.c2
-rw-r--r--main/php_ticks.h2
-rw-r--r--main/php_variables.c82
-rw-r--r--main/php_variables.h10
-rw-r--r--main/php_version.h10
-rw-r--r--main/reentrancy.c59
-rw-r--r--main/rfc1867.c23
-rw-r--r--main/rfc1867.h2
-rw-r--r--main/snprintf.c25
-rw-r--r--main/snprintf.h2
-rw-r--r--main/spprintf.c24
-rw-r--r--main/spprintf.h2
-rw-r--r--main/streams/cast.c6
-rw-r--r--main/streams/filter.c6
-rw-r--r--main/streams/glob_wrapper.c2
-rw-r--r--main/streams/memory.c14
-rw-r--r--main/streams/mmap.c2
-rw-r--r--main/streams/php_stream_context.h4
-rw-r--r--main/streams/php_stream_filter_api.h2
-rw-r--r--main/streams/php_stream_glob_wrapper.h2
-rw-r--r--main/streams/php_stream_mmap.h2
-rw-r--r--main/streams/php_stream_plain_wrapper.h2
-rw-r--r--main/streams/php_stream_transport.h2
-rw-r--r--main/streams/php_stream_userspace.h2
-rw-r--r--main/streams/php_streams_int.h2
-rw-r--r--main/streams/plain_wrapper.c40
-rw-r--r--main/streams/streams.c56
-rw-r--r--main/streams/transports.c10
-rw-r--r--main/streams/userspace.c196
-rw-r--r--main/streams/xp_socket.c15
-rw-r--r--main/strlcat.c4
-rw-r--r--main/strlcpy.c4
69 files changed, 544 insertions, 1590 deletions
diff --git a/main/SAPI.c b/main/SAPI.c
index a5a68f8c68..01ec31f722 100644
--- a/main/SAPI.c
+++ b/main/SAPI.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -56,7 +54,7 @@ static void _type_dtor(zval *zv)
static void sapi_globals_ctor(sapi_globals_struct *sapi_globals)
{
memset(sapi_globals, 0, sizeof(*sapi_globals));
- zend_hash_init_ex(&sapi_globals->known_post_content_types, 8, NULL, _type_dtor, 1, 0);
+ zend_hash_init(&sapi_globals->known_post_content_types, 8, NULL, _type_dtor, 1);
php_setup_sapi_content_types();
}
@@ -111,18 +109,14 @@ SAPI_API void sapi_free_header(sapi_header_struct *sapi_header)
efree(sapi_header->header);
}
-/* {{{ proto bool header_register_callback(mixed callback)
- call a header function */
+/* {{{ call a header function */
PHP_FUNCTION(header_register_callback)
{
- zval *callback_func;
-
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &callback_func) == FAILURE) {
- return;
- }
+ zend_fcall_info fci;
+ zend_fcall_info_cache fcc;
- if (!zend_is_callable(callback_func, 0, NULL)) {
- RETURN_FALSE;
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "f", &fci, &fcc) == FAILURE) {
+ RETURN_THROWS();
}
if (Z_TYPE(SG(callback_func)) != IS_UNDEF) {
@@ -130,7 +124,7 @@ PHP_FUNCTION(header_register_callback)
SG(fci_cache) = empty_fcall_info_cache;
}
- ZVAL_COPY(&SG(callback_func), callback_func);
+ ZVAL_COPY(&SG(callback_func), &fci.function_name);
RETURN_TRUE;
}
@@ -612,7 +606,7 @@ static void sapi_remove_header(zend_llist *l, char *name, size_t len) {
}
}
-SAPI_API int sapi_add_header_ex(char *header_line, size_t header_line_len, zend_bool duplicate, zend_bool replace)
+SAPI_API int sapi_add_header_ex(const char *header_line, size_t header_line_len, zend_bool duplicate, zend_bool replace)
{
sapi_header_line ctr = {0};
int r;
@@ -624,7 +618,7 @@ SAPI_API int sapi_add_header_ex(char *header_line, size_t header_line_len, zend_
&ctr);
if (!duplicate)
- efree(header_line);
+ efree((void *) header_line);
return r;
}
@@ -684,7 +678,7 @@ SAPI_API int sapi_header_op(sapi_header_op_enum op, void *arg)
if (!p->line || !p->line_len) {
return FAILURE;
}
- header_line = p->line;
+ header_line = estrndup(p->line, p->line_len);
header_line_len = p->line_len;
http_response_code = p->response_code;
break;
@@ -701,8 +695,6 @@ SAPI_API int sapi_header_op(sapi_header_op_enum op, void *arg)
return FAILURE;
}
- header_line = estrndup(header_line, header_line_len);
-
/* cut off trailing spaces, linefeeds and carriage-returns */
if (header_line_len && isspace(header_line[header_line_len-1])) {
do {
@@ -984,7 +976,7 @@ SAPI_API int sapi_register_treat_data(void (*treat_data)(int arg, char *str, zva
return SUCCESS;
}
-SAPI_API int sapi_register_input_filter(unsigned int (*input_filter)(int arg, char *var, char **val, size_t val_len, size_t *new_val_len), unsigned int (*input_filter_init)(void))
+SAPI_API int sapi_register_input_filter(unsigned int (*input_filter)(int arg, const char *var, char **val, size_t val_len, size_t *new_val_len), unsigned int (*input_filter_init)(void))
{
if (SG(sapi_started) && EG(current_execute_data)) {
return FAILURE;
@@ -1016,7 +1008,7 @@ SAPI_API zend_stat_t *sapi_get_stat(void)
}
}
-SAPI_API char *sapi_getenv(char *name, size_t name_len)
+SAPI_API char *sapi_getenv(const char *name, size_t name_len)
{
if (!strncasecmp(name, "HTTP_PROXY", name_len)) {
/* Ugly fix for HTTP_PROXY issue, see bug #72573 */
@@ -1103,10 +1095,10 @@ SAPI_API void sapi_terminate_process(void) {
}
}
-SAPI_API void sapi_add_request_header(char *var, unsigned int var_len, char *val, unsigned int val_len, void *arg) /* {{{ */
+SAPI_API void sapi_add_request_header(const char *var, unsigned int var_len, char *val, unsigned int val_len, void *arg) /* {{{ */
{
zval *return_value = (zval*)arg;
- char *str = NULL;
+ char *buf = NULL;
ALLOCA_FLAG(use_heap)
@@ -1117,11 +1109,12 @@ SAPI_API void sapi_add_request_header(char *var, unsigned int var_len, char *val
var[3] == 'P' &&
var[4] == '_') {
- char *p;
+ const char *p;
+ char *str;
var_len -= 5;
p = var + 5;
- var = str = do_alloca(var_len + 1, use_heap);
+ var = str = buf = do_alloca(var_len + 1, use_heap);
*str++ = *p++;
while (*p) {
if (*p == '_') {
@@ -1147,8 +1140,8 @@ SAPI_API void sapi_add_request_header(char *var, unsigned int var_len, char *val
return;
}
add_assoc_stringl_ex(return_value, var, var_len, val, val_len);
- if (str) {
- free_alloca(var, use_heap);
+ if (buf) {
+ free_alloca(buf, use_heap);
}
}
/* }}} */
diff --git a/main/SAPI.h b/main/SAPI.h
index fe8bfd6244..b0d2928369 100644
--- a/main/SAPI.h
+++ b/main/SAPI.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -24,9 +22,6 @@
#include "zend_API.h"
#include "zend_llist.h"
#include "zend_operators.h"
-#ifdef PHP_WIN32
-#include "win32/php_stdint.h"
-#endif
#include <sys/stat.h>
#define SAPI_OPTION_NO_CHDIR 1
@@ -150,7 +145,7 @@ SAPI_API void sapi_shutdown(void);
SAPI_API void sapi_activate(void);
SAPI_API void sapi_deactivate(void);
SAPI_API void sapi_initialize_empty_request(void);
-SAPI_API void sapi_add_request_header(char *var, unsigned int var_len, char *val, unsigned int val_len, void *arg);
+SAPI_API void sapi_add_request_header(const char *var, unsigned int var_len, char *val, unsigned int val_len, void *arg);
END_EXTERN_C()
/*
@@ -165,7 +160,7 @@ END_EXTERN_C()
*/
typedef struct {
- char *line; /* If you allocated this, you need to free it yourself */
+ const char *line; /* If you allocated this, you need to free it yourself */
size_t line_len;
zend_long response_code; /* long due to zend_parse_parameters compatibility */
} sapi_header_line;
@@ -182,7 +177,7 @@ BEGIN_EXTERN_C()
SAPI_API int sapi_header_op(sapi_header_op_enum op, void *arg);
/* Deprecated functions. Use sapi_header_op instead. */
-SAPI_API int sapi_add_header_ex(char *header_line, size_t header_line_len, zend_bool duplicate, zend_bool replace);
+SAPI_API int sapi_add_header_ex(const char *header_line, size_t header_line_len, zend_bool duplicate, zend_bool replace);
#define sapi_add_header(a, b, c) sapi_add_header_ex((a),(b),(c),1)
@@ -195,11 +190,11 @@ SAPI_API int sapi_register_post_entry(const sapi_post_entry *post_entry);
SAPI_API void sapi_unregister_post_entry(const sapi_post_entry *post_entry);
SAPI_API int sapi_register_default_post_reader(void (*default_post_reader)(void));
SAPI_API int sapi_register_treat_data(void (*treat_data)(int arg, char *str, zval *destArray));
-SAPI_API int sapi_register_input_filter(unsigned int (*input_filter)(int arg, char *var, char **val, size_t val_len, size_t *new_val_len), unsigned int (*input_filter_init)(void));
+SAPI_API int sapi_register_input_filter(unsigned int (*input_filter)(int arg, const char *var, char **val, size_t val_len, size_t *new_val_len), unsigned int (*input_filter_init)(void));
SAPI_API int sapi_flush(void);
SAPI_API zend_stat_t *sapi_get_stat(void);
-SAPI_API char *sapi_getenv(char *name, size_t name_len);
+SAPI_API char *sapi_getenv(const char *name, size_t name_len);
SAPI_API char *sapi_get_default_content_type(void);
SAPI_API void sapi_get_default_content_type_header(sapi_header_struct *default_header);
@@ -228,7 +223,7 @@ struct _sapi_module_struct {
size_t (*ub_write)(const char *str, size_t str_length);
void (*flush)(void *server_context);
zend_stat_t *(*get_stat)(void);
- char *(*getenv)(char *name, size_t name_len);
+ char *(*getenv)(const char *name, size_t name_len);
void (*sapi_error)(int type, const char *error_msg, ...) ZEND_ATTRIBUTE_FORMAT(printf, 2, 3);
@@ -240,7 +235,7 @@ struct _sapi_module_struct {
char *(*read_cookies)(void);
void (*register_server_variables)(zval *track_vars_array);
- void (*log_message)(char *message, int syslog_type_int);
+ void (*log_message)(const char *message, int syslog_type_int);
double (*get_request_time)(void);
void (*terminate_process)(void);
@@ -260,7 +255,7 @@ struct _sapi_module_struct {
int (*get_target_uid)(uid_t *);
int (*get_target_gid)(gid_t *);
- unsigned int (*input_filter)(int arg, char *var, char **val, size_t val_len, size_t *new_val_len);
+ unsigned int (*input_filter)(int arg, const char *var, char **val, size_t val_len, size_t *new_val_len);
void (*ini_defaults)(HashTable *configuration_hash);
int phpinfo_as_text;
@@ -293,7 +288,7 @@ struct _sapi_post_entry {
#define SAPI_POST_HANDLER_FUNC(post_handler) void post_handler(char *content_type_dup, void *arg)
#define SAPI_TREAT_DATA_FUNC(treat_data) void treat_data(int arg, char *str, zval* destArray)
-#define SAPI_INPUT_FILTER_FUNC(input_filter) unsigned int input_filter(int arg, char *var, char **val, size_t val_len, size_t *new_val_len)
+#define SAPI_INPUT_FILTER_FUNC(input_filter) unsigned int input_filter(int arg, const char *var, char **val, size_t val_len, size_t *new_val_len)
BEGIN_EXTERN_C()
SAPI_API SAPI_POST_READER_FUNC(sapi_read_standard_form_data);
diff --git a/main/build-defs.h.in b/main/build-defs.h.in
index f007526846..374996c64a 100644
--- a/main/build-defs.h.in
+++ b/main/build-defs.h.in
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/main/explicit_bzero.c b/main/explicit_bzero.c
index 57d12080c6..5650932a3c 100644
--- a/main/explicit_bzero.c
+++ b/main/explicit_bzero.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -30,7 +28,7 @@
PHPAPI void php_explicit_bzero(void *dst, size_t siz)
{
-#if HAVE_EXPLICIT_MEMSET
+#ifdef HAVE_EXPLICIT_MEMSET
explicit_memset(dst, 0, siz);
#elif defined(PHP_WIN32)
RtlSecureZeroMemory(dst, siz);
diff --git a/main/fastcgi.c b/main/fastcgi.c
index f8044ffce3..dacb06bcfe 100644
--- a/main/fastcgi.c
+++ b/main/fastcgi.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/main/fastcgi.h b/main/fastcgi.h
index 95aae11e41..71c8517b11 100644
--- a/main/fastcgi.h
+++ b/main/fastcgi.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -77,7 +75,7 @@ typedef enum _fcgi_protocol_status {
/* FastCGI client API */
-typedef void (*fcgi_apply_func)(char *var, unsigned int var_len, char *val, unsigned int val_len, void *arg);
+typedef void (*fcgi_apply_func)(const char *var, unsigned int var_len, char *val, unsigned int val_len, void *arg);
#define FCGI_HASH_TABLE_SIZE 128
#define FCGI_HASH_TABLE_MASK (FCGI_HASH_TABLE_SIZE - 1)
diff --git a/main/fopen_wrappers.c b/main/fopen_wrappers.c
index 11d31366d7..88519bc726 100644
--- a/main/fopen_wrappers.c
+++ b/main/fopen_wrappers.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -17,8 +15,7 @@
+----------------------------------------------------------------------+
*/
-/* {{{ includes
- */
+/* {{{ includes */
#include "php.h"
#include "php_globals.h"
#include "SAPI.h"
@@ -75,14 +72,8 @@ Allows any change to open_basedir setting in during Startup and Shutdown events,
or a tightening during activation/runtime/deactivation */
PHPAPI ZEND_INI_MH(OnUpdateBaseDir)
{
- char **p, *pathbuf, *ptr, *end;
-#ifndef ZTS
- char *base = (char *) mh_arg2;
-#else
- char *base = (char *) ts_resource(*((int *) mh_arg2));
-#endif
-
- p = (char **) (base + (size_t) mh_arg1);
+ char **p = (char **) ZEND_INI_GET_ADDR();
+ char *pathbuf, *ptr, *end;
if (stage == PHP_INI_STAGE_STARTUP || stage == PHP_INI_STAGE_SHUTDOWN || stage == PHP_INI_STAGE_ACTIVATE || stage == PHP_INI_STAGE_DEACTIVATE) {
/* We're in a PHP_INI_SYSTEM context, no restrictions */
@@ -275,8 +266,7 @@ PHPAPI int php_check_open_basedir(const char *path)
return php_check_open_basedir_ex(path, 1);
}
-/* {{{ php_check_open_basedir
- */
+/* {{{ php_check_open_basedir */
PHPAPI int php_check_open_basedir_ex(const char *path, int warn)
{
/* Only check when open_basedir is available */
@@ -324,8 +314,7 @@ PHPAPI int php_check_open_basedir_ex(const char *path, int warn)
}
/* }}} */
-/* {{{ php_fopen_and_set_opened_path
- */
+/* {{{ php_fopen_and_set_opened_path */
static FILE *php_fopen_and_set_opened_path(const char *path, const char *mode, zend_string **opened_path)
{
FILE *fp;
@@ -346,8 +335,7 @@ static FILE *php_fopen_and_set_opened_path(const char *path, const char *mode, z
}
/* }}} */
-/* {{{ php_fopen_primary_script
- */
+/* {{{ php_fopen_primary_script */
PHPAPI int php_fopen_primary_script(zend_file_handle *file_handle)
{
char *path_info;
@@ -703,8 +691,7 @@ PHPAPI FILE *php_fopen_with_path(const char *filename, const char *mode, const c
}
/* }}} */
-/* {{{ php_strip_url_passwd
- */
+/* {{{ php_strip_url_passwd */
PHPAPI char *php_strip_url_passwd(char *url)
{
register char *p, *url_start;
@@ -743,24 +730,21 @@ PHPAPI char *php_strip_url_passwd(char *url)
}
/* }}} */
-/* {{{ expand_filepath
- */
+/* {{{ expand_filepath */
PHPAPI char *expand_filepath(const char *filepath, char *real_path)
{
return expand_filepath_ex(filepath, real_path, NULL, 0);
}
/* }}} */
-/* {{{ expand_filepath_ex
- */
+/* {{{ expand_filepath_ex */
PHPAPI char *expand_filepath_ex(const char *filepath, char *real_path, const char *relative_to, size_t relative_to_len)
{
return expand_filepath_with_mode(filepath, real_path, relative_to, relative_to_len, CWD_FILEPATH);
}
/* }}} */
-/* {{{ expand_filepath_use_realpath
- */
+/* {{{ expand_filepath_use_realpath */
PHPAPI char *expand_filepath_with_mode(const char *filepath, char *real_path, const char *relative_to, size_t relative_to_len, int realpath_mode)
{
cwd_state new_state;
diff --git a/main/fopen_wrappers.h b/main/fopen_wrappers.h
index 17e15b7df0..0f70bb4231 100644
--- a/main/fopen_wrappers.h
+++ b/main/fopen_wrappers.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/main/getopt.c b/main/getopt.c
index 9123cee0f2..2160a6f4fe 100644
--- a/main/getopt.c
+++ b/main/getopt.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/main/http_status_codes.h b/main/http_status_codes.h
index 5d5cfb08c3..cf66eabad7 100644
--- a/main/http_status_codes.h
+++ b/main/http_status_codes.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/main/internal_functions.c.in b/main/internal_functions.c.in
index 59557c9651..41458fb366 100644
--- a/main/internal_functions.c.in
+++ b/main/internal_functions.c.in
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/main/internal_functions_win32.c b/main/internal_functions_win32.c
index 4a3301e49b..bad5ad0279 100644
--- a/main/internal_functions_win32.c
+++ b/main/internal_functions_win32.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -17,8 +15,7 @@
+----------------------------------------------------------------------+
*/
-/* {{{ includes
- */
+/* {{{ includes */
#include "php.h"
#include "php_main.h"
#include "zend_modules.h"
@@ -98,8 +95,7 @@
#endif
/* }}} */
-/* {{{ php_builtin_extensions[]
- */
+/* {{{ php_builtin_extensions[] */
static zend_module_entry * const php_builtin_extensions[] = {
phpext_standard_ptr
#if HAVE_BCMATH
diff --git a/main/main.c b/main/main.c
index 1cb50ce1dd..da510f5551 100644
--- a/main/main.c
+++ b/main/main.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -18,8 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* {{{ includes
- */
+/* {{{ includes */
#define ZEND_INCLUDE_FULL_WINDOWS_HEADERS
@@ -74,6 +71,8 @@
#include "zend_extensions.h"
#include "zend_ini.h"
#include "zend_dtrace.h"
+#include "zend_observer.h"
+#include "zend_system_id.h"
#include "php_content_types.h"
#include "php_ticks.h"
@@ -97,33 +96,7 @@ PHPAPI size_t core_globals_offset;
#define SAFE_FILENAME(f) ((f)?(f):"-")
-static char *get_safe_charset_hint(void) {
- ZEND_TLS char *lastHint = NULL;
- ZEND_TLS char *lastCodeset = NULL;
- char *hint = SG(default_charset);
- size_t len = strlen(hint);
- size_t i = 0;
-
- if (lastHint == SG(default_charset)) {
- return lastCodeset;
- }
-
- lastHint = hint;
- lastCodeset = NULL;
-
- for (i = 0; i < sizeof(charset_map)/sizeof(charset_map[0]); i++) {
- if (len == charset_map[i].codeset_len
- && zend_binary_strcasecmp(hint, len, charset_map[i].codeset, len) == 0) {
- lastCodeset = (char*)charset_map[i].codeset;
- break;
- }
- }
-
- return lastCodeset;
-}
-
-/* {{{ PHP_INI_MH
- */
+/* {{{ PHP_INI_MH */
static PHP_INI_MH(OnSetFacility)
{
const char *facility = ZSTR_VAL(new_value);
@@ -259,8 +232,7 @@ static PHP_INI_MH(OnSetFacility)
}
/* }}} */
-/* {{{ PHP_INI_MH
- */
+/* {{{ PHP_INI_MH */
static PHP_INI_MH(OnSetPrecision)
{
zend_long i;
@@ -275,8 +247,7 @@ static PHP_INI_MH(OnSetPrecision)
}
/* }}} */
-/* {{{ PHP_INI_MH
- */
+/* {{{ PHP_INI_MH */
static PHP_INI_MH(OnSetSerializePrecision)
{
zend_long i;
@@ -291,9 +262,7 @@ static PHP_INI_MH(OnSetSerializePrecision)
}
/* }}} */
-
-/* {{{ PHP_INI_MH
- */
+/* {{{ PHP_INI_MH */
static PHP_INI_MH(OnChangeMemoryLimit)
{
if (new_value) {
@@ -301,12 +270,12 @@ static PHP_INI_MH(OnChangeMemoryLimit)
} else {
PG(memory_limit) = Z_L(1)<<30; /* effectively, no limit */
}
- return zend_set_memory_limit(PG(memory_limit));
+ zend_set_memory_limit(PG(memory_limit));
+ return SUCCESS;
}
/* }}} */
-/* {{{ PHP_INI_MH
- */
+/* {{{ PHP_INI_MH */
static PHP_INI_MH(OnSetLogFilter)
{
const char *filter = ZSTR_VAL(new_value);
@@ -332,46 +301,7 @@ static PHP_INI_MH(OnSetLogFilter)
}
/* }}} */
-/* {{{ php_disable_functions
- */
-static void php_disable_functions(void)
-{
- char *s = NULL, *e;
-
- if (!*(INI_STR("disable_functions"))) {
- return;
- }
-
- e = PG(disable_functions) = strdup(INI_STR("disable_functions"));
- if (e == NULL) {
- return;
- }
- while (*e) {
- switch (*e) {
- case ' ':
- case ',':
- if (s) {
- *e = '\0';
- zend_disable_function(s, e-s);
- s = NULL;
- }
- break;
- default:
- if (!s) {
- s = e;
- }
- break;
- }
- e++;
- }
- if (s) {
- zend_disable_function(s, e-s);
- }
-}
-/* }}} */
-
-/* {{{ php_disable_classes
- */
+/* {{{ php_disable_classes */
static void php_disable_classes(void)
{
char *s = NULL, *e;
@@ -406,8 +336,7 @@ static void php_disable_classes(void)
}
/* }}} */
-/* {{{ php_binary_init
- */
+/* {{{ php_binary_init */
static void php_binary_init(void)
{
char *binary_location = NULL;
@@ -456,8 +385,7 @@ static void php_binary_init(void)
}
/* }}} */
-/* {{{ PHP_INI_MH
- */
+/* {{{ PHP_INI_MH */
static PHP_INI_MH(OnUpdateTimeout)
{
if (stage==PHP_INI_STAGE_STARTUP) {
@@ -472,11 +400,10 @@ static PHP_INI_MH(OnUpdateTimeout)
}
/* }}} */
-/* {{{ php_get_display_errors_mode() helper function
- */
-static int php_get_display_errors_mode(char *value, size_t value_length)
+/* {{{ php_get_display_errors_mode() helper function */
+static zend_uchar php_get_display_errors_mode(char *value, size_t value_length)
{
- int mode;
+ zend_uchar mode;
if (!value) {
return PHP_DISPLAY_ERRORS_STDOUT;
@@ -503,21 +430,20 @@ static int php_get_display_errors_mode(char *value, size_t value_length)
}
/* }}} */
-/* {{{ PHP_INI_MH
- */
+/* {{{ PHP_INI_MH */
static PHP_INI_MH(OnUpdateDisplayErrors)
{
- PG(display_errors) = (zend_bool) php_get_display_errors_mode(ZSTR_VAL(new_value), ZSTR_LEN(new_value));
+ PG(display_errors) = php_get_display_errors_mode(ZSTR_VAL(new_value), ZSTR_LEN(new_value));
return SUCCESS;
}
/* }}} */
-/* {{{ PHP_INI_DISP
- */
+/* {{{ PHP_INI_DISP */
static PHP_INI_DISP(display_errors_mode)
{
- int mode, cgi_or_cli;
+ zend_uchar mode;
+ bool cgi_or_cli;
size_t tmp_value_length;
char *tmp_value;
@@ -561,37 +487,36 @@ static PHP_INI_DISP(display_errors_mode)
}
/* }}} */
-PHPAPI const char *php_get_internal_encoding() {
+PHPAPI const char *php_get_internal_encoding(void) {
if (PG(internal_encoding) && PG(internal_encoding)[0]) {
return PG(internal_encoding);
- } else if (SG(default_charset)) {
+ } else if (SG(default_charset) && SG(default_charset)[0]) {
return SG(default_charset);
}
- return "";
+ return "UTF-8";
}
-PHPAPI const char *php_get_input_encoding() {
+PHPAPI const char *php_get_input_encoding(void) {
if (PG(input_encoding) && PG(input_encoding)[0]) {
return PG(input_encoding);
- } else if (SG(default_charset)) {
+ } else if (SG(default_charset) && SG(default_charset)[0]) {
return SG(default_charset);
}
- return "";
+ return "UTF-8";
}
-PHPAPI const char *php_get_output_encoding() {
+PHPAPI const char *php_get_output_encoding(void) {
if (PG(output_encoding) && PG(output_encoding)[0]) {
return PG(output_encoding);
- } else if (SG(default_charset)) {
+ } else if (SG(default_charset) && SG(default_charset)[0]) {
return SG(default_charset);
}
- return "";
+ return "UTF-8";
}
PHPAPI void (*php_internal_encoding_changed)(void) = NULL;
-/* {{{ PHP_INI_MH
- */
+/* {{{ PHP_INI_MH */
static PHP_INI_MH(OnUpdateDefaultCharset)
{
OnUpdateString(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage);
@@ -607,8 +532,7 @@ static PHP_INI_MH(OnUpdateDefaultCharset)
}
/* }}} */
-/* {{{ PHP_INI_MH
- */
+/* {{{ PHP_INI_MH */
static PHP_INI_MH(OnUpdateInternalEncoding)
{
OnUpdateString(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage);
@@ -624,8 +548,7 @@ static PHP_INI_MH(OnUpdateInternalEncoding)
}
/* }}} */
-/* {{{ PHP_INI_MH
- */
+/* {{{ PHP_INI_MH */
static PHP_INI_MH(OnUpdateInputEncoding)
{
OnUpdateString(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage);
@@ -641,8 +564,7 @@ static PHP_INI_MH(OnUpdateInputEncoding)
}
/* }}} */
-/* {{{ PHP_INI_MH
- */
+/* {{{ PHP_INI_MH */
static PHP_INI_MH(OnUpdateOutputEncoding)
{
OnUpdateString(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage);
@@ -658,8 +580,7 @@ static PHP_INI_MH(OnUpdateOutputEncoding)
}
/* }}} */
-/* {{{ PHP_INI_MH
- */
+/* {{{ PHP_INI_MH */
static PHP_INI_MH(OnUpdateErrorLog)
{
/* Only do the safemode/open_basedir check at runtime */
@@ -673,8 +594,7 @@ static PHP_INI_MH(OnUpdateErrorLog)
}
/* }}} */
-/* {{{ PHP_INI_MH
- */
+/* {{{ PHP_INI_MH */
static PHP_INI_MH(OnUpdateMailLog)
{
/* Only do the safemode/open_basedir check at runtime */
@@ -688,8 +608,7 @@ static PHP_INI_MH(OnUpdateMailLog)
}
/* }}} */
-/* {{{ PHP_INI_MH
- */
+/* {{{ PHP_INI_MH */
static PHP_INI_MH(OnChangeMailForceExtra)
{
/* Don't allow changing it in htaccess */
@@ -719,8 +638,7 @@ PHP_INI_MH(OnChangeBrowscap);
# define DEFAULT_SENDMAIL_PATH PHP_PROG_SENDMAIL " -t -i"
#endif
-/* {{{ PHP_INI
- */
+/* {{{ PHP_INI */
PHP_INI_BEGIN()
PHP_INI_ENTRY_EX("highlight.comment", HL_COMMENT_COLOR, PHP_INI_ALL, NULL, php_ini_color_displayer_cb)
PHP_INI_ENTRY_EX("highlight.default", HL_DEFAULT_COLOR, PHP_INI_ALL, NULL, php_ini_color_displayer_cb)
@@ -729,7 +647,7 @@ PHP_INI_BEGIN()
PHP_INI_ENTRY_EX("highlight.string", HL_STRING_COLOR, PHP_INI_ALL, NULL, php_ini_color_displayer_cb)
STD_PHP_INI_ENTRY_EX("display_errors", "1", PHP_INI_ALL, OnUpdateDisplayErrors, display_errors, php_core_globals, core_globals, display_errors_mode)
- STD_PHP_INI_BOOLEAN("display_startup_errors", "0", PHP_INI_ALL, OnUpdateBool, display_startup_errors, php_core_globals, core_globals)
+ STD_PHP_INI_BOOLEAN("display_startup_errors", "1", PHP_INI_ALL, OnUpdateBool, display_startup_errors, php_core_globals, core_globals)
STD_PHP_INI_BOOLEAN("enable_dl", "1", PHP_INI_SYSTEM, OnUpdateBool, enable_dl, php_core_globals, core_globals)
STD_PHP_INI_BOOLEAN("expose_php", "1", PHP_INI_SYSTEM, OnUpdateBool, expose_php, php_core_globals, core_globals)
STD_PHP_INI_ENTRY("docref_root", "", PHP_INI_ALL, OnUpdateString, docref_root, php_core_globals, core_globals)
@@ -745,13 +663,12 @@ PHP_INI_BEGIN()
STD_PHP_INI_BOOLEAN("ignore_repeated_errors", "0", PHP_INI_ALL, OnUpdateBool, ignore_repeated_errors, php_core_globals, core_globals)
STD_PHP_INI_BOOLEAN("ignore_repeated_source", "0", PHP_INI_ALL, OnUpdateBool, ignore_repeated_source, php_core_globals, core_globals)
STD_PHP_INI_BOOLEAN("report_memleaks", "1", PHP_INI_ALL, OnUpdateBool, report_memleaks, php_core_globals, core_globals)
- STD_PHP_INI_BOOLEAN("report_zend_debug", "1", PHP_INI_ALL, OnUpdateBool, report_zend_debug, php_core_globals, core_globals)
+ STD_PHP_INI_BOOLEAN("report_zend_debug", "0", PHP_INI_ALL, OnUpdateBool, report_zend_debug, php_core_globals, core_globals)
STD_PHP_INI_ENTRY("output_buffering", "0", PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateLong, output_buffering, php_core_globals, core_globals)
STD_PHP_INI_ENTRY("output_handler", NULL, PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateString, output_handler, php_core_globals, core_globals)
STD_PHP_INI_BOOLEAN("register_argc_argv", "1", PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateBool, register_argc_argv, php_core_globals, core_globals)
STD_PHP_INI_BOOLEAN("auto_globals_jit", "1", PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateBool, auto_globals_jit, php_core_globals, core_globals)
STD_PHP_INI_BOOLEAN("short_open_tag", DEFAULT_SHORT_OPEN_TAG, PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateBool, short_tags, zend_compiler_globals, compiler_globals)
- STD_PHP_INI_BOOLEAN("track_errors", "0", PHP_INI_ALL, OnUpdateBool, track_errors, php_core_globals, core_globals)
STD_PHP_INI_ENTRY("unserialize_callback_func", NULL, PHP_INI_ALL, OnUpdateString, unserialize_callback_func, php_core_globals, core_globals)
STD_PHP_INI_ENTRY("serialize_precision", "-1", PHP_INI_ALL, OnSetSerializePrecision, serialize_precision, php_core_globals, core_globals)
@@ -840,17 +757,15 @@ static int php_during_module_shutdown(void)
}
/* }}} */
-/* {{{ php_get_module_initialized
- */
+/* {{{ php_get_module_initialized */
PHPAPI int php_get_module_initialized(void)
{
return module_initialized;
}
/* }}} */
-/* {{{ php_log_err_with_severity
- */
-PHPAPI ZEND_COLD void php_log_err_with_severity(char *log_message, int syslog_type_int)
+/* {{{ php_log_err_with_severity */
+PHPAPI ZEND_COLD void php_log_err_with_severity(const char *log_message, int syslog_type_int)
{
int fd = -1;
time_t error_time;
@@ -919,8 +834,7 @@ PHPAPI size_t php_write(void *buf, size_t size)
}
/* }}} */
-/* {{{ php_printf
- */
+/* {{{ php_printf */
PHPAPI size_t php_printf(const char *format, ...)
{
va_list args;
@@ -938,6 +852,37 @@ PHPAPI size_t php_printf(const char *format, ...)
}
/* }}} */
+/* {{{ php_printf_unchecked */
+PHPAPI size_t php_printf_unchecked(const char *format, ...)
+{
+ va_list args;
+ size_t ret;
+ char *buffer;
+ size_t size;
+
+ va_start(args, format);
+ size = vspprintf(&buffer, 0, format, args);
+ ret = PHPWRITE(buffer, size);
+ efree(buffer);
+ va_end(args);
+
+ return ret;
+}
+/* }}} */
+
+static zend_string *escape_html(const char *buffer, size_t buffer_len) {
+ zend_string *result = php_escape_html_entities_ex(
+ (const unsigned char *) buffer, buffer_len, 0, ENT_COMPAT,
+ /* charset_hint */ NULL, /* double_encode */ 1, /* quiet */ 1);
+ if (!result || ZSTR_LEN(result) == 0) {
+ /* Retry with substituting invalid chars on fail. */
+ result = php_escape_html_entities_ex(
+ (const unsigned char *) buffer, buffer_len, 0, ENT_COMPAT | ENT_HTML_SUBSTITUTE_ERRORS,
+ /* charset_hint */ NULL, /* double_encode */ 1, /* quiet */ 1);
+ }
+ return result;
+}
+
/* {{{ php_verror */
/* php_verror is called from php_error_docref<n> functions.
* Its purpose is to unify error messages and automatically generate clickable
@@ -956,19 +901,14 @@ PHPAPI ZEND_COLD void php_verror(const char *docref, const char *params, int typ
const char *function;
int origin_len;
char *origin;
- char *message;
+ zend_string *message;
int is_function = 0;
/* get error text into buffer and escape for html if necessary */
buffer_len = (int)vspprintf(&buffer, 0, format, args);
if (PG(html_errors)) {
- replace_buffer = php_escape_html_entities((unsigned char*)buffer, buffer_len, 0, ENT_COMPAT, get_safe_charset_hint());
- /* Retry with substituting invalid chars on fail. */
- if (!replace_buffer || ZSTR_LEN(replace_buffer) < 1) {
- replace_buffer = php_escape_html_entities((unsigned char*)buffer, buffer_len, 0, ENT_COMPAT | ENT_HTML_SUBSTITUTE_ERRORS, get_safe_charset_hint());
- }
-
+ replace_buffer = escape_html(buffer, buffer_len);
efree(buffer);
if (replace_buffer) {
@@ -1033,7 +973,7 @@ PHPAPI ZEND_COLD void php_verror(const char *docref, const char *params, int typ
}
if (PG(html_errors)) {
- replace_origin = php_escape_html_entities((unsigned char*)origin, origin_len, 0, ENT_COMPAT, get_safe_charset_hint());
+ replace_origin = escape_html(origin, origin_len);
efree(origin);
origin = ZSTR_VAL(replace_origin);
}
@@ -1096,15 +1036,15 @@ PHPAPI ZEND_COLD void php_verror(const char *docref, const char *params, int typ
}
/* display html formatted or only show the additional links */
if (PG(html_errors)) {
- spprintf(&message, 0, "%s [<a href='%s%s%s'>%s</a>]: %s", origin, docref_root, docref, docref_target, docref, buffer);
+ message = zend_strpprintf(0, "%s [<a href='%s%s%s'>%s</a>]: %s", origin, docref_root, docref, docref_target, docref, buffer);
} else {
- spprintf(&message, 0, "%s [%s%s%s]: %s", origin, docref_root, docref, docref_target, buffer);
+ message = zend_strpprintf(0, "%s [%s%s%s]: %s", origin, docref_root, docref, docref_target, buffer);
}
if (target) {
efree(target);
}
} else {
- spprintf(&message, 0, "%s: %s", origin, buffer);
+ message = zend_strpprintf(0, "%s: %s", origin, buffer);
}
if (replace_origin) {
zend_string_free(replace_origin);
@@ -1115,26 +1055,14 @@ PHPAPI ZEND_COLD void php_verror(const char *docref, const char *params, int typ
efree(docref_buf);
}
- if (PG(track_errors) && module_initialized && EG(active) &&
- (Z_TYPE(EG(user_error_handler)) == IS_UNDEF || !(EG(user_error_handler_error_reporting) & type))) {
- zval tmp;
- ZVAL_STRINGL(&tmp, buffer, buffer_len);
- if (EG(current_execute_data)) {
- if (zend_set_local_var_str("php_errormsg", sizeof("php_errormsg")-1, &tmp, 0) == FAILURE) {
- zval_ptr_dtor(&tmp);
- }
- } else {
- zend_hash_str_update_ind(&EG(symbol_table), "php_errormsg", sizeof("php_errormsg")-1, &tmp);
- }
- }
if (replace_buffer) {
zend_string_free(replace_buffer);
} else {
efree(buffer);
}
- php_error(type, "%s", message);
- efree(message);
+ zend_error_zstr(type, message);
+ zend_string_release(message);
}
/* }}} */
@@ -1201,20 +1129,54 @@ PHPAPI void php_html_puts(const char *str, size_t size)
}
/* }}} */
+static void clear_last_error() {
+ if (PG(last_error_message)) {
+ zend_string_release(PG(last_error_message));
+ PG(last_error_message) = NULL;
+ }
+ if (PG(last_error_file)) {
+ free(PG(last_error_file));
+ PG(last_error_file) = NULL;
+ }
+}
+
+#if ZEND_DEBUG
+/* {{{ report_zend_debug_error_notify_cb */
+static void report_zend_debug_error_notify_cb(int type, const char *error_filename, uint32_t error_lineno, zend_string *message)
+{
+ if (PG(report_zend_debug)) {
+ zend_bool trigger_break;
+
+ switch (type) {
+ case E_ERROR:
+ case E_CORE_ERROR:
+ case E_COMPILE_ERROR:
+ case E_USER_ERROR:
+ trigger_break=1;
+ break;
+ default:
+ trigger_break=0;
+ break;
+ }
+
+ zend_output_debug_string(trigger_break, "%s(%" PRIu32 ") : %s", error_filename, error_lineno, ZSTR_VAL(message));
+ }
+}
+/* }}} */
+#endif
+
/* {{{ php_error_cb
extended error handling function */
-static ZEND_COLD void php_error_cb(int type, const char *error_filename, const uint32_t error_lineno, const char *format, va_list args)
+static ZEND_COLD void php_error_cb(int orig_type, const char *error_filename, const uint32_t error_lineno, zend_string *message)
{
- char *buffer;
- int buffer_len, display;
-
- buffer_len = (int)vspprintf(&buffer, PG(log_errors_max_len), format, args);
+ zend_bool display;
+ int type = orig_type & E_ALL;
/* check for repeated errors to be ignored */
if (PG(ignore_repeated_errors) && PG(last_error_message)) {
/* no check for PG(last_error_file) is needed since it cannot
* be NULL if PG(last_error_message) is not NULL */
- if (strcmp(PG(last_error_message), buffer)
+ if (zend_string_equals(PG(last_error_message), message)
|| (!PG(ignore_repeated_source)
&& ((PG(last_error_lineno) != (int)error_lineno)
|| strcmp(PG(last_error_file), error_filename)))) {
@@ -1229,57 +1191,39 @@ static ZEND_COLD void php_error_cb(int type, const char *error_filename, const u
/* according to error handling mode, throw exception or show it */
if (EG(error_handling) == EH_THROW) {
switch (type) {
- case E_ERROR:
- case E_CORE_ERROR:
- case E_COMPILE_ERROR:
- case E_USER_ERROR:
- case E_PARSE:
- /* fatal errors are real errors and cannot be made exceptions */
- break;
- case E_STRICT:
- case E_DEPRECATED:
- case E_USER_DEPRECATED:
- /* for the sake of BC to old damaged code */
- break;
- case E_NOTICE:
- case E_USER_NOTICE:
- /* notices are no errors and are not treated as such like E_WARNINGS */
- break;
- default:
- /* throw an exception if we are in EH_THROW mode
- * but DO NOT overwrite a pending exception
+ case E_WARNING:
+ case E_CORE_WARNING:
+ case E_COMPILE_WARNING:
+ case E_USER_WARNING:
+ /* throw an exception if we are in EH_THROW mode and the type is warning.
+ * fatal errors are real errors and cannot be made exceptions.
+ * exclude deprecated for the sake of BC to old damaged code.
+ * notices are no errors and are not treated as such like E_WARNINGS.
+ * DO NOT overwrite a pending exception.
*/
if (!EG(exception)) {
- zend_throw_error_exception(EG(exception_class), buffer, 0, type);
+ zend_throw_error_exception(EG(exception_class), message, 0, type);
}
- efree(buffer);
return;
+ default:
+ break;
}
}
/* store the error if it has changed */
if (display) {
- if (PG(last_error_message)) {
- char *s = PG(last_error_message);
- PG(last_error_message) = NULL;
- free(s);
- }
- if (PG(last_error_file)) {
- char *s = PG(last_error_file);
- PG(last_error_file) = NULL;
- free(s);
- }
+ clear_last_error();
if (!error_filename) {
error_filename = "Unknown";
}
PG(last_error_type) = type;
- PG(last_error_message) = strdup(buffer);
+ PG(last_error_message) = zend_string_copy(message);
PG(last_error_file) = strdup(error_filename);
PG(last_error_lineno) = error_lineno;
}
/* display/log the error if necessary */
- if (display && (EG(error_reporting) & type || (type & E_CORE))
+ if (display && ((EG(error_reporting) & type) || (type & E_CORE))
&& (PG(log_errors) || PG(display_errors) || (!module_initialized))) {
char *error_type_str;
int syslog_type_int = LOG_NOTICE;
@@ -1326,66 +1270,49 @@ static ZEND_COLD void php_error_cb(int type, const char *error_filename, const u
break;
}
- if (!module_initialized || PG(log_errors)) {
+ if (PG(log_errors)
+ || (!module_initialized && (!PG(display_startup_errors) || !PG(display_errors)))) {
char *log_buffer;
#ifdef PHP_WIN32
if (type == E_CORE_ERROR || type == E_CORE_WARNING) {
- syslog(LOG_ALERT, "PHP %s: %s (%s)", error_type_str, buffer, GetCommandLine());
+ syslog(LOG_ALERT, "PHP %s: %s (%s)", error_type_str, ZSTR_VAL(message), GetCommandLine());
}
#endif
- spprintf(&log_buffer, 0, "PHP %s: %s in %s on line %" PRIu32, error_type_str, buffer, error_filename, error_lineno);
+ spprintf(&log_buffer, 0, "PHP %s: %s in %s on line %" PRIu32, error_type_str, ZSTR_VAL(message), error_filename, error_lineno);
php_log_err_with_severity(log_buffer, syslog_type_int);
efree(log_buffer);
}
if (PG(display_errors) && ((module_initialized && !PG(during_request_startup)) || (PG(display_startup_errors)))) {
if (PG(xmlrpc_errors)) {
- php_printf("<?xml version=\"1.0\"?><methodResponse><fault><value><struct><member><name>faultCode</name><value><int>" ZEND_LONG_FMT "</int></value></member><member><name>faultString</name><value><string>%s:%s in %s on line %" PRIu32 "</string></value></member></struct></value></fault></methodResponse>", PG(xmlrpc_error_number), error_type_str, buffer, error_filename, error_lineno);
+ php_printf("<?xml version=\"1.0\"?><methodResponse><fault><value><struct><member><name>faultCode</name><value><int>" ZEND_LONG_FMT "</int></value></member><member><name>faultString</name><value><string>%s:%s in %s on line %" PRIu32 "</string></value></member></struct></value></fault></methodResponse>", PG(xmlrpc_error_number), error_type_str, ZSTR_VAL(message), error_filename, error_lineno);
} else {
char *prepend_string = INI_STR("error_prepend_string");
char *append_string = INI_STR("error_append_string");
if (PG(html_errors)) {
if (type == E_ERROR || type == E_PARSE) {
- zend_string *buf = php_escape_html_entities((unsigned char*)buffer, buffer_len, 0, ENT_COMPAT, get_safe_charset_hint());
+ zend_string *buf = escape_html(ZSTR_VAL(message), ZSTR_LEN(message));
php_printf("%s<br />\n<b>%s</b>: %s in <b>%s</b> on line <b>%" PRIu32 "</b><br />\n%s", STR_PRINT(prepend_string), error_type_str, ZSTR_VAL(buf), error_filename, error_lineno, STR_PRINT(append_string));
zend_string_free(buf);
} else {
- php_printf("%s<br />\n<b>%s</b>: %s in <b>%s</b> on line <b>%" PRIu32 "</b><br />\n%s", STR_PRINT(prepend_string), error_type_str, buffer, error_filename, error_lineno, STR_PRINT(append_string));
+ php_printf("%s<br />\n<b>%s</b>: %s in <b>%s</b> on line <b>%" PRIu32 "</b><br />\n%s", STR_PRINT(prepend_string), error_type_str, ZSTR_VAL(message), error_filename, error_lineno, STR_PRINT(append_string));
}
} else {
/* Write CLI/CGI errors to stderr if display_errors = "stderr" */
if ((!strcmp(sapi_module.name, "cli") || !strcmp(sapi_module.name, "cgi") || !strcmp(sapi_module.name, "phpdbg")) &&
PG(display_errors) == PHP_DISPLAY_ERRORS_STDERR
) {
- fprintf(stderr, "%s: %s in %s on line %" PRIu32 "\n", error_type_str, buffer, error_filename, error_lineno);
+ fprintf(stderr, "%s: %s in %s on line %" PRIu32 "\n", error_type_str, ZSTR_VAL(message), error_filename, error_lineno);
#ifdef PHP_WIN32
fflush(stderr);
#endif
} else {
- php_printf("%s\n%s: %s in %s on line %" PRIu32 "\n%s", STR_PRINT(prepend_string), error_type_str, buffer, error_filename, error_lineno, STR_PRINT(append_string));
+ php_printf("%s\n%s: %s in %s on line %" PRIu32 "\n%s", STR_PRINT(prepend_string), error_type_str, ZSTR_VAL(message), error_filename, error_lineno, STR_PRINT(append_string));
}
}
}
}
-#if ZEND_DEBUG
- if (PG(report_zend_debug)) {
- zend_bool trigger_break;
-
- switch (type) {
- case E_ERROR:
- case E_CORE_ERROR:
- case E_COMPILE_ERROR:
- case E_USER_ERROR:
- trigger_break=1;
- break;
- default:
- trigger_break=0;
- break;
- }
- zend_output_debug_string(trigger_break, "%s(%" PRIu32 ") : %s - %s", error_filename, error_lineno, error_type_str, buffer);
- }
-#endif
}
/* Bail out if we can't recover */
@@ -1414,10 +1341,9 @@ static ZEND_COLD void php_error_cb(int type, const char *error_filename, const u
sapi_header_op(SAPI_HEADER_REPLACE, &ctr);
}
/* the parser would return 1 (failure), we can bail out nicely */
- if (type != E_PARSE) {
+ if (!(orig_type & E_DONT_BAIL)) {
/* restore memory limit */
zend_set_memory_limit(PG(memory_limit));
- efree(buffer);
zend_objects_store_mark_destructed(&EG(objects_store));
zend_bailout();
return;
@@ -1425,32 +1351,10 @@ static ZEND_COLD void php_error_cb(int type, const char *error_filename, const u
}
break;
}
-
- /* Log if necessary */
- if (!display) {
- efree(buffer);
- return;
- }
-
- if (PG(track_errors) && module_initialized && EG(active)) {
- zval tmp;
-
- ZVAL_STRINGL(&tmp, buffer, buffer_len);
- if (EG(current_execute_data)) {
- if (zend_set_local_var_str("php_errormsg", sizeof("php_errormsg")-1, &tmp, 0) == FAILURE) {
- zval_ptr_dtor(&tmp);
- }
- } else {
- zend_hash_str_update_ind(&EG(symbol_table), "php_errormsg", sizeof("php_errormsg")-1, &tmp);
- }
- }
-
- efree(buffer);
}
/* }}} */
-/* {{{ php_get_current_user
- */
+/* {{{ php_get_current_user */
PHPAPI char *php_get_current_user(void)
{
zend_stat_t *pstat;
@@ -1518,8 +1422,7 @@ PHPAPI char *php_get_current_user(void)
}
/* }}} */
-/* {{{ proto bool set_time_limit(int seconds)
- Sets the maximum time a script can run */
+/* {{{ Sets the maximum time a script can run */
PHP_FUNCTION(set_time_limit)
{
zend_long new_timeout;
@@ -1528,7 +1431,7 @@ PHP_FUNCTION(set_time_limit)
zend_string *key;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &new_timeout) == FAILURE) {
- return;
+ RETURN_THROWS();
}
new_timeout_strlen = (int)zend_spprintf(&new_timeout_str, 0, ZEND_LONG_FMT, new_timeout);
@@ -1544,8 +1447,7 @@ PHP_FUNCTION(set_time_limit)
}
/* }}} */
-/* {{{ php_fopen_wrapper_for_zend
- */
+/* {{{ php_fopen_wrapper_for_zend */
static FILE *php_fopen_wrapper_for_zend(const char *filename, zend_string **opened_path)
{
return php_stream_open_wrapper_as_file((char *)filename, "rb", USE_PATH|IGNORE_URL_WIN|REPORT_ERRORS|STREAM_OPEN_FOR_INCLUDE, opened_path);
@@ -1576,13 +1478,13 @@ static size_t php_zend_stream_fsizer(void *handle) /* {{{ */
}
/* }}} */
-static int php_stream_open_for_zend(const char *filename, zend_file_handle *handle) /* {{{ */
+static zend_result php_stream_open_for_zend(const char *filename, zend_file_handle *handle) /* {{{ */
{
return php_stream_open_for_zend_ex(filename, handle, USE_PATH|REPORT_ERRORS|STREAM_OPEN_FOR_INCLUDE);
}
/* }}} */
-PHPAPI int php_stream_open_for_zend_ex(const char *filename, zend_file_handle *handle, int mode) /* {{{ */
+PHPAPI zend_result php_stream_open_for_zend_ex(const char *filename, zend_file_handle *handle, int mode) /* {{{ */
{
zend_string *opened_path;
php_stream *stream = php_stream_open_wrapper((char *)filename, "rb", mode, &opened_path);
@@ -1613,26 +1515,17 @@ static zend_string *php_resolve_path_for_zend(const char *filename, size_t filen
}
/* }}} */
-/* {{{ php_get_configuration_directive_for_zend
- */
+/* {{{ php_get_configuration_directive_for_zend */
static zval *php_get_configuration_directive_for_zend(zend_string *name)
{
return cfg_get_entry_ex(name);
}
/* }}} */
-/* {{{ php_free_request_globals
- */
+/* {{{ php_free_request_globals */
static void php_free_request_globals(void)
{
- if (PG(last_error_message)) {
- free(PG(last_error_message));
- PG(last_error_message) = NULL;
- }
- if (PG(last_error_file)) {
- free(PG(last_error_file));
- PG(last_error_file) = NULL;
- }
+ clear_last_error();
if (PG(php_sys_temp_dir)) {
efree(PG(php_sys_temp_dir));
PG(php_sys_temp_dir) = NULL;
@@ -1640,8 +1533,7 @@ static void php_free_request_globals(void)
}
/* }}} */
-/* {{{ php_message_handler_for_zend
- */
+/* {{{ php_message_handler_for_zend */
static ZEND_COLD void php_message_handler_for_zend(zend_long message, const void *data)
{
switch (message) {
@@ -1649,7 +1541,7 @@ static ZEND_COLD void php_message_handler_for_zend(zend_long message, const void
php_error_docref("function.include", E_WARNING, "Failed opening '%s' for inclusion (include_path='%s')", php_strip_url_passwd((char *) data), STR_PRINT(PG(include_path)));
break;
case ZMSG_FAILED_REQUIRE_FOPEN:
- php_error_docref("function.require", E_COMPILE_ERROR, "Failed opening required '%s' (include_path='%s')", php_strip_url_passwd((char *) data), STR_PRINT(PG(include_path)));
+ zend_throw_error(NULL, "Failed opening required '%s' (include_path='%s')", php_strip_url_passwd((char *) data), STR_PRINT(PG(include_path)));
break;
case ZMSG_FAILED_HIGHLIGHT_FOPEN:
php_error_docref(NULL, E_WARNING, "Failed opening '%s' for highlighting", php_strip_url_passwd((char *) data));
@@ -1742,8 +1634,7 @@ void php_on_timeout(int seconds)
}
#if PHP_SIGCHILD
-/* {{{ sigchld_handler
- */
+/* {{{ sigchld_handler */
static void sigchld_handler(int apar)
{
int errno_save = errno;
@@ -1756,8 +1647,7 @@ static void sigchld_handler(int apar)
/* }}} */
#endif
-/* {{{ php_request_startup
- */
+/* {{{ php_request_startup */
int php_request_startup(void)
{
int retval = SUCCESS;
@@ -1841,8 +1731,7 @@ int php_request_startup(void)
}
/* }}} */
-/* {{{ php_request_shutdown
- */
+/* {{{ php_request_shutdown */
void php_request_shutdown(void *dummy)
{
zend_bool report_memleaks;
@@ -1859,9 +1748,9 @@ void php_request_shutdown(void *dummy)
php_deactivate_ticks();
/* 1. Call all possible shutdown functions registered with register_shutdown_function() */
- if (PG(modules_activated)) zend_try {
+ if (PG(modules_activated)) {
php_call_shutdown_functions();
- } zend_end_try();
+ }
/* 2. Call all possible __destruct() functions */
zend_try {
@@ -1914,12 +1803,12 @@ void php_request_shutdown(void *dummy)
}
} zend_end_try();
- /* 9. free request-bound globals */
- php_free_request_globals();
-
- /* 10. Shutdown scanner/executor/compiler and restore ini entries */
+ /* 9. Shutdown scanner/executor/compiler and restore ini entries */
zend_deactivate();
+ /* 10. free request-bound globals */
+ php_free_request_globals();
+
/* 11. Call all extensions post-RSHUTDOWN functions */
zend_try {
zend_post_deactivate_modules();
@@ -1962,8 +1851,7 @@ void php_request_shutdown(void *dummy)
}
/* }}} */
-/* {{{ php_com_initialize
- */
+/* {{{ php_com_initialize */
PHPAPI void php_com_initialize(void)
{
#ifdef PHP_WIN32
@@ -1977,8 +1865,7 @@ PHPAPI void php_com_initialize(void)
/* }}} */
#ifdef ZTS
-/* {{{ core_globals_ctor
- */
+/* {{{ core_globals_ctor */
static void core_globals_ctor(php_core_globals *core_globals)
{
memset(core_globals, 0, sizeof(*core_globals));
@@ -1987,19 +1874,13 @@ static void core_globals_ctor(php_core_globals *core_globals)
/* }}} */
#endif
-/* {{{ core_globals_dtor
- */
+/* {{{ core_globals_dtor */
static void core_globals_dtor(php_core_globals *core_globals)
{
- if (core_globals->last_error_message) {
- free(core_globals->last_error_message);
- }
- if (core_globals->last_error_file) {
- free(core_globals->last_error_file);
- }
- if (core_globals->disable_functions) {
- free(core_globals->disable_functions);
- }
+ /* These should have been freed earlier. */
+ ZEND_ASSERT(!core_globals->last_error_message);
+ ZEND_ASSERT(!core_globals->last_error_file);
+
if (core_globals->disable_classes) {
free(core_globals->disable_classes);
}
@@ -2019,8 +1900,7 @@ PHP_MINFO_FUNCTION(php_core) { /* {{{ */
}
/* }}} */
-/* {{{ php_register_extensions
- */
+/* {{{ php_register_extensions */
int php_register_extensions(zend_module_entry * const * ptr, int count)
{
zend_module_entry * const * end = ptr + count;
@@ -2087,8 +1967,7 @@ void dummy_invalid_parameter_handler(
}
#endif
-/* {{{ php_module_startup
- */
+/* {{{ php_module_startup */
int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_modules, uint32_t num_additional_modules)
{
zend_utility_functions zuf;
@@ -2164,29 +2043,24 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
zuf.getenv_function = sapi_getenv;
zuf.resolve_path_function = php_resolve_path_for_zend;
zend_startup(&zuf);
- setlocale(LC_CTYPE, "");
zend_update_current_locale();
+ zend_observer_startup();
+#if ZEND_DEBUG
+ zend_observer_error_register(report_zend_debug_error_notify_cb);
+#endif
+
#if HAVE_TZSET
tzset();
#endif
#ifdef PHP_WIN32
-# if PHP_LINKER_MAJOR == 14
- /* Extend for other CRT if needed. */
-# if PHP_DEBUG
-# define PHP_VCRUNTIME "vcruntime140d.dll"
-# else
-# define PHP_VCRUNTIME "vcruntime140.dll"
-# endif
char *img_err;
- if (!php_win32_crt_compatible(PHP_VCRUNTIME, &img_err)) {
+ if (!php_win32_crt_compatible(&img_err)) {
php_error(E_CORE_WARNING, img_err);
efree(img_err);
return FAILURE;
}
-# undef PHP_VCRUNTIME
-# endif
/* start up winsock services */
if (WSAStartup(wVersionRequested, &wsaData) != 0) {
@@ -2312,6 +2186,9 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
zend_set_utility_values(&zuv);
php_startup_sapi_content_types();
+ /* Begin to fingerprint the process state */
+ zend_startup_system_id();
+
/* startup extensions statically compiled in */
if (php_register_internal_extensions_func() == FAILURE) {
php_printf("Unable to start builtin modules\n");
@@ -2346,7 +2223,7 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
}
/* disable certain classes and functions as requested by php.ini */
- php_disable_functions();
+ zend_disable_functions(INI_STR("disable_functions"));
php_disable_classes();
/* make core report what it should */
@@ -2355,6 +2232,9 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
module->info_func = PHP_MINFO(php_core);
}
+ /* Extensions that add engine hooks after this point do so at their own peril */
+ zend_finalize_system_id();
+
module_initialized = 1;
if (zend_post_startup() != SUCCESS) {
@@ -2367,13 +2247,12 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
struct {
const long error_level;
const char *phrase;
- const char *directives[17]; /* Remember to change this if the number of directives change */
+ const char *directives[18]; /* Remember to change this if the number of directives change */
} directives[2] = {
{
E_DEPRECATED,
"Directive '%s' is deprecated",
{
- "track_errors",
"allow_url_include",
NULL
}
@@ -2398,6 +2277,7 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
"safe_mode_allowed_env_vars",
"safe_mode_protected_env_vars",
"zend.ze1_compatibility_mode",
+ "track_errors",
NULL
}
}
@@ -2430,6 +2310,8 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
sapi_deactivate();
module_startup = 0;
+ /* Don't leak errors from startup into the per-request phase. */
+ clear_last_error();
shutdown_memory_manager(1, 0);
virtual_cwd_activate();
@@ -2444,8 +2326,7 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
}
/* }}} */
-/* {{{ php_module_shutdown_wrapper
- */
+/* {{{ php_module_shutdown_wrapper */
int php_module_shutdown_wrapper(sapi_module_struct *sapi_globals)
{
php_module_shutdown();
@@ -2453,8 +2334,7 @@ int php_module_shutdown_wrapper(sapi_module_struct *sapi_globals)
}
/* }}} */
-/* {{{ php_module_shutdown
- */
+/* {{{ php_module_shutdown */
void php_module_shutdown(void)
{
int module_number=0; /* for UNREGISTER_INI_ENTRIES() */
@@ -2492,6 +2372,7 @@ void php_module_shutdown(void)
/* close down the ini config */
php_shutdown_config();
+ clear_last_error();
#ifndef ZTS
zend_ini_shutdown();
@@ -2527,16 +2408,17 @@ void php_module_shutdown(void)
_set_invalid_parameter_handler(old_invalid_parameter_handler);
}
#endif
+
+ zend_observer_shutdown();
}
/* }}} */
-/* {{{ php_execute_script
- */
+/* {{{ php_execute_script */
PHPAPI int php_execute_script(zend_file_handle *primary_file)
{
zend_file_handle *prepend_file_p, *append_file_p;
zend_file_handle prepend_file, append_file;
-#if HAVE_BROKEN_GETCWD
+#ifdef HAVE_BROKEN_GETCWD
volatile int old_cwd_fd = -1;
#else
char *old_cwd;
@@ -2544,7 +2426,6 @@ PHPAPI int php_execute_script(zend_file_handle *primary_file)
#endif
int retval = 0;
- EG(exit_status) = 0;
#ifndef HAVE_BROKEN_GETCWD
# define OLD_CWD_SIZE 4096
old_cwd = do_alloca(OLD_CWD_SIZE, use_heap);
@@ -2563,7 +2444,7 @@ PHPAPI int php_execute_script(zend_file_handle *primary_file)
PG(during_request_startup) = 0;
if (primary_file->filename && !(SG(options) & SAPI_OPTION_NO_CHDIR)) {
-#if HAVE_BROKEN_GETCWD
+#ifdef HAVE_BROKEN_GETCWD
/* this looks nasty to me */
old_cwd_fd = open(".", 0);
#else
@@ -2606,20 +2487,7 @@ PHPAPI int php_execute_script(zend_file_handle *primary_file)
zend_set_timeout(INI_INT("max_execution_time"), 0);
}
- /*
- If cli primary file has shabang line and there is a prepend file,
- the `skip_shebang` will be used by prepend file but not primary file,
- save it and restore after prepend file been executed.
- */
- if (CG(skip_shebang) && prepend_file_p) {
- CG(skip_shebang) = 0;
- if (zend_execute_scripts(ZEND_REQUIRE, NULL, 1, prepend_file_p) == SUCCESS) {
- CG(skip_shebang) = 1;
- retval = (zend_execute_scripts(ZEND_REQUIRE, NULL, 2, primary_file, append_file_p) == SUCCESS);
- }
- } else {
- retval = (zend_execute_scripts(ZEND_REQUIRE, NULL, 3, prepend_file_p, primary_file, append_file_p) == SUCCESS);
- }
+ retval = (zend_execute_scripts(ZEND_REQUIRE, NULL, 3, prepend_file_p, primary_file, append_file_p) == SUCCESS);
} zend_end_try();
if (EG(exception)) {
@@ -2628,7 +2496,7 @@ PHPAPI int php_execute_script(zend_file_handle *primary_file)
} zend_end_try();
}
-#if HAVE_BROKEN_GETCWD
+#ifdef HAVE_BROKEN_GETCWD
if (old_cwd_fd != -1) {
fchdir(old_cwd_fd);
close(old_cwd_fd);
@@ -2643,8 +2511,7 @@ PHPAPI int php_execute_script(zend_file_handle *primary_file)
}
/* }}} */
-/* {{{ php_execute_simple_script
- */
+/* {{{ php_execute_simple_script */
PHPAPI int php_execute_simple_script(zend_file_handle *primary_file, zval *ret)
{
char *old_cwd;
@@ -2680,8 +2547,7 @@ PHPAPI int php_execute_simple_script(zend_file_handle *primary_file, zval *ret)
}
/* }}} */
-/* {{{ php_handle_aborted_connection
- */
+/* {{{ php_handle_aborted_connection */
PHPAPI void php_handle_aborted_connection(void)
{
@@ -2694,8 +2560,7 @@ PHPAPI void php_handle_aborted_connection(void)
}
/* }}} */
-/* {{{ php_handle_auth_data
- */
+/* {{{ php_handle_auth_data */
PHPAPI int php_handle_auth_data(const char *auth)
{
int ret = -1;
@@ -2736,8 +2601,7 @@ PHPAPI int php_handle_auth_data(const char *auth)
}
/* }}} */
-/* {{{ php_lint_script
- */
+/* {{{ php_lint_script */
PHPAPI int php_lint_script(zend_file_handle *file)
{
zend_op_array *op_array;
@@ -2762,8 +2626,7 @@ PHPAPI int php_lint_script(zend_file_handle *file)
/* }}} */
#ifdef ZTS
-/* {{{ php_reserve_tsrm_memory
- */
+/* {{{ php_reserve_tsrm_memory */
PHPAPI void php_reserve_tsrm_memory(void)
{
tsrm_reserve(
@@ -2783,8 +2646,7 @@ PHPAPI void php_reserve_tsrm_memory(void)
}
/* }}} */
-/* {{{ php_tsrm_startup
- */
+/* {{{ php_tsrm_startup */
PHPAPI int php_tsrm_startup(void)
{
int ret = tsrm_startup(1, 1, 0, NULL);
diff --git a/main/mergesort.c b/main/mergesort.c
deleted file mode 100644
index da6d8560bf..0000000000
--- a/main/mergesort.c
+++ /dev/null
@@ -1,347 +0,0 @@
-/*-
- * Copyright (c) 1992, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Peter McIlroy.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)merge.c 8.2 (Berkeley) 2/14/94";
-#endif /* LIBC_SCCS and not lint */
-
-/*
- * Hybrid exponential search/linear search merge sort with hybrid
- * natural/pairwise first pass. Requires about .3% more comparisons
- * for random data than LSMS with pairwise first pass alone.
- * It works for objects as small as two bytes.
- */
-
-#define NATURAL
-#define THRESHOLD 16 /* Best choice for natural merge cut-off. */
-
-/* #define NATURAL to get hybrid natural merge.
- * (The default is pairwise merging.)
- */
-
-#include <sys/types.h>
-
-#include <errno.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "php.h"
-
-#ifdef PHP_WIN32
-#include <winsock2.h> /* Includes definition for u_char */
-#endif
-
-static void setup(u_char *list1, u_char *list2, size_t n, size_t size, int (*cmp)(const void *, const void *));
-static void insertionsort(u_char *a, size_t n, size_t size, int (*cmp)(const void *, const void *));
-
-#define ISIZE sizeof(int)
-#define PSIZE sizeof(u_char *)
-#define ICOPY_LIST(src, dst, last) \
- do \
- *(int*)dst = *(int*)src, src += ISIZE, dst += ISIZE; \
- while(src < last)
-#define ICOPY_ELT(src, dst, i) \
- do \
- *(int*) dst = *(int*) src, src += ISIZE, dst += ISIZE; \
- while (i -= ISIZE)
-
-#define CCOPY_LIST(src, dst, last) \
- do \
- *dst++ = *src++; \
- while (src < last)
-#define CCOPY_ELT(src, dst, i) \
- do \
- *dst++ = *src++; \
- while (i -= 1)
-
-/*
- * Find the next possible pointer head. (Trickery for forcing an array
- * to do double duty as a linked list when objects do not align with word
- * boundaries.
- */
-/* Assumption: PSIZE is a power of 2. */
-#define EVAL(p) (u_char **) \
- ((u_char *)0 + \
- (((u_char *)p + PSIZE - 1 - (u_char *) 0) & ~(PSIZE - 1)))
-
-/* {{{ php_mergesort
- * Arguments are as for qsort.
- */
-PHPAPI int php_mergesort(void *base, size_t nmemb, size_t size, int (*cmp)(const void *, const void *))
-{
- register size_t i;
- register int sense;
- int big, iflag;
- register u_char *f1, *f2, *t, *b, *tp2, *q, *l1, *l2;
- u_char *list2, *list1, *p2, *p, *last, **p1;
-
- if (size < PSIZE / 2) { /* Pointers must fit into 2 * size. */
- errno = EINVAL;
- return (-1);
- }
-
- if (nmemb == 0)
- return (0);
-
- /*
- * XXX
- * Stupid subtraction for the Cray.
- */
- iflag = 0;
- if (!(size % ISIZE) && !(((char *)base - (char *)0) % ISIZE))
- iflag = 1;
-
- if ((list2 = malloc(nmemb * size + PSIZE)) == NULL)
- return (-1);
-
- list1 = base;
- setup(list1, list2, nmemb, size, cmp);
- last = list2 + nmemb * size;
- i = big = 0;
- while (*EVAL(list2) != last) {
- l2 = list1;
- p1 = EVAL(list1);
- for (tp2 = p2 = list2; p2 != last; p1 = EVAL(l2)) {
- p2 = *EVAL(p2);
- f1 = l2;
- f2 = l1 = list1 + (p2 - list2);
- if (p2 != last)
- p2 = *EVAL(p2);
- l2 = list1 + (p2 - list2);
- while (f1 < l1 && f2 < l2) {
- if ((*cmp)(f1, f2) <= 0) {
- q = f2;
- b = f1, t = l1;
- sense = -1;
- } else {
- q = f1;
- b = f2, t = l2;
- sense = 0;
- }
- if (!big) { /* here i = 0 */
- while ((b += size) < t && cmp(q, b) >sense)
- if (++i == 6) {
- big = 1;
- goto EXPONENTIAL;
- }
- } else {
-EXPONENTIAL: for (i = size; ; i <<= 1)
- if ((p = (b + i)) >= t) {
- if ((p = t - size) > b &&
- (*cmp)(q, p) <= sense)
- t = p;
- else
- b = p;
- break;
- } else if ((*cmp)(q, p) <= sense) {
- t = p;
- if (i == size)
- big = 0;
- goto FASTCASE;
- } else
- b = p;
- while (t > b+size) {
- i = (((t - b) / size) >> 1) * size;
- if ((*cmp)(q, p = b + i) <= sense)
- t = p;
- else
- b = p;
- }
- goto COPY;
-FASTCASE: while (i > size)
- if ((*cmp)(q,
- p = b + (i >>= 1)) <= sense)
- t = p;
- else
- b = p;
-COPY: b = t;
- }
- i = size;
- if (q == f1) {
- if (iflag) {
- ICOPY_LIST(f2, tp2, b);
- ICOPY_ELT(f1, tp2, i);
- } else {
- CCOPY_LIST(f2, tp2, b);
- CCOPY_ELT(f1, tp2, i);
- }
- } else {
- if (iflag) {
- ICOPY_LIST(f1, tp2, b);
- ICOPY_ELT(f2, tp2, i);
- } else {
- CCOPY_LIST(f1, tp2, b);
- CCOPY_ELT(f2, tp2, i);
- }
- }
- }
- if (f2 < l2) {
- if (iflag)
- ICOPY_LIST(f2, tp2, l2);
- else
- CCOPY_LIST(f2, tp2, l2);
- } else if (f1 < l1) {
- if (iflag)
- ICOPY_LIST(f1, tp2, l1);
- else
- CCOPY_LIST(f1, tp2, l1);
- }
- *p1 = l2;
- }
- tp2 = list1; /* swap list1, list2 */
- list1 = list2;
- list2 = tp2;
- last = list2 + nmemb*size;
- }
- if (base == list2) {
- memmove(list2, list1, nmemb*size);
- list2 = list1;
- }
- free(list2);
- return (0);
-}
-/* }}} */
-
-#define swap(a, b) { \
- s = b; \
- i = size; \
- do { \
- tmp = *a; *a++ = *s; *s++ = tmp; \
- } while (--i); \
- a -= size; \
- }
-#define reverse(bot, top) { \
- s = top; \
- do { \
- i = size; \
- do { \
- tmp = *bot; *bot++ = *s; *s++ = tmp; \
- } while (--i); \
- s -= size2; \
- } while(bot < s); \
-}
-
-/* {{{ setup
- * Optional hybrid natural/pairwise first pass. Eats up list1 in runs of
- * increasing order, list2 in a corresponding linked list. Checks for runs
- * when THRESHOLD/2 pairs compare with same sense. (Only used when NATURAL
- * is defined. Otherwise simple pairwise merging is used.)
- */
-static void setup(u_char *list1, u_char *list2, size_t n, size_t size, int (*cmp)(const void *, const void *))
-{
- size_t i, length, size2, sense;
- u_char *f1, *f2, *s, *l2, *last, *p2, tmp;
-
- size2 = size*2;
- if (n <= 5) {
- insertionsort(list1, n, size, cmp);
- *EVAL(list2) = (u_char*) list2 + n*size;
- return;
- }
- /*
- * Avoid running pointers out of bounds; limit n to evens
- * for simplicity.
- */
- i = 4 + (n & 1);
- insertionsort(list1 + (n - i) * size, i, size, cmp);
- last = list1 + size * (n - i);
- *EVAL(list2 + (last - list1)) = list2 + n * size;
-
-#ifdef NATURAL
- p2 = list2;
- f1 = list1;
- sense = (cmp(f1, f1 + size) > 0);
- for (; f1 < last; sense = !sense) {
- length = 2;
- /* Find pairs with same sense. */
- for (f2 = f1 + size2; f2 < last; f2 += size2) {
- if ((cmp(f2, f2+ size) > 0) != sense)
- break;
- length += 2;
- }
- if (length < THRESHOLD) { /* Pairwise merge */
- do {
- p2 = *EVAL(p2) = f1 + size2 - list1 + list2;
- if (sense > 0)
- swap (f1, f1 + size);
- } while ((f1 += size2) < f2);
- } else { /* Natural merge */
- l2 = f2;
- for (f2 = f1 + size2; f2 < l2; f2 += size2) {
- if ((cmp(f2-size, f2) > 0) != sense) {
- p2 = *EVAL(p2) = f2 - list1 + list2;
- if (sense > 0)
- reverse(f1, f2-size);
- f1 = f2;
- }
- }
- if (sense > 0)
- reverse (f1, f2-size);
- f1 = f2;
- if (f2 < last || cmp(f2 - size, f2) > 0)
- p2 = *EVAL(p2) = f2 - list1 + list2;
- else
- p2 = *EVAL(p2) = list2 + n*size;
- }
- }
-#else /* pairwise merge only. */
- for (f1 = list1, p2 = list2; f1 < last; f1 += size2) {
- p2 = *EVAL(p2) = p2 + size2;
- if (cmp (f1, f1 + size) > 0)
- swap(f1, f1 + size);
- }
-#endif /* NATURAL */
-}
-/* }}} */
-
-/* {{{ insertionsort
- * This is to avoid out-of-bounds addresses in sorting the
- * last 4 elements.
- */
-static void insertionsort(u_char *a, size_t n, size_t size, int (*cmp)(const void *, const void *))
-{
- u_char *ai, *s, *t, *u, tmp;
- size_t i;
-
- for (ai = a+size; --n >= 1; ai += size)
- for (t = ai; t > a; t -= size) {
- u = t - size;
- if (cmp(u, t) <= 0)
- break;
- swap(u, t);
- }
-}
-/* }}} */
diff --git a/main/network.c b/main/network.c
index 091fc17e6f..2c504952b2 100644
--- a/main/network.c
+++ b/main/network.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -99,8 +97,7 @@ const struct in6_addr in6addr_any = {0}; /* IN6ADDR_ANY_INIT; */
# define PHP_GAI_STRERROR(x) (gai_strerror(x))
#else
# define PHP_GAI_STRERROR(x) (php_gai_strerror(x))
-/* {{{ php_gai_strerror
- */
+/* {{{ php_gai_strerror */
static const char *php_gai_strerror(int code)
{
static struct {
@@ -138,8 +135,7 @@ static const char *php_gai_strerror(int code)
#endif
#endif
-/* {{{ php_network_freeaddresses
- */
+/* {{{ php_network_freeaddresses */
PHPAPI void php_network_freeaddresses(struct sockaddr **sal)
{
struct sockaddr **sap;
@@ -782,7 +778,7 @@ PHPAPI php_socket_t php_network_accept_incoming(php_socket_t srvsock,
/* {{{ php_network_connect_socket_to_host */
php_socket_t php_network_connect_socket_to_host(const char *host, unsigned short port,
int socktype, int asynchronous, struct timeval *timeout, zend_string **error_string,
- int *error_code, char *bindto, unsigned short bindport, long sockopts
+ int *error_code, const char *bindto, unsigned short bindport, long sockopts
)
{
int num_addrs, n, fatal = 0;
@@ -889,7 +885,7 @@ php_socket_t php_network_connect_socket_to_host(const char *host, unsigned short
#endif
if (!local_address || bind(sock, local_address, local_address_len)) {
- php_error_docref(NULL, E_WARNING, "failed to bind to '%s:%d', system said: %s", bindto, bindport, strerror(errno));
+ php_error_docref(NULL, E_WARNING, "Failed to bind to '%s:%d', system said: %s", bindto, bindport, strerror(errno));
}
skip_bind:
if (local_address) {
@@ -1187,16 +1183,18 @@ PHPAPI void _php_emit_fd_setsize_warning(int max_fd)
PHPAPI int php_poll2(php_pollfd *ufds, unsigned int nfds, int timeout)
{
fd_set rset, wset, eset;
- php_socket_t max_fd = SOCK_ERR;
+ php_socket_t max_fd = SOCK_ERR; /* effectively unused on Windows */
unsigned int i;
int n;
struct timeval tv;
+#ifndef PHP_WIN32
/* check the highest numbered descriptor */
for (i = 0; i < nfds; i++) {
if (ufds[i].fd > max_fd)
max_fd = ufds[i].fd;
}
+#endif
PHP_SAFE_MAX_FD(max_fd, nfds + 1);
@@ -1220,7 +1218,7 @@ PHPAPI int php_poll2(php_pollfd *ufds, unsigned int nfds, int timeout)
tv.tv_sec = timeout / 1000;
tv.tv_usec = (timeout - (tv.tv_sec * 1000)) * 1000;
}
-/* Reseting/initializing */
+/* Resetting/initializing */
#ifdef PHP_WIN32
WSASetLastError(0);
#else
@@ -1319,7 +1317,7 @@ struct hostent * gethostname_re (const char *host,struct hostent *hostbuf,char *
#endif
#endif
-PHPAPI struct hostent* php_network_gethostbyname(char *name) {
+PHPAPI struct hostent* php_network_gethostbyname(const char *name) {
#if !defined(HAVE_GETHOSTBYNAME_R)
return gethostbyname(name);
#else
diff --git a/main/output.c b/main/output.c
index 7751586dbc..c895d3856e 100644
--- a/main/output.c
+++ b/main/output.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -33,7 +31,7 @@
#include "zend_stack.h"
#include "php_output.h"
-PHPAPI ZEND_DECLARE_MODULE_GLOBALS(output);
+PHPAPI ZEND_DECLARE_MODULE_GLOBALS(output)
const char php_output_default_handler_name[sizeof("default output handler")] = "default output handler";
const char php_output_devnull_handler_name[sizeof("null output handler")] = "null output handler";
@@ -592,9 +590,9 @@ PHPAPI int php_output_handler_conflict(const char *handler_new, size_t handler_n
{
if (php_output_handler_started(handler_set, handler_set_len)) {
if (handler_new_len != handler_set_len || memcmp(handler_new, handler_set, handler_set_len)) {
- php_error_docref("ref.outcontrol", E_WARNING, "output handler '%s' conflicts with '%s'", handler_new, handler_set);
+ php_error_docref("ref.outcontrol", E_WARNING, "Output handler '%s' conflicts with '%s'", handler_new, handler_set);
} else {
- php_error_docref("ref.outcontrol", E_WARNING, "output handler '%s' cannot be used twice", handler_new);
+ php_error_docref("ref.outcontrol", E_WARNING, "Output handler '%s' cannot be used twice", handler_new);
}
return 1;
}
@@ -1199,12 +1197,12 @@ static int php_output_stack_pop(int flags)
if (!orphan) {
if (!(flags & PHP_OUTPUT_POP_SILENT)) {
- php_error_docref("ref.outcontrol", E_NOTICE, "failed to %s buffer. No buffer to %s", (flags&PHP_OUTPUT_POP_DISCARD)?"discard":"send", (flags&PHP_OUTPUT_POP_DISCARD)?"discard":"send");
+ php_error_docref("ref.outcontrol", E_NOTICE, "Failed to %s buffer. No buffer to %s", (flags&PHP_OUTPUT_POP_DISCARD)?"discard":"send", (flags&PHP_OUTPUT_POP_DISCARD)?"discard":"send");
}
return 0;
} else if (!(flags & PHP_OUTPUT_POP_FORCE) && !(orphan->flags & PHP_OUTPUT_HANDLER_REMOVABLE)) {
if (!(flags & PHP_OUTPUT_POP_SILENT)) {
- php_error_docref("ref.outcontrol", E_NOTICE, "failed to %s buffer of %s (%d)", (flags&PHP_OUTPUT_POP_DISCARD)?"discard":"send", ZSTR_VAL(orphan->name), orphan->level);
+ php_error_docref("ref.outcontrol", E_NOTICE, "Failed to %s buffer of %s (%d)", (flags&PHP_OUTPUT_POP_DISCARD)?"discard":"send", ZSTR_VAL(orphan->name), orphan->level);
}
return 0;
} else {
@@ -1292,8 +1290,7 @@ static int php_output_handler_devnull_func(void **handler_context, php_output_co
* USERLAND (nearly 1:1 of old output.c)
*/
-/* {{{ proto bool ob_start([string|array user_function [, int chunk_size [, int flags]]])
- Turn on Output Buffering (specifying an optional output handler). */
+/* {{{ Turn on Output Buffering (specifying an optional output handler). */
PHP_FUNCTION(ob_start)
{
zval *output_handler = NULL;
@@ -1301,7 +1298,7 @@ PHP_FUNCTION(ob_start)
zend_long flags = PHP_OUTPUT_HANDLER_STDFLAGS;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|zll", &output_handler, &chunk_size, &flags) == FAILURE) {
- return;
+ RETURN_THROWS();
}
if (chunk_size < 0) {
@@ -1309,65 +1306,62 @@ PHP_FUNCTION(ob_start)
}
if (php_output_start_user(output_handler, chunk_size, flags) == FAILURE) {
- php_error_docref("ref.outcontrol", E_NOTICE, "failed to create buffer");
+ php_error_docref("ref.outcontrol", E_NOTICE, "Failed to create buffer");
RETURN_FALSE;
}
RETURN_TRUE;
}
/* }}} */
-/* {{{ proto bool ob_flush(void)
- Flush (send) contents of the output buffer. The last buffer content is sent to next buffer */
+/* {{{ Flush (send) contents of the output buffer. The last buffer content is sent to next buffer */
PHP_FUNCTION(ob_flush)
{
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
if (!OG(active)) {
- php_error_docref("ref.outcontrol", E_NOTICE, "failed to flush buffer. No buffer to flush");
+ php_error_docref("ref.outcontrol", E_NOTICE, "Failed to flush buffer. No buffer to flush");
RETURN_FALSE;
}
if (SUCCESS != php_output_flush()) {
- php_error_docref("ref.outcontrol", E_NOTICE, "failed to flush buffer of %s (%d)", ZSTR_VAL(OG(active)->name), OG(active)->level);
+ php_error_docref("ref.outcontrol", E_NOTICE, "Failed to flush buffer of %s (%d)", ZSTR_VAL(OG(active)->name), OG(active)->level);
RETURN_FALSE;
}
RETURN_TRUE;
}
/* }}} */
-/* {{{ proto bool ob_clean(void)
- Clean (delete) the current output buffer */
+/* {{{ Clean (delete) the current output buffer */
PHP_FUNCTION(ob_clean)
{
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
if (!OG(active)) {
- php_error_docref("ref.outcontrol", E_NOTICE, "failed to delete buffer. No buffer to delete");
+ php_error_docref("ref.outcontrol", E_NOTICE, "Failed to delete buffer. No buffer to delete");
RETURN_FALSE;
}
if (SUCCESS != php_output_clean()) {
- php_error_docref("ref.outcontrol", E_NOTICE, "failed to delete buffer of %s (%d)", ZSTR_VAL(OG(active)->name), OG(active)->level);
+ php_error_docref("ref.outcontrol", E_NOTICE, "Failed to delete buffer of %s (%d)", ZSTR_VAL(OG(active)->name), OG(active)->level);
RETURN_FALSE;
}
RETURN_TRUE;
}
/* }}} */
-/* {{{ proto bool ob_end_flush(void)
- Flush (send) the output buffer, and delete current output buffer */
+/* {{{ Flush (send) the output buffer, and delete current output buffer */
PHP_FUNCTION(ob_end_flush)
{
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
if (!OG(active)) {
- php_error_docref("ref.outcontrol", E_NOTICE, "failed to delete and flush buffer. No buffer to delete or flush");
+ php_error_docref("ref.outcontrol", E_NOTICE, "Failed to delete and flush buffer. No buffer to delete or flush");
RETURN_FALSE;
}
@@ -1375,16 +1369,15 @@ PHP_FUNCTION(ob_end_flush)
}
/* }}} */
-/* {{{ proto bool ob_end_clean(void)
- Clean the output buffer, and delete current output buffer */
+/* {{{ Clean the output buffer, and delete current output buffer */
PHP_FUNCTION(ob_end_clean)
{
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
if (!OG(active)) {
- php_error_docref("ref.outcontrol", E_NOTICE, "failed to delete buffer. No buffer to delete");
+ php_error_docref("ref.outcontrol", E_NOTICE, "Failed to delete buffer. No buffer to delete");
RETURN_FALSE;
}
@@ -1392,31 +1385,29 @@ PHP_FUNCTION(ob_end_clean)
}
/* }}} */
-/* {{{ proto bool ob_get_flush(void)
- Get current buffer contents, flush (send) the output buffer, and delete current output buffer */
+/* {{{ Get current buffer contents, flush (send) the output buffer, and delete current output buffer */
PHP_FUNCTION(ob_get_flush)
{
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
if (php_output_get_contents(return_value) == FAILURE) {
- php_error_docref("ref.outcontrol", E_NOTICE, "failed to delete and flush buffer. No buffer to delete or flush");
+ php_error_docref("ref.outcontrol", E_NOTICE, "Failed to delete and flush buffer. No buffer to delete or flush");
RETURN_FALSE;
}
if (SUCCESS != php_output_end()) {
- php_error_docref("ref.outcontrol", E_NOTICE, "failed to delete buffer of %s (%d)", ZSTR_VAL(OG(active)->name), OG(active)->level);
+ php_error_docref("ref.outcontrol", E_NOTICE, "Failed to delete buffer of %s (%d)", ZSTR_VAL(OG(active)->name), OG(active)->level);
}
}
/* }}} */
-/* {{{ proto bool ob_get_clean(void)
- Get current buffer contents and delete current output buffer */
+/* {{{ Get current buffer contents and delete current output buffer */
PHP_FUNCTION(ob_get_clean)
{
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
if(!OG(active)) {
@@ -1424,22 +1415,21 @@ PHP_FUNCTION(ob_get_clean)
}
if (php_output_get_contents(return_value) == FAILURE) {
- php_error_docref("ref.outcontrol", E_NOTICE, "failed to delete buffer. No buffer to delete");
+ php_error_docref("ref.outcontrol", E_NOTICE, "Failed to delete buffer. No buffer to delete");
RETURN_FALSE;
}
if (SUCCESS != php_output_discard()) {
- php_error_docref("ref.outcontrol", E_NOTICE, "failed to delete buffer of %s (%d)", ZSTR_VAL(OG(active)->name), OG(active)->level);
+ php_error_docref("ref.outcontrol", E_NOTICE, "Failed to delete buffer of %s (%d)", ZSTR_VAL(OG(active)->name), OG(active)->level);
}
}
/* }}} */
-/* {{{ proto string ob_get_contents(void)
- Return the contents of the output buffer */
+/* {{{ Return the contents of the output buffer */
PHP_FUNCTION(ob_get_contents)
{
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
if (php_output_get_contents(return_value) == FAILURE) {
@@ -1448,24 +1438,22 @@ PHP_FUNCTION(ob_get_contents)
}
/* }}} */
-/* {{{ proto int ob_get_level(void)
- Return the nesting level of the output buffer */
+/* {{{ Return the nesting level of the output buffer */
PHP_FUNCTION(ob_get_level)
{
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
RETURN_LONG(php_output_get_level());
}
/* }}} */
-/* {{{ proto int ob_get_length(void)
- Return the length of the output buffer */
+/* {{{ Return the length of the output buffer */
PHP_FUNCTION(ob_get_length)
{
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
if (php_output_get_length(return_value) == FAILURE) {
@@ -1474,12 +1462,11 @@ PHP_FUNCTION(ob_get_length)
}
/* }}} */
-/* {{{ proto false|array ob_list_handlers()
- List all output_buffers in an array */
+/* {{{ List all output_buffers in an array */
PHP_FUNCTION(ob_list_handlers)
{
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
array_init(return_value);
@@ -1492,14 +1479,13 @@ PHP_FUNCTION(ob_list_handlers)
}
/* }}} */
-/* {{{ proto false|array ob_get_status([bool full_status])
- Return the status of the active or all output buffers */
+/* {{{ Return the status of the active or all output buffers */
PHP_FUNCTION(ob_get_status)
{
zend_bool full_status = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|b", &full_status) == FAILURE) {
- return;
+ RETURN_THROWS();
}
if (!OG(active)) {
@@ -1516,26 +1502,24 @@ PHP_FUNCTION(ob_get_status)
}
/* }}} */
-/* {{{ proto void ob_implicit_flush([int flag])
- Turn implicit flush on/off and is equivalent to calling flush() after every output call */
+/* {{{ Turn implicit flush on/off and is equivalent to calling flush() after every output call */
PHP_FUNCTION(ob_implicit_flush)
{
zend_long flag = 1;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &flag) == FAILURE) {
- return;
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "|b", &flag) == FAILURE) {
+ RETURN_THROWS();
}
- php_output_set_implicit_flush(flag);
+ php_output_set_implicit_flush((int) flag);
}
/* }}} */
-/* {{{ proto bool output_reset_rewrite_vars(void)
- Reset(clear) URL rewriter values */
+/* {{{ Reset(clear) URL rewriter values */
PHP_FUNCTION(output_reset_rewrite_vars)
{
if (zend_parse_parameters_none() == FAILURE) {
- return;
+ RETURN_THROWS();
}
if (php_url_scanner_reset_vars() == SUCCESS) {
@@ -1546,15 +1530,14 @@ PHP_FUNCTION(output_reset_rewrite_vars)
}
/* }}} */
-/* {{{ proto bool output_add_rewrite_var(string name, string value)
- Add URL rewriter values */
+/* {{{ Add URL rewriter values */
PHP_FUNCTION(output_add_rewrite_var)
{
char *name, *value;
size_t name_len, value_len;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &name, &name_len, &value, &value_len) == FAILURE) {
- return;
+ RETURN_THROWS();
}
if (php_url_scanner_add_var(name, name_len, value, value_len, 1) == SUCCESS) {
diff --git a/main/php.h b/main/php.h
index dbd7673643..497b906fc6 100644
--- a/main/php.h
+++ b/main/php.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -24,7 +22,7 @@
#include <dmalloc.h>
#endif
-#define PHP_API_VERSION 20190902
+#define PHP_API_VERSION 20200804
#define PHP_HAVE_STREAMS
#define YYDEBUG 0
#define PHP_DEFAULT_CHARSET "UTF-8"
@@ -128,7 +126,7 @@ typedef int pid_t;
#endif
#include <assert.h>
-#if HAVE_UNIX_H
+#ifdef HAVE_UNIX_H
#include <unix.h>
#endif
@@ -295,11 +293,10 @@ END_EXTERN_C()
#define php_ignore_value(x) ZEND_IGNORE_VALUE(x)
/* global variables */
-#if !defined(PHP_WIN32)
-#define PHP_SLEEP_NON_VOID
+#ifndef PHP_WIN32
#define php_sleep sleep
extern char **environ;
-#endif /* !defined(PHP_WIN32) */
+#endif /* ifndef PHP_WIN32 */
#ifdef PHP_PWRITE_64
ssize_t pwrite(int, void *, size_t, off64_t);
@@ -312,8 +309,8 @@ ssize_t pread(int, void *, size_t, off64_t);
BEGIN_EXTERN_C()
void phperror(char *error);
PHPAPI size_t php_write(void *buf, size_t size);
-PHPAPI size_t php_printf(const char *format, ...) PHP_ATTRIBUTE_FORMAT(printf, 1,
- 2);
+PHPAPI size_t php_printf(const char *format, ...) PHP_ATTRIBUTE_FORMAT(printf, 1, 2);
+PHPAPI size_t php_printf_unchecked(const char *format, ...);
PHPAPI int php_get_module_initialized(void);
#ifdef HAVE_SYSLOG_H
#include "php_syslog.h"
@@ -321,7 +318,7 @@ PHPAPI int php_get_module_initialized(void);
#else
#define php_log_err(msg) php_log_err_with_severity(msg, 5)
#endif
-PHPAPI ZEND_COLD void php_log_err_with_severity(char *log_message, int syslog_type_int);
+PHPAPI ZEND_COLD void php_log_err_with_severity(const char *log_message, int syslog_type_int);
int Debug(char *format, ...) PHP_ATTRIBUTE_FORMAT(printf, 1, 2);
int cfgparse(void);
END_EXTERN_C()
@@ -363,7 +360,6 @@ END_EXTERN_C()
BEGIN_EXTERN_C()
PHPAPI extern int (*php_register_internal_extensions_func)(void);
PHPAPI int php_register_internal_extensions(void);
-PHPAPI int php_mergesort(void *base, size_t nmemb, size_t size, int (*cmp)(const void *, const void *));
PHPAPI void php_register_pre_request_shutdown(void (*func)(void *), void *userdata);
PHPAPI void php_com_initialize(void);
PHPAPI char *php_get_current_user(void);
diff --git a/main/php_compat.h b/main/php_compat.h
index 01d3e326c5..4dcf39dc22 100644
--- a/main/php_compat.h
+++ b/main/php_compat.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/main/php_content_types.c b/main/php_content_types.c
index b53ee1ab84..920fc95906 100644
--- a/main/php_content_types.c
+++ b/main/php_content_types.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -22,8 +20,7 @@
#include "php_content_types.h"
-/* {{{ php_post_entries[]
- */
+/* {{{ php_post_entries[] */
static const sapi_post_entry php_post_entries[] = {
{ DEFAULT_POST_CONTENT_TYPE, sizeof(DEFAULT_POST_CONTENT_TYPE)-1, sapi_read_standard_form_data, php_std_post_handler },
{ MULTIPART_CONTENT_TYPE, sizeof(MULTIPART_CONTENT_TYPE)-1, NULL, rfc1867_post_handler },
@@ -31,8 +28,7 @@ static const sapi_post_entry php_post_entries[] = {
};
/* }}} */
-/* {{{ SAPI_POST_READER_FUNC
- */
+/* {{{ SAPI_POST_READER_FUNC */
SAPI_API SAPI_POST_READER_FUNC(php_default_post_reader)
{
if (!strcmp(SG(request_info).request_method, "POST")) {
@@ -44,8 +40,7 @@ SAPI_API SAPI_POST_READER_FUNC(php_default_post_reader)
}
/* }}} */
-/* {{{ php_startup_sapi_content_types
- */
+/* {{{ php_startup_sapi_content_types */
int php_startup_sapi_content_types(void)
{
sapi_register_default_post_reader(php_default_post_reader);
@@ -55,8 +50,7 @@ int php_startup_sapi_content_types(void)
}
/* }}} */
-/* {{{ php_setup_sapi_content_types
- */
+/* {{{ php_setup_sapi_content_types */
int php_setup_sapi_content_types(void)
{
sapi_register_post_entries(php_post_entries);
diff --git a/main/php_content_types.h b/main/php_content_types.h
index 145e8d4c5e..b1bae1dd0c 100644
--- a/main/php_content_types.h
+++ b/main/php_content_types.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/main/php_getopt.h b/main/php_getopt.h
index c368aa7fa9..c68d3969c4 100644
--- a/main/php_getopt.h
+++ b/main/php_getopt.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/main/php_globals.h b/main/php_globals.h
index 6b31d9eaa6..e079866645 100644
--- a/main/php_globals.h
+++ b/main/php_globals.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -67,8 +65,7 @@ struct _php_core_globals {
zend_long memory_limit;
zend_long max_input_time;
- zend_bool track_errors;
- zend_bool display_errors;
+ zend_uchar display_errors;
zend_bool display_startup_errors;
zend_bool log_errors;
zend_long log_errors_max_len;
@@ -136,13 +133,12 @@ struct _php_core_globals {
zend_bool report_zend_debug;
int last_error_type;
- char *last_error_message;
+ zend_string *last_error_message;
char *last_error_file;
int last_error_lineno;
char *php_sys_temp_dir;
- char *disable_functions;
char *disable_classes;
zend_bool allow_url_include;
#ifdef PHP_WIN32
diff --git a/main/php_ini.c b/main/php_ini.c
index cc2cf16cf8..53c08ae3c4 100644
--- a/main/php_ini.c
+++ b/main/php_ini.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -67,8 +65,7 @@ static php_extension_lists extension_lists;
PHPAPI char *php_ini_scanned_path=NULL;
PHPAPI char *php_ini_scanned_files=NULL;
-/* {{{ php_ini_displayer_cb
- */
+/* {{{ php_ini_displayer_cb */
static ZEND_COLD void php_ini_displayer_cb(zend_ini_entry *ini_entry, int type)
{
if (ini_entry->displayer) {
@@ -115,8 +112,7 @@ static ZEND_COLD void php_ini_displayer_cb(zend_ini_entry *ini_entry, int type)
}
/* }}} */
-/* {{{ display_ini_entries
- */
+/* {{{ display_ini_entries */
PHPAPI ZEND_COLD void display_ini_entries(zend_module_entry *module)
{
int module_number;
@@ -166,8 +162,7 @@ PHPAPI ZEND_COLD void display_ini_entries(zend_module_entry *module)
#define PHP_EXTENSION_TOKEN "extension"
#define ZEND_EXTENSION_TOKEN "zend_extension"
-/* {{{ config_zval_dtor
- */
+/* {{{ config_zval_dtor */
PHPAPI void config_zval_dtor(zval *zvalue)
{
if (Z_TYPE_P(zvalue) == IS_ARRAY) {
@@ -184,8 +179,7 @@ PHPAPI void config_zval_dtor(zval *zvalue)
} while (0)
/* }}} */
-/* {{{ php_ini_parser_cb
- */
+/* {{{ php_ini_parser_cb */
static void php_ini_parser_cb(zval *arg1, zval *arg2, zval *arg3, int callback_type, HashTable *target_hash)
{
zval *entry;
@@ -316,8 +310,7 @@ static void php_ini_parser_cb(zval *arg1, zval *arg2, zval *arg3, int callback_t
}
/* }}} */
-/* {{{ php_load_php_extension_cb
- */
+/* {{{ php_load_php_extension_cb */
static void php_load_php_extension_cb(void *arg)
{
#ifdef HAVE_LIBDL
@@ -326,8 +319,7 @@ static void php_load_php_extension_cb(void *arg)
}
/* }}} */
-/* {{{ php_load_zend_extension_cb
- */
+/* {{{ php_load_zend_extension_cb */
#ifdef HAVE_LIBDL
static void php_load_zend_extension_cb(void *arg)
{
@@ -339,13 +331,6 @@ static void php_load_zend_extension_cb(void *arg)
#endif
if (IS_ABSOLUTE_PATH(filename, length)) {
-#ifdef PHP_WIN32
- char *err;
- if (!php_win32_image_compatible(filename, &err)) {
- php_error(E_CORE_WARNING, err);
- return;
- }
-#endif
zend_load_extension(filename);
} else {
DL_HANDLE handle;
@@ -389,13 +374,13 @@ static void php_load_zend_extension_cb(void *arg)
efree(orig_libpath);
efree(err1);
+ efree(libpath);
}
#ifdef PHP_WIN32
- if (!php_win32_image_compatible(libpath, &err1)) {
+ if (!php_win32_image_compatible(handle, &err1)) {
php_error(E_CORE_WARNING, err1);
efree(err1);
- efree(libpath);
DL_UNLOAD(handle);
return;
}
@@ -410,8 +395,7 @@ static void php_load_zend_extension_cb(void *arg) { }
#endif
/* }}} */
-/* {{{ php_init_config
- */
+/* {{{ php_init_config */
int php_init_config(void)
{
char *php_ini_file_name = NULL;
@@ -749,8 +733,7 @@ int php_init_config(void)
}
/* }}} */
-/* {{{ php_shutdown_config
- */
+/* {{{ php_shutdown_config */
int php_shutdown_config(void)
{
zend_hash_destroy(&configuration_hash);
@@ -766,8 +749,7 @@ int php_shutdown_config(void)
}
/* }}} */
-/* {{{ php_ini_register_extensions
- */
+/* {{{ php_ini_register_extensions */
void php_ini_register_extensions(void)
{
zend_llist_apply(&extension_lists.engine, php_load_zend_extension_cb);
@@ -778,9 +760,8 @@ void php_ini_register_extensions(void)
}
/* }}} */
-/* {{{ php_parse_user_ini_file
- */
-PHPAPI int php_parse_user_ini_file(const char *dirname, char *ini_filename, HashTable *target_hash)
+/* {{{ php_parse_user_ini_file */
+PHPAPI int php_parse_user_ini_file(const char *dirname, const char *ini_filename, HashTable *target_hash)
{
zend_stat_t sb;
char ini_file[MAXPATHLEN];
@@ -807,8 +788,7 @@ PHPAPI int php_parse_user_ini_file(const char *dirname, char *ini_filename, Hash
}
/* }}} */
-/* {{{ php_ini_activate_config
- */
+/* {{{ php_ini_activate_config */
PHPAPI void php_ini_activate_config(HashTable *source_hash, int modify_type, int stage)
{
zend_string *str;
@@ -821,16 +801,14 @@ PHPAPI void php_ini_activate_config(HashTable *source_hash, int modify_type, int
}
/* }}} */
-/* {{{ php_ini_has_per_dir_config
- */
+/* {{{ php_ini_has_per_dir_config */
PHPAPI int php_ini_has_per_dir_config(void)
{
return has_per_dir_config;
}
/* }}} */
-/* {{{ php_ini_activate_per_dir_config
- */
+/* {{{ php_ini_activate_per_dir_config */
PHPAPI void php_ini_activate_per_dir_config(char *path, size_t path_len)
{
zval *tmp2;
@@ -872,16 +850,14 @@ PHPAPI void php_ini_activate_per_dir_config(char *path, size_t path_len)
}
/* }}} */
-/* {{{ php_ini_has_per_host_config
- */
+/* {{{ php_ini_has_per_host_config */
PHPAPI int php_ini_has_per_host_config(void)
{
return has_per_host_config;
}
/* }}} */
-/* {{{ php_ini_activate_per_host_config
- */
+/* {{{ php_ini_activate_per_host_config */
PHPAPI void php_ini_activate_per_host_config(const char *host, size_t host_len)
{
zval *tmp;
@@ -895,24 +871,21 @@ PHPAPI void php_ini_activate_per_host_config(const char *host, size_t host_len)
}
/* }}} */
-/* {{{ cfg_get_entry
- */
+/* {{{ cfg_get_entry */
PHPAPI zval *cfg_get_entry_ex(zend_string *name)
{
return zend_hash_find(&configuration_hash, name);
}
/* }}} */
-/* {{{ cfg_get_entry
- */
+/* {{{ cfg_get_entry */
PHPAPI zval *cfg_get_entry(const char *name, size_t name_length)
{
return zend_hash_str_find(&configuration_hash, name, name_length);
}
/* }}} */
-/* {{{ cfg_get_long
- */
+/* {{{ cfg_get_long */
PHPAPI int cfg_get_long(const char *varname, zend_long *result)
{
zval *tmp;
@@ -926,8 +899,7 @@ PHPAPI int cfg_get_long(const char *varname, zend_long *result)
}
/* }}} */
-/* {{{ cfg_get_double
- */
+/* {{{ cfg_get_double */
PHPAPI int cfg_get_double(const char *varname, double *result)
{
zval *tmp;
@@ -941,8 +913,7 @@ PHPAPI int cfg_get_double(const char *varname, double *result)
}
/* }}} */
-/* {{{ cfg_get_string
- */
+/* {{{ cfg_get_string */
PHPAPI int cfg_get_string(const char *varname, char **result)
{
zval *tmp;
diff --git a/main/php_ini.h b/main/php_ini.h
index a4fad6c689..7fd7cdd1ce 100644
--- a/main/php_ini.h
+++ b/main/php_ini.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -31,7 +29,7 @@ PHPAPI zval *cfg_get_entry(const char *name, size_t name_length);
PHPAPI int cfg_get_long(const char *varname, zend_long *result);
PHPAPI int cfg_get_double(const char *varname, double *result);
PHPAPI int cfg_get_string(const char *varname, char **result);
-PHPAPI int php_parse_user_ini_file(const char *dirname, char *ini_filename, HashTable *target_hash);
+PHPAPI int php_parse_user_ini_file(const char *dirname, const char *ini_filename, HashTable *target_hash);
PHPAPI void php_ini_activate_config(HashTable *source_hash, int modify_type, int stage);
PHPAPI int php_ini_has_per_dir_config(void);
PHPAPI int php_ini_has_per_host_config(void);
diff --git a/main/php_main.h b/main/php_main.h
index 44eeb974d6..ee27209fbe 100644
--- a/main/php_main.h
+++ b/main/php_main.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/main/php_memory_streams.h b/main/php_memory_streams.h
index 7db25dd1dd..5d0b978aad 100644
--- a/main/php_memory_streams.h
+++ b/main/php_memory_streams.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -42,12 +40,12 @@
BEGIN_EXTERN_C()
PHPAPI php_stream *_php_stream_memory_create(int mode STREAMS_DC);
-PHPAPI php_stream *_php_stream_memory_open(int mode, char *buf, size_t length STREAMS_DC);
+PHPAPI php_stream *_php_stream_memory_open(int mode, const char *buf, size_t length STREAMS_DC);
PHPAPI char *_php_stream_memory_get_buffer(php_stream *stream, size_t *length STREAMS_DC);
PHPAPI php_stream *_php_stream_temp_create(int mode, size_t max_memory_usage STREAMS_DC);
PHPAPI php_stream *_php_stream_temp_create_ex(int mode, size_t max_memory_usage, const char *tmpdir STREAMS_DC);
-PHPAPI php_stream *_php_stream_temp_open(int mode, size_t max_memory_usage, char *buf, size_t length STREAMS_DC);
+PHPAPI php_stream *_php_stream_temp_open(int mode, size_t max_memory_usage, const char *buf, size_t length STREAMS_DC);
PHPAPI int php_stream_mode_from_str(const char *mode);
PHPAPI const char *_php_stream_mode_to_str(int mode);
diff --git a/main/php_network.h b/main/php_network.h
index 241ca94e27..437069b4fc 100644
--- a/main/php_network.h
+++ b/main/php_network.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -243,7 +241,7 @@ PHPAPI void php_network_freeaddresses(struct sockaddr **sal);
PHPAPI php_socket_t php_network_connect_socket_to_host(const char *host, unsigned short port,
int socktype, int asynchronous, struct timeval *timeout, zend_string **error_string,
- int *error_code, char *bindto, unsigned short bindport, long sockopts
+ int *error_code, const char *bindto, unsigned short bindport, long sockopts
);
PHPAPI int php_network_connect_socket(php_socket_t sockfd,
@@ -317,7 +315,7 @@ PHPAPI void php_network_populate_name_from_sockaddr(
PHPAPI int php_network_parse_network_address_with_port(const char *addr,
zend_long addrlen, struct sockaddr *sa, socklen_t *sl);
-PHPAPI struct hostent* php_network_gethostbyname(char *name);
+PHPAPI struct hostent* php_network_gethostbyname(const char *name);
PHPAPI int php_set_sock_blocking(php_socket_t socketd, int block);
END_EXTERN_C()
diff --git a/main/php_open_temporary_file.c b/main/php_open_temporary_file.c
index 6fca7e4cab..a65b91e84e 100644
--- a/main/php_open_temporary_file.c
+++ b/main/php_open_temporary_file.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/main/php_open_temporary_file.h b/main/php_open_temporary_file.h
index 0195056e31..deb8e240e5 100644
--- a/main/php_open_temporary_file.h
+++ b/main/php_open_temporary_file.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/main/php_output.h b/main/php_output.h
index f76d61d841..60f389b2b5 100644
--- a/main/php_output.h
+++ b/main/php_output.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/main/php_reentrancy.h b/main/php_reentrancy.h
index bbc772b5db..62c1ca232f 100644
--- a/main/php_reentrancy.h
+++ b/main/php_reentrancy.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -101,12 +99,6 @@ char *strtok_r(char *s, const char *delim, char **last);
#endif
#endif
-#if !defined(HAVE_RAND_R)
-PHPAPI int php_rand_r(unsigned int *seed);
-#else
-#define php_rand_r rand_r
-#endif
-
END_EXTERN_C()
#if !defined(ZTS)
diff --git a/main/php_scandir.c b/main/php_scandir.c
index 7fdb49b77a..91bfabc73c 100644
--- a/main/php_scandir.c
+++ b/main/php_scandir.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/main/php_scandir.h b/main/php_scandir.h
index 04bf29f2c9..834d0b7f1e 100644
--- a/main/php_scandir.h
+++ b/main/php_scandir.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/main/php_stdint.h b/main/php_stdint.h
index 3e5fd0016c..0ea91fadeb 100644
--- a/main/php_stdint.h
+++ b/main/php_stdint.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -41,180 +39,13 @@
# endif
#endif
-#if defined(_MSC_VER)
-/* Make sure the regular stdint.h wasn't included already and prevent it to be
- included afterwards. Though if some other library needs some stuff from
- stdint.h included afterwards and misses it, we'd have to extend ours. On
- the other hand, if stdint.h was included before, some conflicts might
- happen so we'd likewise have to fix ours. */
-# if !defined(_STDINT)
-# define _STDINT
-# include "win32/php_stdint.h"
-# include "win32/php_inttypes.h"
-# endif
-# define HAVE_INT8_T 1
-# define HAVE_UINT8_T 1
-# define HAVE_INT16_T 1
-# define HAVE_UINT16_T 1
-# define HAVE_INT32_T 1
-# define HAVE_UINT32_T 1
-# define HAVE_INT64_T 1
-# define HAVE_UINT64_T 1
-#else
-
-#include "php_config.h"
-
-#if HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-
-#if HAVE_INTTYPES_H
-# include <inttypes.h>
-#endif
-
-#if HAVE_STDINT_H
-# include <stdint.h>
-#endif
-
-#ifndef HAVE_INT8_T
-# ifdef HAVE_INT8
-typedef int8 int8_t;
-# else
-typedef signed char int8_t;
-# endif
-#endif
-
-#ifndef INT8_C
-# define INT8_C(c) c
-#endif
-
-#ifndef HAVE_UINT8_T
-# ifdef HAVE_UINT8
-typedef uint8 uint8_t
-# elif HAVE_U_INT8_T
-typedef u_int8_t uint8_t;
-# else
-typedef unsigned char uint8_t;
-# endif
-#endif
-
-#ifndef UINT8_C
-# define UINT8_C(c) c
-#endif
+#include <inttypes.h>
+#include <stdint.h>
-#ifndef HAVE_INT16_T
-# ifdef HAVE_INT16
-typedef int16 int16_t;
-# elif SIZEOF_SHORT >= 2
-typedef signed short int16_t;
-# else
-# error "No suitable 16bit integer type found"
-# endif
-#endif
-
-#ifndef INT16_C
-# define INT16_C(c) c
-#endif
-
-#ifndef HAVE_UINT16_T
-# ifdef HAVE_UINT16
-typedef uint16 uint16_t
-# elif HAVE_U_INT16_T
-typedef u_int16_t uint16_t;
-# elif SIZEOF_SHORT >= 2
-typedef unsigned short uint16_t;
-# else
-# error "No suitable 16bit integer type found"
-# endif
-#endif
-
-#ifndef UINT16_C
-# define UINT16_C(c) c
-#endif
-
-#ifndef HAVE_INT32_T
-# ifdef HAVE_INT32
-typedef int32 int32_t;
-# elif SIZEOF_INT >= 4
-typedef int int32_t;
-# elif SIZEOF_LONG >= 4
-typedef long int32_t;
-# else
-# error "No suitable 32bit integer type found"
-# endif
-#endif
-
-#ifndef INT32_C
-# define INT32_C(c) c
-#endif
-
-#ifndef HAVE_UINT32_T
-# ifdef HAVE_UINT32
-typedef uint32 uint32_t
-# elif HAVE_U_INT32_T
-typedef u_int32_t uint32_t;
-# elif SIZEOF_INT >= 4
-typedef unsigned int uint32_t;
-# elif SIZEOF_LONG >= 4
-typedef unsigned long uint32_t;
-# else
-# error "No suitable 32bit integer type found"
-# endif
-#endif
-
-#ifndef UINT32_C
-# define UINT32_C(c) c ## U
-#endif
-
-#ifndef HAVE_INT64_T
-# ifdef HAVE_INT64
-typedef int64 int64_t;
-# elif SIZEOF_INT >= 8
-typedef int int64_t;
-# elif SIZEOF_LONG >= 8
-typedef long int64_t;
-# elif SIZEOF_LONG_LONG >= 8
-typedef long long int64_t;
-# else
-# error "No suitable 64bit integer type found"
-# endif
-#endif
-
-#ifndef INT64_C
-# if SIZEOF_INT >= 8
-# define INT64_C(c) c
-# elif SIZEOF_LONG >= 8
-# define INT64_C(c) c ## L
-# elif SIZEOF_LONG_LONG >= 8
-# define INT64_C(c) c ## LL
-# endif
-#endif
-
-#ifndef HAVE_UINT64_T
-# ifdef HAVE_UINT64
-typedef uint64 uint64_t
-# elif HAVE_U_INT64_T
-typedef u_int64_t uint64_t;
-# elif SIZEOF_INT >= 8
-typedef unsigned int uint64_t;
-# elif SIZEOF_LONG >= 8
-typedef unsigned long uint64_t;
-# elif SIZEOF_LONG_LONG >= 8
-typedef unsigned long long uint64_t;
-# else
-# error "No suitable 64bit integer type found"
-# endif
-#endif
-
-#ifndef UINT64_C
-# if SIZEOF_INT >= 8
-# define UINT64_C(c) c ## U
-# elif SIZEOF_LONG >= 8
-# define UINT64_C(c) c ## UL
-# elif SIZEOF_LONG_LONG >= 8
-# define UINT64_C(c) c ## ULL
+#if defined(_MSC_VER)
+# ifndef u_char
+typedef unsigned __int8 u_char;
# endif
-#endif
+#endif /* !_MSC_VER */
-#endif /* !PHP_WIN32 */
#endif /* PHP_STDINT_H */
diff --git a/main/php_streams.h b/main/php_streams.h
index 11e7c2aae7..73740a7a79 100644
--- a/main/php_streams.h
+++ b/main/php_streams.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -260,13 +258,13 @@ END_EXTERN_C()
#define php_stream_from_zval(xstr, pzval) do { \
if (((xstr) = (php_stream*)zend_fetch_resource2_ex((pzval), \
"stream", php_file_le_stream(), php_file_le_pstream())) == NULL) { \
- RETURN_FALSE; \
+ return; \
} \
} while (0)
#define php_stream_from_res(xstr, res) do { \
if (((xstr) = (php_stream*)zend_fetch_resource2((res), \
"stream", php_file_le_stream(), php_file_le_pstream())) == NULL) { \
- RETURN_FALSE; \
+ return; \
} \
} while (0)
#define php_stream_from_res_no_verify(xstr, pzval) (xstr) = (php_stream*)zend_fetch_resource2((res), "stream", php_file_le_stream(), php_file_le_pstream())
diff --git a/main/php_syslog.c b/main/php_syslog.c
index 987ef9cc0c..37bf5a7fb6 100644
--- a/main/php_syslog.c
+++ b/main/php_syslog.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/main/php_syslog.h b/main/php_syslog.h
index 2c499269a4..227baa8b16 100644
--- a/main/php_syslog.h
+++ b/main/php_syslog.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/main/php_ticks.c b/main/php_ticks.c
index f5b0dd0c58..0fd0dde6fe 100644
--- a/main/php_ticks.c
+++ b/main/php_ticks.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/main/php_ticks.h b/main/php_ticks.h
index 5b2bb057e6..cc92eae8fc 100644
--- a/main/php_ticks.h
+++ b/main/php_ticks.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/main/php_variables.c b/main/php_variables.c
index cbdc7cf171..312c22ef07 100644
--- a/main/php_variables.c
+++ b/main/php_variables.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -27,33 +25,24 @@
#include "php_content_types.h"
#include "SAPI.h"
#include "zend_globals.h"
-#ifdef PHP_WIN32
-# include "win32/php_inttypes.h"
-#endif
/* for systems that need to override reading of environment variables */
void _php_import_environment_variables(zval *array_ptr);
PHPAPI void (*php_import_environment_variables)(zval *array_ptr) = _php_import_environment_variables;
-PHPAPI void php_register_variable(char *var, char *strval, zval *track_vars_array)
+PHPAPI void php_register_variable(const char *var, const char *strval, zval *track_vars_array)
{
php_register_variable_safe(var, strval, strlen(strval), track_vars_array);
}
/* binary-safe version */
-PHPAPI void php_register_variable_safe(char *var, char *strval, size_t str_len, zval *track_vars_array)
+PHPAPI void php_register_variable_safe(const char *var, const char *strval, size_t str_len, zval *track_vars_array)
{
zval new_entry;
assert(strval != NULL);
- /* Prepare value */
- if (str_len == 0) {
- ZVAL_EMPTY_STRING(&new_entry);
- } else if (str_len == 1) {
- ZVAL_INTERNED_STR(&new_entry, ZSTR_CHAR((zend_uchar)*strval));
- } else {
- ZVAL_NEW_STR(&new_entry, zend_string_init(strval, str_len, 0));
- }
+ ZVAL_STRINGL_FAST(&new_entry, strval, str_len);
+
php_register_variable_ex(var, &new_entry, track_vars_array);
}
@@ -65,7 +54,7 @@ static zend_always_inline void php_register_variable_quick(const char *name, siz
zend_string_release_ex(key, 0);
}
-PHPAPI void php_register_variable_ex(char *var_name, zval *val, zval *track_vars_array)
+PHPAPI void php_register_variable_ex(const char *var_name, zval *val, zval *track_vars_array)
{
char *p = NULL;
char *ip = NULL; /* index pointer */
@@ -189,8 +178,14 @@ PHPAPI void php_register_variable_ex(char *var_name, zval *val, zval *track_vars
} else {
ip = strchr(ip, ']');
if (!ip) {
- /* PHP variables cannot contain '[' in their names, so we replace the character with a '_' */
+ /* not an index; un-terminate the var name */
*(index_s - 1) = '_';
+ /* PHP variables cannot contain ' ', '.', '[' in their names, so we replace the characters with a '_' */
+ for (p = index_s; *p; p++) {
+ if (*p == ' ' || *p == '.' || *p == '[') {
+ *p = '_';
+ }
+ }
index_len = 0;
if (index) {
@@ -559,13 +554,7 @@ static zend_always_inline void import_environment_variable(HashTable *ht, char *
name_len = p - env;
p++;
len = strlen(p);
- if (len == 0) {
- ZVAL_EMPTY_STRING(&val);
- } else if (len == 1) {
- ZVAL_INTERNED_STR(&val, ZSTR_CHAR((zend_uchar)*p));
- } else {
- ZVAL_NEW_STR(&val, zend_string_init(p, len, 0));
- }
+ ZVAL_STRINGL_FAST(&val, p, len);
if (ZEND_HANDLE_NUMERIC_STR(env, name_len, idx)) {
zend_hash_index_update(ht, idx, &val);
} else {
@@ -575,21 +564,15 @@ static zend_always_inline void import_environment_variable(HashTable *ht, char *
void _php_import_environment_variables(zval *array_ptr)
{
-#ifndef PHP_WIN32
- char **env;
-#else
- char *environment, *env;
-#endif
-
tsrm_env_lock();
#ifndef PHP_WIN32
- for (env = environ; env != NULL && *env != NULL; env++) {
+ for (char **env = environ; env != NULL && *env != NULL; env++) {
import_environment_variable(Z_ARRVAL_P(array_ptr), *env);
}
#else
- environment = GetEnvironmentStringsA();
- for (env = environment; env != NULL && *env; env += strlen(env) + 1) {
+ char *environment = GetEnvironmentStringsA();
+ for (char *env = environment; env != NULL && *env; env += strlen(env) + 1) {
import_environment_variable(Z_ARRVAL_P(array_ptr), env);
}
FreeEnvironmentStringsA(environment);
@@ -604,13 +587,11 @@ zend_bool php_std_auto_global_callback(char *name, uint32_t name_len)
return 0; /* don't rearm */
}
-/* {{{ php_build_argv
- */
-PHPAPI void php_build_argv(char *s, zval *track_vars_array)
+/* {{{ php_build_argv */
+PHPAPI void php_build_argv(const char *s, zval *track_vars_array)
{
zval arr, argc, tmp;
int count = 0;
- char *ss, *space;
if (!(SG(request_info).argc || track_vars_array)) {
return;
@@ -628,24 +609,18 @@ PHPAPI void php_build_argv(char *s, zval *track_vars_array)
}
}
} else if (s && *s) {
- ss = s;
- while (ss) {
- space = strchr(ss, '+');
- if (space) {
- *space = '\0';
- }
+ while (1) {
+ const char *space = strchr(s, '+');
/* auto-type */
- ZVAL_STRING(&tmp, ss);
+ ZVAL_STRINGL(&tmp, s, space ? space - s : strlen(s));
count++;
if (zend_hash_next_index_insert(Z_ARRVAL(arr), &tmp) == NULL) {
zend_string_efree(Z_STR(tmp));
}
- if (space) {
- *space = '+';
- ss = space + 1;
- } else {
- ss = space;
+ if (!space) {
+ break;
}
+ s = space + 1;
}
}
@@ -670,8 +645,7 @@ PHPAPI void php_build_argv(char *s, zval *track_vars_array)
}
/* }}} */
-/* {{{ php_register_server_variables
- */
+/* {{{ php_register_server_variables */
static inline void php_register_server_variables(void)
{
zval tmp;
@@ -709,8 +683,7 @@ static inline void php_register_server_variables(void)
}
/* }}} */
-/* {{{ php_autoglobal_merge
- */
+/* {{{ php_autoglobal_merge */
static void php_autoglobal_merge(HashTable *dest, HashTable *src)
{
zval *src_entry, *dest_entry;
@@ -742,8 +715,7 @@ static void php_autoglobal_merge(HashTable *dest, HashTable *src)
}
/* }}} */
-/* {{{ php_hash_environment
- */
+/* {{{ php_hash_environment */
PHPAPI int php_hash_environment(void)
{
memset(PG(http_globals), 0, sizeof(PG(http_globals)));
diff --git a/main/php_variables.h b/main/php_variables.h
index 7dc33d328a..c6ccbe6a72 100644
--- a/main/php_variables.h
+++ b/main/php_variables.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -34,12 +32,12 @@
BEGIN_EXTERN_C()
void php_startup_auto_globals(void);
extern PHPAPI void (*php_import_environment_variables)(zval *array_ptr);
-PHPAPI void php_register_variable(char *var, char *val, zval *track_vars_array);
+PHPAPI void php_register_variable(const char *var, const char *val, zval *track_vars_array);
/* binary-safe version */
-PHPAPI void php_register_variable_safe(char *var, char *val, size_t val_len, zval *track_vars_array);
-PHPAPI void php_register_variable_ex(char *var, zval *val, zval *track_vars_array);
+PHPAPI void php_register_variable_safe(const char *var, const char *val, size_t val_len, zval *track_vars_array);
+PHPAPI void php_register_variable_ex(const char *var, zval *val, zval *track_vars_array);
-PHPAPI void php_build_argv(char *s, zval *track_vars_array);
+PHPAPI void php_build_argv(const char *s, zval *track_vars_array);
PHPAPI int php_hash_environment(void);
END_EXTERN_C()
diff --git a/main/php_version.h b/main/php_version.h
index 75d1e02d5e..24765617cb 100644
--- a/main/php_version.h
+++ b/main/php_version.h
@@ -1,8 +1,8 @@
/* automatically generated by configure */
/* edit configure.ac to change version number */
-#define PHP_MAJOR_VERSION 7
-#define PHP_MINOR_VERSION 4
-#define PHP_RELEASE_VERSION 11
+#define PHP_MAJOR_VERSION 8
+#define PHP_MINOR_VERSION 0
+#define PHP_RELEASE_VERSION 0
#define PHP_EXTRA_VERSION "-dev"
-#define PHP_VERSION "7.4.11-dev"
-#define PHP_VERSION_ID 70411
+#define PHP_VERSION "8.0.0-dev"
+#define PHP_VERSION_ID 80000
diff --git a/main/reentrancy.c b/main/reentrancy.c
index e4c378f659..776bcb9f35 100644
--- a/main/reentrancy.c
+++ b/main/reentrancy.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -215,63 +213,6 @@ void reentrancy_shutdown(void)
#endif
-#ifndef HAVE_RAND_R
-
-/*-
- * Copyright (c) 1990, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * Posix rand_r function added May 1999 by Wes Peters <wes@softweyr.com>.
- */
-
-#include <sys/types.h>
-#include <stdlib.h>
-
-static int
-do_rand(unsigned long *ctx)
-{
- return ((*ctx = *ctx * 1103515245 + 12345) % ((u_long)PHP_RAND_MAX + 1));
-}
-
-
-PHPAPI int
-php_rand_r(unsigned int *ctx)
-{
- u_long val = (u_long) *ctx;
- *ctx = do_rand(&val);
- return (int) *ctx;
-}
-
-#endif
-
#ifndef HAVE_STRTOK_R
diff --git a/main/rfc1867.c b/main/rfc1867.c
index 8bdc409296..8ef83f443d 100644
--- a/main/rfc1867.c
+++ b/main/rfc1867.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -33,11 +31,6 @@
#include "ext/standard/php_string.h"
#include "zend_smart_string.h"
-#if defined(PHP_WIN32) && !defined(HAVE_ATOLL)
-# define atoll(s) _atoi64(s)
-# define HAVE_ATOLL 1
-#endif
-
#ifndef DEBUG_FILE_UPLOAD
# define DEBUG_FILE_UPLOAD 0
#endif
@@ -905,11 +898,7 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler) /* {{{ */
}
if (!strcasecmp(param, "MAX_FILE_SIZE")) {
-#ifdef HAVE_ATOLL
- max_file_size = atoll(value);
-#else
max_file_size = strtoll(value, NULL, 10);
-#endif
}
efree(param);
@@ -1139,11 +1128,11 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler) /* {{{ */
snprintf(lbuf, llen, "%s_name", param);
}
- /* The \ check should technically be needed for win32 systems only where
- * it is a valid path separator. However, IE in all it's wisdom always sends
- * the full path of the file on the user's filesystem, which means that unless
- * the user does basename() they get a bogus file name. Until IE's user base drops
- * to nill or problem is fixed this code must remain enabled for all systems. */
+ /* Pursuant to RFC 7578, strip any path components in the
+ * user-supplied file name:
+ * > If a "filename" parameter is supplied ... do not use
+ * > directory path information that may be present."
+ */
s = _basename(internal_encoding, filename);
if (!s) {
s = filename;
@@ -1200,7 +1189,7 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler) /* {{{ */
{
/* store temp_filename as-is (in case upload_tmp_dir
- * contains escapeable characters. escape only the variable name.) */
+ * contains escapable characters. escape only the variable name.) */
zval zfilename;
/* Initialize variables */
diff --git a/main/rfc1867.h b/main/rfc1867.h
index bfb9bb51c6..2fb396b40c 100644
--- a/main/rfc1867.h
+++ b/main/rfc1867.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/main/snprintf.c b/main/snprintf.c
index 61a5dfffce..581cac1d3b 100644
--- a/main/snprintf.c
+++ b/main/snprintf.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -29,10 +27,7 @@
#include <string.h>
#include <stdlib.h>
#include <math.h>
-
-#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
-#endif
#include <locale.h>
#ifdef ZTS
@@ -714,25 +709,6 @@ static int format_converter(register buffy * odp, const char *fmt, va_list ap) /
fmt++;
modifier = LM_LONG_DOUBLE;
break;
- case 'I':
- fmt++;
-#if SIZEOF_LONG_LONG
- if (*fmt == '6' && *(fmt+1) == '4') {
- fmt += 2;
- modifier = LM_LONG_LONG;
- } else
-#endif
- if (*fmt == '3' && *(fmt+1) == '2') {
- fmt += 2;
- modifier = LM_LONG;
- } else {
-#ifdef _WIN64
- modifier = LM_LONG_LONG;
-#else
- modifier = LM_LONG;
-#endif
- }
- break;
case 'l':
fmt++;
#if SIZEOF_LONG_LONG
@@ -982,7 +958,6 @@ static int format_converter(register buffy * odp, const char *fmt, va_list ap) /
case 's':
- case 'v':
s = va_arg(ap, char *);
if (s != NULL) {
s_len = strlen(s);
diff --git a/main/snprintf.h b/main/snprintf.h
index 93d2034bb6..8a36562127 100644
--- a/main/snprintf.h
+++ b/main/snprintf.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/main/spprintf.c b/main/spprintf.c
index a20705016a..768a27470c 100644
--- a/main/spprintf.c
+++ b/main/spprintf.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -85,9 +83,7 @@
#include <string.h>
#include <stdlib.h>
#include <math.h>
-#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
-#endif
#include <locale.h>
#ifdef ZTS
@@ -314,25 +310,6 @@ static void xbuf_format_converter(void *xbuf, zend_bool is_char, const char *fmt
fmt++;
modifier = LM_LONG_DOUBLE;
break;
- case 'I':
- fmt++;
-#if SIZEOF_LONG_LONG
- if (*fmt == '6' && *(fmt+1) == '4') {
- fmt += 2;
- modifier = LM_LONG_LONG;
- } else
-#endif
- if (*fmt == '3' && *(fmt+1) == '2') {
- fmt += 2;
- modifier = LM_LONG;
- } else {
-#ifdef _WIN64
- modifier = LM_LONG_LONG;
-#else
- modifier = LM_LONG;
-#endif
- }
- break;
case 'l':
fmt++;
#if SIZEOF_LONG_LONG
@@ -589,7 +566,6 @@ static void xbuf_format_converter(void *xbuf, zend_bool is_char, const char *fmt
case 's':
- case 'v':
s = va_arg(ap, char *);
if (s != NULL) {
if (!adjust_precision) {
diff --git a/main/spprintf.h b/main/spprintf.h
index bbb7add25c..afb3b505b8 100644
--- a/main/spprintf.h
+++ b/main/spprintf.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/main/streams/cast.c b/main/streams/cast.c
index 73421a7588..9e689e9d6c 100644
--- a/main/streams/cast.c
+++ b/main/streams/cast.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -295,7 +293,7 @@ PHPAPI int _php_stream_cast(php_stream *stream, int castas, void **ret, int show
}
if (php_stream_is_filtered(stream)) {
- php_error_docref(NULL, E_WARNING, "cannot cast a filtered stream on this system");
+ php_error_docref(NULL, E_WARNING, "Cannot cast a filtered stream on this system");
return FAILURE;
} else if (stream->ops->cast && stream->ops->cast(stream, castas, ret) == SUCCESS) {
goto exit_success;
@@ -310,7 +308,7 @@ PHPAPI int _php_stream_cast(php_stream *stream, int castas, void **ret, int show
"select()able descriptor"
};
- php_error_docref(NULL, E_WARNING, "cannot represent a stream of type %s as a %s", stream->ops->label, cast_names[castas]);
+ php_error_docref(NULL, E_WARNING, "Cannot represent a stream of type %s as a %s", stream->ops->label, cast_names[castas]);
}
return FAILURE;
diff --git a/main/streams/filter.c b/main/streams/filter.c
index f536b92a02..e14925c1d7 100644
--- a/main/streams/filter.c
+++ b/main/streams/filter.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -255,9 +253,9 @@ PHPAPI php_stream_filter *php_stream_filter_create(const char *filtername, zval
if (filter == NULL) {
/* TODO: these need correct docrefs */
if (factory == NULL)
- php_error_docref(NULL, E_WARNING, "unable to locate filter \"%s\"", filtername);
+ php_error_docref(NULL, E_WARNING, "Unable to locate filter \"%s\"", filtername);
else
- php_error_docref(NULL, E_WARNING, "unable to create or locate filter \"%s\"", filtername);
+ php_error_docref(NULL, E_WARNING, "Unable to create or locate filter \"%s\"", filtername);
}
return filter;
diff --git a/main/streams/glob_wrapper.c b/main/streams/glob_wrapper.c
index 0e72558a2a..212d905e16 100644
--- a/main/streams/glob_wrapper.c
+++ b/main/streams/glob_wrapper.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/main/streams/memory.c b/main/streams/memory.c
index 4b92fc2ffd..0def3b1a3d 100644
--- a/main/streams/memory.c
+++ b/main/streams/memory.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -256,9 +254,9 @@ static int php_stream_memory_set_option(php_stream *stream, int option, int valu
ms->fsize = newsize;
return PHP_STREAM_OPTION_RETURN_OK;
}
- default:
- return PHP_STREAM_OPTION_RETURN_NOTIMPL;
}
+
+ return PHP_STREAM_OPTION_RETURN_NOTIMPL;
}
/* }}} */
@@ -317,7 +315,7 @@ PHPAPI php_stream *_php_stream_memory_create(int mode STREAMS_DC)
/* {{{ */
-PHPAPI php_stream *_php_stream_memory_open(int mode, char *buf, size_t length STREAMS_DC)
+PHPAPI php_stream *_php_stream_memory_open(int mode, const char *buf, size_t length STREAMS_DC)
{
php_stream *stream;
php_stream_memory_data *ms;
@@ -327,7 +325,7 @@ PHPAPI php_stream *_php_stream_memory_open(int mode, char *buf, size_t length ST
if (mode == TEMP_STREAM_READONLY || mode == TEMP_STREAM_TAKE_BUFFER) {
/* use the buffer directly */
- ms->data = buf;
+ ms->data = (char *) buf;
ms->fsize = length;
} else {
if (length) {
@@ -600,7 +598,7 @@ PHPAPI php_stream *_php_stream_temp_create(int mode, size_t max_memory_usage STR
/* }}} */
/* {{{ _php_stream_temp_open */
-PHPAPI php_stream *_php_stream_temp_open(int mode, size_t max_memory_usage, char *buf, size_t length STREAMS_DC)
+PHPAPI php_stream *_php_stream_temp_open(int mode, size_t max_memory_usage, const char *buf, size_t length STREAMS_DC)
{
php_stream *stream;
php_stream_temp_data *ts;
@@ -621,7 +619,7 @@ PHPAPI php_stream *_php_stream_temp_open(int mode, size_t max_memory_usage, char
/* }}} */
PHPAPI const php_stream_ops php_stream_rfc2397_ops = {
- php_stream_temp_write, php_stream_temp_read,
+ NULL, php_stream_temp_read,
php_stream_temp_close, php_stream_temp_flush,
"RFC2397",
php_stream_temp_seek,
diff --git a/main/streams/mmap.c b/main/streams/mmap.c
index 63bae87505..c99c63f065 100644
--- a/main/streams/mmap.c
+++ b/main/streams/mmap.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/main/streams/php_stream_context.h b/main/streams/php_stream_context.h
index c477dda4ac..29c9ae28a6 100644
--- a/main/streams/php_stream_context.h
+++ b/main/streams/php_stream_context.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -102,7 +100,7 @@ END_EXTERN_C()
(context)->notifier->mask |= PHP_STREAM_NOTIFIER_PROGRESS; \
php_stream_notify_progress((context), (sofar), (bmax)); } } while (0)
-#define php_stream_notify_progress_increment(context, dsofar, dmax) do { if ((context) && (context)->notifier && (context)->notifier->mask & PHP_STREAM_NOTIFIER_PROGRESS) { \
+#define php_stream_notify_progress_increment(context, dsofar, dmax) do { if ((context) && (context)->notifier && ((context)->notifier->mask & PHP_STREAM_NOTIFIER_PROGRESS)) { \
(context)->notifier->progress += (dsofar); \
(context)->notifier->progress_max += (dmax); \
php_stream_notify_progress((context), (context)->notifier->progress, (context)->notifier->progress_max); } } while (0)
diff --git a/main/streams/php_stream_filter_api.h b/main/streams/php_stream_filter_api.h
index 4d5760e2cf..9df312152a 100644
--- a/main/streams/php_stream_filter_api.h
+++ b/main/streams/php_stream_filter_api.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/main/streams/php_stream_glob_wrapper.h b/main/streams/php_stream_glob_wrapper.h
index 644e5ab7e4..f4c8e05b7e 100644
--- a/main/streams/php_stream_glob_wrapper.h
+++ b/main/streams/php_stream_glob_wrapper.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/main/streams/php_stream_mmap.h b/main/streams/php_stream_mmap.h
index 40288cc27f..3fda788f19 100644
--- a/main/streams/php_stream_mmap.h
+++ b/main/streams/php_stream_mmap.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/main/streams/php_stream_plain_wrapper.h b/main/streams/php_stream_plain_wrapper.h
index 4af8b86cdd..44910bf320 100644
--- a/main/streams/php_stream_plain_wrapper.h
+++ b/main/streams/php_stream_plain_wrapper.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/main/streams/php_stream_transport.h b/main/streams/php_stream_transport.h
index f49d9c787d..69d2b9a774 100644
--- a/main/streams/php_stream_transport.h
+++ b/main/streams/php_stream_transport.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/main/streams/php_stream_userspace.h b/main/streams/php_stream_userspace.h
index 389d591921..4171a0d953 100644
--- a/main/streams/php_stream_userspace.h
+++ b/main/streams/php_stream_userspace.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/main/streams/php_streams_int.h b/main/streams/php_streams_int.h
index 1bc6fdc89c..ab00549a6e 100644
--- a/main/streams/php_streams_int.h
+++ b/main/streams/php_streams_int.h
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
diff --git a/main/streams/plain_wrapper.c b/main/streams/plain_wrapper.c
index 8bd20969f9..8a891ddf72 100644
--- a/main/streams/plain_wrapper.c
+++ b/main/streams/plain_wrapper.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -135,11 +133,11 @@ typedef struct {
int lock_flag; /* stores the lock state */
zend_string *temp_name; /* if non-null, this is the path to a temporary file that
* is to be deleted when the stream is closed */
-#if HAVE_FLUSHIO
+#ifdef HAVE_FLUSHIO
char last_op;
#endif
-#if HAVE_MMAP
+#ifdef HAVE_MMAP
char *last_mapped_addr;
size_t last_mapped_len;
#endif
@@ -233,7 +231,7 @@ PHPAPI php_stream *_php_stream_fopen_temporary_file(const char *dir, const char
}
close(fd);
- php_error_docref(NULL, E_WARNING, "unable to allocate stream");
+ php_error_docref(NULL, E_WARNING, "Unable to allocate stream");
return NULL;
}
@@ -259,6 +257,11 @@ static void detect_is_seekable(php_stdio_stream_data *self) {
self->is_seekable = !(file_type == FILE_TYPE_PIPE || file_type == FILE_TYPE_CHAR);
self->is_pipe = file_type == FILE_TYPE_PIPE;
+
+ /* Additional check needed to distinguish between pipes and sockets. */
+ if (self->is_pipe && !GetNamedPipeInfo((HANDLE) handle, NULL, NULL, NULL, NULL)) {
+ self->is_pipe = 0;
+ }
}
#endif
}
@@ -355,12 +358,12 @@ static ssize_t php_stdiop_write(php_stream *stream, const char *buf, size_t coun
/* TODO: Should this be treated as a proper error or not? */
return bytes_written;
}
- php_error_docref(NULL, E_NOTICE, "write of %zu bytes failed with errno=%d %s", count, errno, strerror(errno));
+ php_error_docref(NULL, E_NOTICE, "Write of %zu bytes failed with errno=%d %s", count, errno, strerror(errno));
}
return bytes_written;
} else {
-#if HAVE_FLUSHIO
+#ifdef HAVE_FLUSHIO
if (data->is_seekable && data->last_op == 'r') {
zend_fseek(data->file, 0, SEEK_CUR);
}
@@ -394,7 +397,7 @@ static ssize_t php_stdiop_read(php_stream *stream, char *buf, size_t count)
if (!PeekNamedPipe(ph, NULL, 0, NULL, &avail_read, NULL)) {
break;
}
- /* If there's nothing to read, wait in 10ms periods. */
+ /* If there's nothing to read, wait in 10us periods. */
if (0 == avail_read) {
usleep(10);
}
@@ -423,7 +426,7 @@ static ssize_t php_stdiop_read(php_stream *stream, char *buf, size_t count)
} else if (errno == EINTR) {
/* TODO: Should this be treated as a proper error or not? */
} else {
- php_error_docref(NULL, E_NOTICE, "read of %zu bytes failed with errno=%d %s", count, errno, strerror(errno));
+ php_error_docref(NULL, E_NOTICE, "Read of %zu bytes failed with errno=%d %s", count, errno, strerror(errno));
/* TODO: Remove this special-case? */
if (errno != EBADF) {
@@ -435,7 +438,7 @@ static ssize_t php_stdiop_read(php_stream *stream, char *buf, size_t count)
}
} else {
-#if HAVE_FLUSHIO
+#ifdef HAVE_FLUSHIO
if (data->is_seekable && data->last_op == 'w')
zend_fseek(data->file, 0, SEEK_CUR);
data->last_op = 'r';
@@ -455,7 +458,7 @@ static int php_stdiop_close(php_stream *stream, int close_handle)
assert(data != NULL);
-#if HAVE_MMAP
+#ifdef HAVE_MMAP
if (data->last_mapped_addr) {
munmap(data->last_mapped_addr, data->last_mapped_len);
data->last_mapped_addr = NULL;
@@ -477,7 +480,7 @@ static int php_stdiop_close(php_stream *stream, int close_handle)
errno = 0;
ret = pclose(data->file);
-#if HAVE_SYS_WAIT_H
+#ifdef HAVE_SYS_WAIT_H
if (WIFEXITED(ret)) {
ret = WEXITSTATUS(ret);
}
@@ -538,7 +541,7 @@ static int php_stdiop_seek(php_stream *stream, zend_off_t offset, int whence, ze
assert(data != NULL);
if (!data->is_seekable) {
- php_error_docref(NULL, E_WARNING, "cannot seek on this stream");
+ php_error_docref(NULL, E_WARNING, "Cannot seek on this stream");
return -1;
}
@@ -706,7 +709,7 @@ static int php_stdiop_set_option(php_stream *stream, int option, int value, void
break;
case PHP_STREAM_OPTION_MMAP_API:
-#if HAVE_MMAP
+#ifdef HAVE_MMAP
{
php_stream_mmap_range *range = (php_stream_mmap_range*)ptrparam;
int prot, flags;
@@ -901,7 +904,7 @@ static int php_stdiop_set_option(php_stream *stream, int option, int value, void
return PHP_STREAM_OPTION_RETURN_ERR;
}
-#if defined(_WIN64)
+#ifdef _WIN64
sz.QuadPart = new_size;
#else
sz.HighPart = 0;
@@ -922,6 +925,7 @@ static int php_stdiop_set_option(php_stream *stream, int option, int value, void
#endif
}
}
+ return PHP_STREAM_OPTION_RETURN_NOTIMPL;
#ifdef PHP_WIN32
case PHP_STREAM_OPTION_PIPE_BLOCKING:
@@ -1243,7 +1247,7 @@ static int php_plain_files_rename(php_stream_wrapper *wrapper, const char *url_f
if (php_copy_file(url_from, url_to) == SUCCESS) {
if (VCWD_STAT(url_from, &sb) == 0) {
success = 1;
-# if !defined(TSRM_WIN32)
+# ifndef TSRM_WIN32
/*
* Try to set user and permission info on the target.
* If we're not root, then some of these may fail.
@@ -1310,7 +1314,7 @@ static int php_plain_files_mkdir(php_stream_wrapper *wrapper, const char *dir, i
if (!recursive) {
ret = php_mkdir(dir, mode);
} else {
- /* we look for directory separator from the end of string, thus hopefuly reducing our work load */
+ /* we look for directory separator from the end of string, thus hopefully reducing our work load */
char *e;
zend_stat_t sb;
size_t dir_len = strlen(dir), offset = 0;
@@ -1481,7 +1485,7 @@ static int php_plain_files_metadata(php_stream_wrapper *wrapper, const char *url
ret = VCWD_CHMOD(url, mode);
break;
default:
- php_error_docref1(NULL, url, E_WARNING, "Unknown option %d for stream_metadata", option);
+ zend_value_error("Unknown option %d for stream_metadata", option);
return 0;
}
if (ret == -1) {
diff --git a/main/streams/streams.c b/main/streams/streams.c
index cf411a1dd3..1262c874f7 100644
--- a/main/streams/streams.c
+++ b/main/streams/streams.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -26,7 +24,7 @@
#include "php_network.h"
#include "php_open_temporary_file.h"
#include "ext/standard/file.h"
-#include "ext/standard/basic_functions.h" /* for BG(mmap_file) (not strictly required) */
+#include "ext/standard/basic_functions.h" /* for BG(CurrentStatFile) */
#include "ext/standard/php_string.h" /* for php_memnstr, used by php_stream_get_record() */
#include <stddef.h>
#include <fcntl.h>
@@ -247,7 +245,7 @@ PHPAPI void php_stream_wrapper_log_error(const php_stream_wrapper *wrapper, int
vspprintf(&buffer, 0, fmt, args);
va_end(args);
- if (options & REPORT_ERRORS || wrapper == NULL) {
+ if ((options & REPORT_ERRORS) || wrapper == NULL) {
php_error_docref(NULL, E_WARNING, "%s", buffer);
efree(buffer);
} else {
@@ -705,7 +703,7 @@ PHPAPI ssize_t _php_stream_read(php_stream *stream, char *buf, size_t size)
break;
}
- if (!stream->readfilters.head && (stream->flags & PHP_STREAM_FLAG_NO_BUFFER || stream->chunk_size == 1)) {
+ if (!stream->readfilters.head && ((stream->flags & PHP_STREAM_FLAG_NO_BUFFER) || stream->chunk_size == 1)) {
toread = stream->ops->read(stream, buf, size);
if (toread < 0) {
/* Report an error if the read failed and we did not read any data
@@ -1120,7 +1118,7 @@ PHPAPI zend_string *php_stream_get_record(php_stream *stream, size_t maxlen, con
/* Writes a buffer directly to a stream, using multiple of the chunk size */
static ssize_t _php_stream_write_buffer(php_stream *stream, const char *buf, size_t count)
{
- ssize_t didwrite = 0, justwrote;
+ ssize_t didwrite = 0;
/* if we have a seekable stream we need to ensure that data is written at the
* current stream->position. This means invalidating the read buffer and then
@@ -1131,13 +1129,8 @@ static ssize_t _php_stream_write_buffer(php_stream *stream, const char *buf, siz
stream->ops->seek(stream, stream->position, SEEK_SET, &stream->position);
}
-
while (count > 0) {
- size_t towrite = count;
- if (towrite > stream->chunk_size)
- towrite = stream->chunk_size;
-
- justwrote = stream->ops->write(stream, buf, towrite);
+ ssize_t justwrote = stream->ops->write(stream, buf, count);
if (justwrote <= 0) {
/* If we already successfully wrote some bytes and a write error occurred
* later, report the successfully written bytes. */
@@ -1373,7 +1366,7 @@ PHPAPI int _php_stream_seek(php_stream *stream, zend_off_t offset, int whence)
return 0;
}
- php_error_docref(NULL, E_WARNING, "stream does not support seeking");
+ php_error_docref(NULL, E_WARNING, "Stream does not support seeking");
return -1;
}
@@ -1881,7 +1874,7 @@ PHPAPI php_stream_wrapper *php_stream_locate_url_wrapper(const char *path, const
if (localhost == 0 && path[n+3] != '\0' && path[n+3] != '/') {
#endif
if (options & REPORT_ERRORS) {
- php_error_docref(NULL, E_WARNING, "remote host file access not supported, %s", path);
+ php_error_docref(NULL, E_WARNING, "Remote host file access not supported, %s", path);
}
return NULL;
}
@@ -1948,8 +1941,7 @@ PHPAPI php_stream_wrapper *php_stream_locate_url_wrapper(const char *path, const
}
/* }}} */
-/* {{{ _php_stream_mkdir
- */
+/* {{{ _php_stream_mkdir */
PHPAPI int _php_stream_mkdir(const char *path, int mode, int options, php_stream_context *context)
{
php_stream_wrapper *wrapper = NULL;
@@ -1963,8 +1955,7 @@ PHPAPI int _php_stream_mkdir(const char *path, int mode, int options, php_stream
}
/* }}} */
-/* {{{ _php_stream_rmdir
- */
+/* {{{ _php_stream_rmdir */
PHPAPI int _php_stream_rmdir(const char *path, int options, php_stream_context *context)
{
php_stream_wrapper *wrapper = NULL;
@@ -2047,7 +2038,7 @@ PHPAPI php_stream *_php_stream_opendir(const char *path, int options,
if (wrapper && wrapper->wops->dir_opener) {
stream = wrapper->wops->dir_opener(wrapper,
- path_to_open, "r", options ^ REPORT_ERRORS, NULL,
+ path_to_open, "r", options & ~REPORT_ERRORS, NULL,
context STREAMS_REL_CC);
if (stream) {
@@ -2055,10 +2046,10 @@ PHPAPI php_stream *_php_stream_opendir(const char *path, int options,
stream->flags |= PHP_STREAM_FLAG_NO_BUFFER | PHP_STREAM_FLAG_IS_DIR;
}
} else if (wrapper) {
- php_stream_wrapper_log_error(wrapper, options ^ REPORT_ERRORS, "not implemented");
+ php_stream_wrapper_log_error(wrapper, options & ~REPORT_ERRORS, "not implemented");
}
if (stream == NULL && (options & REPORT_ERRORS)) {
- php_stream_display_wrapper_errors(wrapper, path, "failed to open dir");
+ php_stream_display_wrapper_errors(wrapper, path, "Failed to open directory");
}
php_stream_tidy_wrapper_error_log(wrapper);
@@ -2094,7 +2085,7 @@ PHPAPI php_stream *_php_stream_open_wrapper_ex(const char *path, const char *mod
}
if (!path || !*path) {
- php_error_docref(NULL, E_WARNING, "Filename cannot be empty");
+ zend_value_error("Path cannot be empty");
return NULL;
}
@@ -2114,7 +2105,7 @@ PHPAPI php_stream *_php_stream_open_wrapper_ex(const char *path, const char *mod
path_to_open = path;
wrapper = php_stream_locate_url_wrapper(path, &path_to_open, options);
- if (options & STREAM_USE_URL && (!wrapper || !wrapper->is_url)) {
+ if ((options & STREAM_USE_URL) && (!wrapper || !wrapper->is_url)) {
php_error_docref(NULL, E_WARNING, "This function may only be used against URLs");
if (resolved_path) {
zend_string_release_ex(resolved_path, 0);
@@ -2124,18 +2115,18 @@ PHPAPI php_stream *_php_stream_open_wrapper_ex(const char *path, const char *mod
if (wrapper) {
if (!wrapper->wops->stream_opener) {
- php_stream_wrapper_log_error(wrapper, options ^ REPORT_ERRORS,
+ php_stream_wrapper_log_error(wrapper, options & ~REPORT_ERRORS,
"wrapper does not support stream open");
} else {
stream = wrapper->wops->stream_opener(wrapper,
- path_to_open, mode, options ^ REPORT_ERRORS,
+ path_to_open, mode, options & ~REPORT_ERRORS,
opened_path, context STREAMS_REL_CC);
}
/* if the caller asked for a persistent stream but the wrapper did not
* return one, force an error here */
if (stream && (options & STREAM_OPEN_PERSISTENT) && !stream->is_persistent) {
- php_stream_wrapper_log_error(wrapper, options ^ REPORT_ERRORS,
+ php_stream_wrapper_log_error(wrapper, options & ~REPORT_ERRORS,
"wrapper does not support persistent streams");
php_stream_close(stream);
stream = NULL;
@@ -2192,7 +2183,7 @@ PHPAPI php_stream *_php_stream_open_wrapper_ex(const char *path, const char *mod
tmp);
efree(tmp);
- options ^= REPORT_ERRORS;
+ options &= ~REPORT_ERRORS;
}
}
}
@@ -2207,7 +2198,7 @@ PHPAPI php_stream *_php_stream_open_wrapper_ex(const char *path, const char *mod
}
if (stream == NULL && (options & REPORT_ERRORS)) {
- php_stream_display_wrapper_errors(wrapper, path, "failed to open stream");
+ php_stream_display_wrapper_errors(wrapper, path, "Failed to open stream");
if (opened_path && *opened_path) {
zend_string_release_ex(*opened_path, 0);
*opened_path = NULL;
@@ -2320,24 +2311,21 @@ PHPAPI int php_stream_context_set_option(php_stream_context *context,
}
/* }}} */
-/* {{{ php_stream_dirent_alphasort
- */
+/* {{{ php_stream_dirent_alphasort */
PHPAPI int php_stream_dirent_alphasort(const zend_string **a, const zend_string **b)
{
return strcoll(ZSTR_VAL(*a), ZSTR_VAL(*b));
}
/* }}} */
-/* {{{ php_stream_dirent_alphasortr
- */
+/* {{{ php_stream_dirent_alphasortr */
PHPAPI int php_stream_dirent_alphasortr(const zend_string **a, const zend_string **b)
{
return strcoll(ZSTR_VAL(*b), ZSTR_VAL(*a));
}
/* }}} */
-/* {{{ php_stream_scandir
- */
+/* {{{ php_stream_scandir */
PHPAPI int _php_stream_scandir(const char *dirname, zend_string **namelist[], int flags, php_stream_context *context,
int (*compare) (const zend_string **a, const zend_string **b))
{
diff --git a/main/streams/transports.c b/main/streams/transports.c
index 74fbef58d8..fcc3f29330 100644
--- a/main/streams/transports.c
+++ b/main/streams/transports.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -359,7 +357,7 @@ PHPAPI int php_stream_xport_crypto_setup(php_stream *stream, php_stream_xport_cr
return param.outputs.returncode;
}
- php_error_docref("streams.crypto", E_WARNING, "this stream does not support SSL/crypto");
+ php_error_docref("streams.crypto", E_WARNING, "This stream does not support SSL/crypto");
return ret;
}
@@ -379,7 +377,7 @@ PHPAPI int php_stream_xport_crypto_enable(php_stream *stream, int activate)
return param.outputs.returncode;
}
- php_error_docref("streams.crypto", E_WARNING, "this stream does not support SSL/crypto");
+ php_error_docref("streams.crypto", E_WARNING, "This stream does not support SSL/crypto");
return ret;
}
@@ -401,7 +399,7 @@ PHPAPI int php_stream_xport_recvfrom(php_stream *stream, char *buf, size_t bufle
}
if (stream->readfilters.head) {
- php_error_docref(NULL, E_WARNING, "cannot peek or fetch OOB data from a filtered stream");
+ php_error_docref(NULL, E_WARNING, "Cannot peek or fetch OOB data from a filtered stream");
return -1;
}
@@ -471,7 +469,7 @@ PHPAPI int php_stream_xport_sendto(php_stream *stream, const char *buf, size_t b
oob = (flags & STREAM_OOB) == STREAM_OOB;
if ((oob || addr) && stream->writefilters.head) {
- php_error_docref(NULL, E_WARNING, "cannot write OOB data, or data to a targeted address on a filtered stream");
+ php_error_docref(NULL, E_WARNING, "Cannot write OOB data, or data to a targeted address on a filtered stream");
return -1;
}
diff --git a/main/streams/userspace.c b/main/streams/userspace.c
index cf8f59b756..0e9059a99e 100644
--- a/main/streams/userspace.c
+++ b/main/streams/userspace.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -38,7 +36,6 @@ static int le_protocols;
struct php_user_stream_wrapper {
char * protoname;
- char * classname;
zend_class_entry *ce;
php_stream_wrapper wrapper;
};
@@ -73,7 +70,6 @@ static void stream_wrapper_dtor(zend_resource *rsrc)
struct php_user_stream_wrapper * uwrap = (struct php_user_stream_wrapper*)rsrc->ptr;
efree(uwrap->protoname);
- efree(uwrap->classname);
efree(uwrap);
}
@@ -300,29 +296,8 @@ static void user_stream_create_object(struct php_user_stream_wrapper *uwrap, php
}
if (uwrap->ce->constructor) {
- zend_fcall_info fci;
- zend_fcall_info_cache fcc;
- zval retval;
-
- fci.size = sizeof(fci);
- ZVAL_UNDEF(&fci.function_name);
- fci.object = Z_OBJ_P(object);
- fci.retval = &retval;
- fci.param_count = 0;
- fci.params = NULL;
- fci.no_separation = 1;
-
- fcc.function_handler = uwrap->ce->constructor;
- fcc.called_scope = Z_OBJCE_P(object);
- fcc.object = Z_OBJ_P(object);
-
- if (zend_call_function(&fci, &fcc) == FAILURE) {
- php_error_docref(NULL, E_WARNING, "Could not execute %s::%s()", ZSTR_VAL(uwrap->ce->name), ZSTR_VAL(uwrap->ce->constructor->common.function_name));
- zval_ptr_dtor(object);
- ZVAL_UNDEF(object);
- } else {
- zval_ptr_dtor(&retval);
- }
+ zend_call_known_instance_method_with_0_params(
+ uwrap->ce->constructor, Z_OBJ_P(object), NULL);
}
}
@@ -375,12 +350,11 @@ static php_stream *user_wrapper_opener(php_stream_wrapper *wrapper, const char *
ZVAL_STRING(&zfuncname, USERSTREAM_OPEN);
zend_try {
- call_result = call_user_function_ex(NULL,
+ call_result = call_user_function(NULL,
Z_ISUNDEF(us->object)? NULL : &us->object,
&zfuncname,
&zretval,
- 4, args,
- 0, NULL );
+ 4, args);
} zend_catch {
FG(user_stream_current_filename) = NULL;
zend_bailout();
@@ -399,7 +373,7 @@ static php_stream *user_wrapper_opener(php_stream_wrapper *wrapper, const char *
ZVAL_COPY(&stream->wrapperdata, &us->object);
} else {
php_stream_wrapper_log_error(wrapper, options, "\"%s::" USERSTREAM_OPEN "\" call failed",
- us->wrapper->classname);
+ ZSTR_VAL(us->wrapper->ce->name));
}
/* destroy everything else */
@@ -454,12 +428,11 @@ static php_stream *user_wrapper_opendir(php_stream_wrapper *wrapper, const char
ZVAL_STRING(&zfuncname, USERSTREAM_DIR_OPEN);
- call_result = call_user_function_ex(NULL,
+ call_result = call_user_function(NULL,
Z_ISUNDEF(us->object)? NULL : &us->object,
&zfuncname,
&zretval,
- 2, args,
- 0, NULL );
+ 2, args);
if (call_result == SUCCESS && Z_TYPE(zretval) != IS_UNDEF && zval_is_true(&zretval)) {
/* the stream is now open! */
@@ -469,7 +442,7 @@ static php_stream *user_wrapper_opendir(php_stream_wrapper *wrapper, const char
ZVAL_COPY(&stream->wrapperdata, &us->object);
} else {
php_stream_wrapper_log_error(wrapper, options, "\"%s::" USERSTREAM_DIR_OPEN "\" call failed",
- us->wrapper->classname);
+ ZSTR_VAL(us->wrapper->ce->name));
}
/* destroy everything else */
@@ -490,42 +463,38 @@ static php_stream *user_wrapper_opendir(php_stream_wrapper *wrapper, const char
}
-/* {{{ proto bool stream_wrapper_register(string protocol, string classname[, int flags])
- Registers a custom URL protocol handler class */
+/* {{{ Registers a custom URL protocol handler class */
PHP_FUNCTION(stream_wrapper_register)
{
- zend_string *protocol, *classname;
- struct php_user_stream_wrapper * uwrap;
+ zend_string *protocol;
+ struct php_user_stream_wrapper *uwrap;
+ zend_class_entry *ce = NULL;
zend_resource *rsrc;
zend_long flags = 0;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "SS|l", &protocol, &classname, &flags) == FAILURE) {
- RETURN_FALSE;
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "SC|l", &protocol, &ce, &flags) == FAILURE) {
+ RETURN_THROWS();
}
uwrap = (struct php_user_stream_wrapper *)ecalloc(1, sizeof(*uwrap));
+ uwrap->ce = ce;
uwrap->protoname = estrndup(ZSTR_VAL(protocol), ZSTR_LEN(protocol));
- uwrap->classname = estrndup(ZSTR_VAL(classname), ZSTR_LEN(classname));
uwrap->wrapper.wops = &user_stream_wops;
uwrap->wrapper.abstract = uwrap;
uwrap->wrapper.is_url = ((flags & PHP_STREAM_IS_URL) != 0);
rsrc = zend_register_resource(uwrap, le_protocols);
- if ((uwrap->ce = zend_lookup_class(classname)) != NULL) {
- if (php_register_url_stream_wrapper_volatile(protocol, &uwrap->wrapper) == SUCCESS) {
- RETURN_TRUE;
- } else {
- /* We failed. But why? */
- if (zend_hash_exists(php_stream_get_url_stream_wrappers_hash(), protocol)) {
- php_error_docref(NULL, E_WARNING, "Protocol %s:// is already defined.", ZSTR_VAL(protocol));
- } else {
- /* Hash doesn't exist so it must have been an invalid protocol scheme */
- php_error_docref(NULL, E_WARNING, "Invalid protocol scheme specified. Unable to register wrapper class %s to %s://", ZSTR_VAL(classname), ZSTR_VAL(protocol));
- }
- }
+ if (php_register_url_stream_wrapper_volatile(protocol, &uwrap->wrapper) == SUCCESS) {
+ RETURN_TRUE;
+ }
+
+ /* We failed. But why? */
+ if (zend_hash_exists(php_stream_get_url_stream_wrappers_hash(), protocol)) {
+ php_error_docref(NULL, E_WARNING, "Protocol %s:// is already defined.", ZSTR_VAL(protocol));
} else {
- php_error_docref(NULL, E_WARNING, "class '%s' is undefined", ZSTR_VAL(classname));
+ /* Hash doesn't exist so it must have been an invalid protocol scheme */
+ php_error_docref(NULL, E_WARNING, "Invalid protocol scheme specified. Unable to register wrapper class %s to %s://", ZSTR_VAL(uwrap->ce->name), ZSTR_VAL(protocol));
}
zend_list_delete(rsrc);
@@ -533,14 +502,13 @@ PHP_FUNCTION(stream_wrapper_register)
}
/* }}} */
-/* {{{ proto bool stream_wrapper_unregister(string protocol)
- Unregister a wrapper for the life of the current request. */
+/* {{{ Unregister a wrapper for the life of the current request. */
PHP_FUNCTION(stream_wrapper_unregister)
{
zend_string *protocol;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &protocol) == FAILURE) {
- RETURN_FALSE;
+ RETURN_THROWS();
}
if (php_unregister_url_stream_wrapper_volatile(protocol) == FAILURE) {
@@ -553,8 +521,7 @@ PHP_FUNCTION(stream_wrapper_unregister)
}
/* }}} */
-/* {{{ proto bool stream_wrapper_restore(string protocol)
- Restore the original protocol handler, overriding if necessary */
+/* {{{ Restore the original protocol handler, overriding if necessary */
PHP_FUNCTION(stream_wrapper_restore)
{
zend_string *protocol;
@@ -562,7 +529,7 @@ PHP_FUNCTION(stream_wrapper_restore)
HashTable *global_wrapper_hash, *wrapper_hash;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "S", &protocol) == FAILURE) {
- RETURN_FALSE;
+ RETURN_THROWS();
}
global_wrapper_hash = php_stream_get_url_stream_wrappers_hash_global();
@@ -604,12 +571,11 @@ static ssize_t php_userstreamop_write(php_stream *stream, const char *buf, size_
ZVAL_STRINGL(&args[0], (char*)buf, count);
- call_result = call_user_function_ex(NULL,
+ call_result = call_user_function(NULL,
Z_ISUNDEF(us->object)? NULL : &us->object,
&func_name,
&retval,
- 1, args,
- 0, NULL);
+ 1, args);
zval_ptr_dtor(&args[0]);
zval_ptr_dtor(&func_name);
@@ -626,14 +592,14 @@ static ssize_t php_userstreamop_write(php_stream *stream, const char *buf, size_
}
} else {
php_error_docref(NULL, E_WARNING, "%s::" USERSTREAM_WRITE " is not implemented!",
- us->wrapper->classname);
+ ZSTR_VAL(us->wrapper->ce->name));
didwrite = -1;
}
/* don't allow strange buffer overruns due to bogus return */
if (didwrite > 0 && didwrite > count) {
php_error_docref(NULL, E_WARNING, "%s::" USERSTREAM_WRITE " wrote " ZEND_LONG_FMT " bytes more data than requested (" ZEND_LONG_FMT " written, " ZEND_LONG_FMT " max)",
- us->wrapper->classname,
+ ZSTR_VAL(us->wrapper->ce->name),
(zend_long)(didwrite - count), (zend_long)didwrite, (zend_long)count);
didwrite = count;
}
@@ -658,12 +624,11 @@ static ssize_t php_userstreamop_read(php_stream *stream, char *buf, size_t count
ZVAL_LONG(&args[0], count);
- call_result = call_user_function_ex(NULL,
+ call_result = call_user_function(NULL,
Z_ISUNDEF(us->object)? NULL : &us->object,
&func_name,
&retval,
- 1, args,
- 0, NULL);
+ 1, args);
zval_ptr_dtor(&args[0]);
zval_ptr_dtor(&func_name);
@@ -674,7 +639,7 @@ static ssize_t php_userstreamop_read(php_stream *stream, char *buf, size_t count
if (call_result == FAILURE) {
php_error_docref(NULL, E_WARNING, "%s::" USERSTREAM_READ " is not implemented!",
- us->wrapper->classname);
+ ZSTR_VAL(us->wrapper->ce->name));
return -1;
}
@@ -690,7 +655,7 @@ static ssize_t php_userstreamop_read(php_stream *stream, char *buf, size_t count
if (didread > 0) {
if (didread > count) {
php_error_docref(NULL, E_WARNING, "%s::" USERSTREAM_READ " - read " ZEND_LONG_FMT " bytes more data than requested (" ZEND_LONG_FMT " read, " ZEND_LONG_FMT " max) - excess data will be lost",
- us->wrapper->classname, (zend_long)(didread - count), (zend_long)didread, (zend_long)count);
+ ZSTR_VAL(us->wrapper->ce->name), (zend_long)(didread - count), (zend_long)didread, (zend_long)count);
didread = count;
}
memcpy(buf, Z_STRVAL(retval), didread);
@@ -719,7 +684,7 @@ static ssize_t php_userstreamop_read(php_stream *stream, char *buf, size_t count
} else if (call_result == FAILURE) {
php_error_docref(NULL, E_WARNING,
"%s::" USERSTREAM_EOF " is not implemented! Assuming EOF",
- us->wrapper->classname);
+ ZSTR_VAL(us->wrapper->ce->name));
stream->eof = 1;
}
@@ -799,12 +764,11 @@ static int php_userstreamop_seek(php_stream *stream, zend_off_t offset, int when
ZVAL_LONG(&args[0], offset);
ZVAL_LONG(&args[1], whence);
- call_result = call_user_function_ex(NULL,
+ call_result = call_user_function(NULL,
Z_ISUNDEF(us->object)? NULL : &us->object,
&func_name,
&retval,
- 2, args,
- 0, NULL);
+ 2, args);
zval_ptr_dtor(&args[0]);
zval_ptr_dtor(&args[1]);
@@ -844,7 +808,7 @@ static int php_userstreamop_seek(php_stream *stream, zend_off_t offset, int when
*newoffs = Z_LVAL(retval);
ret = 0;
} else if (call_result == FAILURE) {
- php_error_docref(NULL, E_WARNING, "%s::" USERSTREAM_TELL " is not implemented!", us->wrapper->classname);
+ php_error_docref(NULL, E_WARNING, "%s::" USERSTREAM_TELL " is not implemented!", ZSTR_VAL(us->wrapper->ce->name));
ret = -1;
} else {
ret = -1;
@@ -916,7 +880,7 @@ static int php_userstreamop_stat(php_stream *stream, php_stream_statbuf *ssb)
} else {
if (call_result == FAILURE) {
php_error_docref(NULL, E_WARNING, "%s::" USERSTREAM_STAT " is not implemented!",
- us->wrapper->classname);
+ ZSTR_VAL(us->wrapper->ce->name));
}
}
@@ -945,7 +909,7 @@ static int php_userstreamop_set_option(php_stream *stream, int option, int value
ret = PHP_STREAM_OPTION_RETURN_ERR;
php_error_docref(NULL, E_WARNING,
"%s::" USERSTREAM_EOF " is not implemented! Assuming EOF",
- us->wrapper->classname);
+ ZSTR_VAL(us->wrapper->ce->name));
}
zval_ptr_dtor(&retval);
zval_ptr_dtor(&func_name);
@@ -972,11 +936,11 @@ static int php_userstreamop_set_option(php_stream *stream, int option, int value
/* TODO wouldblock */
ZVAL_STRINGL(&func_name, USERSTREAM_LOCK, sizeof(USERSTREAM_LOCK)-1);
- call_result = call_user_function_ex(NULL,
+ call_result = call_user_function(NULL,
Z_ISUNDEF(us->object)? NULL : &us->object,
&func_name,
&retval,
- 1, args, 0, NULL);
+ 1, args);
if (call_result == SUCCESS && (Z_TYPE(retval) == IS_FALSE || Z_TYPE(retval) == IS_TRUE)) {
ret = (Z_TYPE(retval) == IS_FALSE);
@@ -986,7 +950,7 @@ static int php_userstreamop_set_option(php_stream *stream, int option, int value
ret = PHP_STREAM_OPTION_RETURN_OK;
} else {
php_error_docref(NULL, E_WARNING, "%s::" USERSTREAM_LOCK " is not implemented!",
- us->wrapper->classname);
+ ZSTR_VAL(us->wrapper->ce->name));
ret = PHP_STREAM_OPTION_RETURN_ERR;
}
}
@@ -1003,7 +967,7 @@ static int php_userstreamop_set_option(php_stream *stream, int option, int value
case PHP_STREAM_TRUNCATE_SUPPORTED:
if (zend_is_callable_ex(&func_name,
Z_ISUNDEF(us->object)? NULL : Z_OBJ(us->object),
- IS_CALLABLE_CHECK_SILENT, NULL, NULL, NULL))
+ 0, NULL, NULL, NULL))
ret = PHP_STREAM_OPTION_RETURN_OK;
else
ret = PHP_STREAM_OPTION_RETURN_ERR;
@@ -1013,11 +977,11 @@ static int php_userstreamop_set_option(php_stream *stream, int option, int value
ptrdiff_t new_size = *(ptrdiff_t*) ptrparam;
if (new_size >= 0 && new_size <= (ptrdiff_t)LONG_MAX) {
ZVAL_LONG(&args[0], (zend_long)new_size);
- call_result = call_user_function_ex(NULL,
+ call_result = call_user_function(NULL,
Z_ISUNDEF(us->object)? NULL : &us->object,
&func_name,
&retval,
- 1, args, 0, NULL);
+ 1, args);
if (call_result == SUCCESS && Z_TYPE(retval) != IS_UNDEF) {
if (Z_TYPE(retval) == IS_FALSE || Z_TYPE(retval) == IS_TRUE) {
ret = (Z_TYPE(retval) == IS_TRUE) ? PHP_STREAM_OPTION_RETURN_OK :
@@ -1025,12 +989,12 @@ static int php_userstreamop_set_option(php_stream *stream, int option, int value
} else {
php_error_docref(NULL, E_WARNING,
"%s::" USERSTREAM_TRUNCATE " did not return a boolean!",
- us->wrapper->classname);
+ ZSTR_VAL(us->wrapper->ce->name));
}
} else {
php_error_docref(NULL, E_WARNING,
"%s::" USERSTREAM_TRUNCATE " is not implemented!",
- us->wrapper->classname);
+ ZSTR_VAL(us->wrapper->ce->name));
}
zval_ptr_dtor(&retval);
zval_ptr_dtor(&args[0]);
@@ -1077,15 +1041,15 @@ static int php_userstreamop_set_option(php_stream *stream, int option, int value
break;
}
- call_result = call_user_function_ex(NULL,
+ call_result = call_user_function(NULL,
Z_ISUNDEF(us->object)? NULL : &us->object,
&func_name,
&retval,
- 3, args, 0, NULL);
+ 3, args);
if (call_result == FAILURE) {
php_error_docref(NULL, E_WARNING, "%s::" USERSTREAM_SET_OPTION " is not implemented!",
- us->wrapper->classname);
+ ZSTR_VAL(us->wrapper->ce->name));
ret = PHP_STREAM_OPTION_RETURN_ERR;
} else if (zend_is_true(&retval)) {
ret = PHP_STREAM_OPTION_RETURN_OK;
@@ -1127,17 +1091,16 @@ static int user_wrapper_unlink(php_stream_wrapper *wrapper, const char *url, int
ZVAL_STRING(&zfuncname, USERSTREAM_UNLINK);
- call_result = call_user_function_ex(NULL,
+ call_result = call_user_function(NULL,
&object,
&zfuncname,
&zretval,
- 1, args,
- 0, NULL );
+ 1, args);
if (call_result == SUCCESS && (Z_TYPE(zretval) == IS_FALSE || Z_TYPE(zretval) == IS_TRUE)) {
ret = (Z_TYPE(zretval) == IS_TRUE);
} else if (call_result == FAILURE) {
- php_error_docref(NULL, E_WARNING, "%s::" USERSTREAM_UNLINK " is not implemented!", uwrap->classname);
+ php_error_docref(NULL, E_WARNING, "%s::" USERSTREAM_UNLINK " is not implemented!", ZSTR_VAL(uwrap->ce->name));
}
/* clean up */
@@ -1172,17 +1135,16 @@ static int user_wrapper_rename(php_stream_wrapper *wrapper, const char *url_from
ZVAL_STRING(&zfuncname, USERSTREAM_RENAME);
- call_result = call_user_function_ex(NULL,
+ call_result = call_user_function(NULL,
&object,
&zfuncname,
&zretval,
- 2, args,
- 0, NULL );
+ 2, args);
if (call_result == SUCCESS && (Z_TYPE(zretval) == IS_FALSE || Z_TYPE(zretval) == IS_TRUE)) {
ret = (Z_TYPE(zretval) == IS_TRUE);
} else if (call_result == FAILURE) {
- php_error_docref(NULL, E_WARNING, "%s::" USERSTREAM_RENAME " is not implemented!", uwrap->classname);
+ php_error_docref(NULL, E_WARNING, "%s::" USERSTREAM_RENAME " is not implemented!", ZSTR_VAL(uwrap->ce->name));
}
/* clean up */
@@ -1219,17 +1181,16 @@ static int user_wrapper_mkdir(php_stream_wrapper *wrapper, const char *url, int
ZVAL_STRING(&zfuncname, USERSTREAM_MKDIR);
- call_result = call_user_function_ex(NULL,
+ call_result = call_user_function(NULL,
&object,
&zfuncname,
&zretval,
- 3, args,
- 0, NULL );
+ 3, args);
if (call_result == SUCCESS && (Z_TYPE(zretval) == IS_FALSE || Z_TYPE(zretval) == IS_TRUE)) {
ret = (Z_TYPE(zretval) == IS_TRUE);
} else if (call_result == FAILURE) {
- php_error_docref(NULL, E_WARNING, "%s::" USERSTREAM_MKDIR " is not implemented!", uwrap->classname);
+ php_error_docref(NULL, E_WARNING, "%s::" USERSTREAM_MKDIR " is not implemented!", ZSTR_VAL(uwrap->ce->name));
}
/* clean up */
@@ -1266,17 +1227,16 @@ static int user_wrapper_rmdir(php_stream_wrapper *wrapper, const char *url,
ZVAL_STRING(&zfuncname, USERSTREAM_RMDIR);
- call_result = call_user_function_ex(NULL,
+ call_result = call_user_function(NULL,
&object,
&zfuncname,
&zretval,
- 2, args,
- 0, NULL );
+ 2, args);
if (call_result == SUCCESS && (Z_TYPE(zretval) == IS_FALSE || Z_TYPE(zretval) == IS_TRUE)) {
ret = (Z_TYPE(zretval) == IS_TRUE);
} else if (call_result == FAILURE) {
- php_error_docref(NULL, E_WARNING, "%s::" USERSTREAM_RMDIR " is not implemented!", uwrap->classname);
+ php_error_docref(NULL, E_WARNING, "%s::" USERSTREAM_RMDIR " is not implemented!", ZSTR_VAL(uwrap->ce->name));
}
/* clean up */
@@ -1337,17 +1297,16 @@ static int user_wrapper_metadata(php_stream_wrapper *wrapper, const char *url, i
ZVAL_STRING(&zfuncname, USERSTREAM_METADATA);
- call_result = call_user_function_ex(NULL,
+ call_result = call_user_function(NULL,
&object,
&zfuncname,
&zretval,
- 3, args,
- 0, NULL );
+ 3, args);
if (call_result == SUCCESS && (Z_TYPE(zretval) == IS_FALSE || Z_TYPE(zretval) == IS_TRUE)) {
ret = Z_TYPE(zretval) == IS_TRUE;
} else if (call_result == FAILURE) {
- php_error_docref(NULL, E_WARNING, "%s::" USERSTREAM_METADATA " is not implemented!", uwrap->classname);
+ php_error_docref(NULL, E_WARNING, "%s::" USERSTREAM_METADATA " is not implemented!", ZSTR_VAL(uwrap->ce->name));
}
/* clean up */
@@ -1385,12 +1344,11 @@ static int user_wrapper_stat_url(php_stream_wrapper *wrapper, const char *url, i
ZVAL_STRING(&zfuncname, USERSTREAM_STATURL);
- call_result = call_user_function_ex(NULL,
+ call_result = call_user_function(NULL,
&object,
&zfuncname,
&zretval,
- 2, args,
- 0, NULL );
+ 2, args);
if (call_result == SUCCESS && Z_TYPE(zretval) == IS_ARRAY) {
/* We got the info we needed */
@@ -1399,7 +1357,7 @@ static int user_wrapper_stat_url(php_stream_wrapper *wrapper, const char *url, i
} else {
if (call_result == FAILURE) {
php_error_docref(NULL, E_WARNING, "%s::" USERSTREAM_STATURL " is not implemented!",
- uwrap->classname);
+ ZSTR_VAL(uwrap->ce->name));
}
}
@@ -1443,7 +1401,7 @@ static ssize_t php_userstreamop_readdir(php_stream *stream, char *buf, size_t co
didread = sizeof(php_stream_dirent);
} else if (call_result == FAILURE) {
php_error_docref(NULL, E_WARNING, "%s::" USERSTREAM_DIR_READ " is not implemented!",
- us->wrapper->classname);
+ ZSTR_VAL(us->wrapper->ce->name));
}
zval_ptr_dtor(&retval);
@@ -1520,16 +1478,16 @@ static int php_userstreamop_cast(php_stream *stream, int castas, void **retptr)
break;
}
- call_result = call_user_function_ex(NULL,
+ call_result = call_user_function(NULL,
Z_ISUNDEF(us->object)? NULL : &us->object,
&func_name,
&retval,
- 1, args, 0, NULL);
+ 1, args);
do {
if (call_result == FAILURE) {
php_error_docref(NULL, E_WARNING, "%s::" USERSTREAM_CAST " is not implemented!",
- us->wrapper->classname);
+ ZSTR_VAL(us->wrapper->ce->name));
break;
}
if (!zend_is_true(&retval)) {
@@ -1538,12 +1496,12 @@ static int php_userstreamop_cast(php_stream *stream, int castas, void **retptr)
php_stream_from_zval_no_verify(intstream, &retval);
if (!intstream) {
php_error_docref(NULL, E_WARNING, "%s::" USERSTREAM_CAST " must return a stream resource",
- us->wrapper->classname);
+ ZSTR_VAL(us->wrapper->ce->name));
break;
}
if (intstream == stream) {
php_error_docref(NULL, E_WARNING, "%s::" USERSTREAM_CAST " must not return itself",
- us->wrapper->classname);
+ ZSTR_VAL(us->wrapper->ce->name));
intstream = NULL;
break;
}
diff --git a/main/streams/xp_socket.c b/main/streams/xp_socket.c
index 46b23b63ad..f3370e89f7 100644
--- a/main/streams/xp_socket.c
+++ b/main/streams/xp_socket.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -25,7 +23,7 @@
# undef AF_UNIX
#endif
-#if defined(AF_UNIX)
+#ifdef AF_UNIX
#include <sys/un.h>
#endif
@@ -106,7 +104,7 @@ retry:
}
estr = php_socket_strerror(err, NULL, 0);
- php_error_docref(NULL, E_NOTICE, "send of " ZEND_LONG_FMT " bytes failed with errno=%d %s",
+ php_error_docref(NULL, E_NOTICE, "Send of " ZEND_LONG_FMT " bytes failed with errno=%d %s",
(zend_long)count, err, estr);
efree(estr);
}
@@ -239,7 +237,7 @@ static int php_sockop_flush(php_stream *stream)
static int php_sockop_stat(php_stream *stream, php_stream_statbuf *ssb)
{
-#if ZEND_WIN32
+#ifdef ZEND_WIN32
return 0;
#else
php_netstream_data_t *sock = (php_netstream_data_t*)stream->abstract;
@@ -451,12 +449,11 @@ static int php_sockop_set_option(php_stream *stream, int option, int value, void
#endif
default:
- return PHP_STREAM_OPTION_RETURN_NOTIMPL;
+ break;
}
-
- default:
- return PHP_STREAM_OPTION_RETURN_NOTIMPL;
}
+
+ return PHP_STREAM_OPTION_RETURN_NOTIMPL;
}
static int php_sockop_cast(php_stream *stream, int castas, void **ret)
diff --git a/main/strlcat.c b/main/strlcat.c
index 6ef5644568..5556bc31ae 100644
--- a/main/strlcat.c
+++ b/main/strlcat.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -50,7 +48,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char *rcsid = "$OpenBSD: strlcat.c,v 1.17 2016/10/14 18:19:04 dtucker Exp $";
+static const char *rcsid = "$OpenBSD: strlcat.c,v 1.17 2016/10/14 18:19:04 dtucker Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
diff --git a/main/strlcpy.c b/main/strlcpy.c
index 31e13489d8..ef397e267e 100644
--- a/main/strlcpy.c
+++ b/main/strlcpy.c
@@ -1,7 +1,5 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
@@ -50,7 +48,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char *rcsid = "$OpenBSD: strlcpy.c,v 1.15 2016/10/16 17:37:39 dtucker Exp $";
+static const char *rcsid = "$OpenBSD: strlcpy.c,v 1.15 2016/10/16 17:37:39 dtucker Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>