summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
Diffstat (limited to 'main')
-rw-r--r--main/SAPI.c19
-rw-r--r--main/SAPI.h14
-rw-r--r--main/alloca.c13
-rw-r--r--main/build-defs.h.in53
-rw-r--r--main/explicit_bzero.c10
-rw-r--r--main/fastcgi.c11
-rw-r--r--main/fastcgi.h11
-rw-r--r--main/fopen_wrappers.c21
-rw-r--r--main/fopen_wrappers.h10
-rw-r--r--main/getopt.c11
-rw-r--r--main/http_status_codes.h10
-rw-r--r--main/internal_functions.c.in11
-rw-r--r--main/internal_functions_win32.c31
-rw-r--r--main/main.c319
-rw-r--r--main/mergesort.c9
-rw-r--r--main/network.c53
-rw-r--r--main/output.c30
-rw-r--r--main/php.h94
-rw-r--r--main/php_compat.h10
-rw-r--r--main/php_content_types.c11
-rw-r--r--main/php_content_types.h10
-rw-r--r--main/php_getopt.h11
-rw-r--r--main/php_globals.h14
-rw-r--r--main/php_ini.c172
-rw-r--r--main/php_ini.h10
-rw-r--r--main/php_main.h18
-rw-r--r--main/php_memory_streams.h11
-rw-r--r--main/php_network.h13
-rw-r--r--main/php_open_temporary_file.c11
-rw-r--r--main/php_open_temporary_file.h10
-rw-r--r--main/php_output.h11
-rw-r--r--main/php_reentrancy.h17
-rw-r--r--main/php_scandir.c18
-rw-r--r--main/php_scandir.h14
-rw-r--r--main/php_sprintf.c48
-rw-r--r--main/php_stdint.h11
-rw-r--r--main/php_streams.h26
-rw-r--r--main/php_syslog.c12
-rw-r--r--main/php_syslog.h11
-rw-r--r--main/php_ticks.c11
-rw-r--r--main/php_ticks.h11
-rw-r--r--main/php_variables.c54
-rw-r--r--main/php_variables.h10
-rw-r--r--main/php_version.h8
-rw-r--r--main/reentrancy.c59
-rw-r--r--main/rfc1867.c33
-rw-r--r--main/rfc1867.h10
-rw-r--r--main/snprintf.c30
-rw-r--r--main/snprintf.h21
-rw-r--r--main/spprintf.c21
-rw-r--r--main/spprintf.h13
-rw-r--r--main/streams/cast.c17
-rw-r--r--main/streams/filter.c16
-rw-r--r--main/streams/glob_wrapper.c31
-rw-r--r--main/streams/memory.c21
-rw-r--r--main/streams/mmap.c19
-rw-r--r--main/streams/php_stream_context.h12
-rw-r--r--main/streams/php_stream_filter_api.h13
-rw-r--r--main/streams/php_stream_glob_wrapper.h19
-rw-r--r--main/streams/php_stream_mmap.h11
-rw-r--r--main/streams/php_stream_plain_wrapper.h11
-rw-r--r--main/streams/php_stream_transport.h27
-rw-r--r--main/streams/php_stream_userspace.h11
-rw-r--r--main/streams/php_streams_int.h2
-rw-r--r--main/streams/plain_wrapper.c148
-rw-r--r--main/streams/streams.c252
-rw-r--r--main/streams/transports.c11
-rw-r--r--main/streams/userspace.c64
-rw-r--r--main/streams/xp_socket.c78
-rw-r--r--main/strlcat.c11
-rw-r--r--main/strlcpy.c11
71 files changed, 744 insertions, 1521 deletions
diff --git a/main/SAPI.c b/main/SAPI.c
index afb0c77276..a5a68f8c68 100644
--- a/main/SAPI.c
+++ b/main/SAPI.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -27,9 +27,7 @@
#include "php_ini.h"
#include "ext/standard/php_string.h"
#include "ext/standard/pageinfo.h"
-#if (HAVE_PCRE || HAVE_BUNDLED_PCRE) && !defined(COMPILE_DL_PCRE)
#include "ext/pcre/php_pcre.h"
-#endif
#ifdef ZTS
#include "TSRM.h"
#endif
@@ -45,6 +43,7 @@
#ifdef ZTS
SAPI_API int sapi_globals_id;
+SAPI_API size_t sapi_globals_offset;
#else
sapi_globals_struct sapi_globals;
#endif
@@ -56,9 +55,6 @@ static void _type_dtor(zval *zv)
static void sapi_globals_ctor(sapi_globals_struct *sapi_globals)
{
-#ifdef ZTS
- ZEND_TSRMLS_CACHE_UPDATE();
-#endif
memset(sapi_globals, 0, sizeof(*sapi_globals));
zend_hash_init_ex(&sapi_globals->known_post_content_types, 8, NULL, _type_dtor, 1, 0);
php_setup_sapi_content_types();
@@ -79,7 +75,7 @@ SAPI_API void sapi_startup(sapi_module_struct *sf)
sapi_module = *sf;
#ifdef ZTS
- ts_allocate_id(&sapi_globals_id, sizeof(sapi_globals_struct), (ts_allocate_ctor) sapi_globals_ctor, (ts_allocate_dtor) sapi_globals_dtor);
+ ts_allocate_fast_id(&sapi_globals_id, &sapi_globals_offset, sizeof(sapi_globals_struct), (ts_allocate_ctor) sapi_globals_ctor, (ts_allocate_dtor) sapi_globals_dtor);
# ifdef PHP_WIN32
_configthreadlocale(_ENABLE_PER_THREAD_LOCALE);
# endif
@@ -1156,12 +1152,3 @@ SAPI_API void sapi_add_request_header(char *var, unsigned int var_len, char *val
}
}
/* }}} */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/SAPI.h b/main/SAPI.h
index 94612afd64..fe8bfd6244 100644
--- a/main/SAPI.h
+++ b/main/SAPI.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -137,8 +137,9 @@ typedef struct _sapi_globals_struct {
BEGIN_EXTERN_C()
#ifdef ZTS
-# define SG(v) ZEND_TSRMG(sapi_globals_id, sapi_globals_struct *, v)
+# define SG(v) ZEND_TSRMG_FAST(sapi_globals_offset, sapi_globals_struct *, v)
SAPI_API extern int sapi_globals_id;
+SAPI_API extern size_t sapi_globals_offset;
#else
# define SG(v) (sapi_globals.v)
extern SAPI_API sapi_globals_struct sapi_globals;
@@ -320,12 +321,3 @@ END_EXTERN_C()
NULL /* input_filter_init */
#endif /* SAPI_H */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/alloca.c b/main/alloca.c
index 66e001b900..480b9b0ab5 100644
--- a/main/alloca.c
+++ b/main/alloca.c
@@ -25,12 +25,8 @@
#if !HAVE_ALLOCA
-#ifdef HAVE_STRING_H
#include <string.h>
-#endif
-#ifdef HAVE_STDLIB_H
#include <stdlib.h>
-#endif
#ifdef emacs
#include "blockinput.h"
@@ -488,12 +484,3 @@ i00afunc (long address)
#endif /* no alloca */
#endif /* not GCC version 2 */
#endif /* HAVE_ALLOCA */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/build-defs.h.in b/main/build-defs.h.in
index 67712b7b69..f007526846 100644
--- a/main/build-defs.h.in
+++ b/main/build-defs.h.in
@@ -1,8 +1,8 @@
-/* -*- C -*-
+/*
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -17,60 +17,13 @@
*/
#define CONFIGURE_COMMAND "@CONFIGURE_COMMAND@"
-#define PHP_ADA_INCLUDE ""
-#define PHP_ADA_LFLAGS ""
-#define PHP_ADA_LIBS ""
-#define PHP_APACHE_INCLUDE ""
-#define PHP_APACHE_TARGET ""
-#define PHP_FHTTPD_INCLUDE ""
-#define PHP_FHTTPD_LIB ""
-#define PHP_FHTTPD_TARGET ""
-#define PHP_CFLAGS "@CFLAGS@"
-#define PHP_DBASE_LIB ""
-#define PHP_BUILD_DEBUG "@DEBUG_CFLAGS@"
-#define PHP_GDBM_INCLUDE ""
-#define PHP_IBASE_INCLUDE ""
-#define PHP_IBASE_LFLAGS ""
-#define PHP_IBASE_LIBS ""
-#define PHP_IFX_INCLUDE ""
-#define PHP_IFX_LFLAGS ""
-#define PHP_IFX_LIBS ""
-#define PHP_INSTALL_IT "@INSTALL_IT@"
-#define PHP_IODBC_INCLUDE ""
-#define PHP_IODBC_LFLAGS ""
-#define PHP_IODBC_LIBS ""
-#define PHP_MSQL_INCLUDE ""
-#define PHP_MSQL_LFLAGS ""
-#define PHP_MSQL_LIBS ""
-#define PHP_MYSQL_INCLUDE "@MYSQL_INCLUDE@"
-#define PHP_MYSQL_LIBS "@MYSQL_LIBS@"
-#define PHP_MYSQL_TYPE "@MYSQL_MODULE_TYPE@"
-#define PHP_ODBC_INCLUDE "@ODBC_INCLUDE@"
+#define PHP_ODBC_CFLAGS "@ODBC_CFLAGS@"
#define PHP_ODBC_LFLAGS "@ODBC_LFLAGS@"
#define PHP_ODBC_LIBS "@ODBC_LIBS@"
#define PHP_ODBC_TYPE "@ODBC_TYPE@"
-#define PHP_OCI8_SHARED_LIBADD "@OCI8_SHARED_LIBADD@"
#define PHP_OCI8_DIR "@OCI8_DIR@"
#define PHP_OCI8_ORACLE_VERSION "@OCI8_ORACLE_VERSION@"
-#define PHP_ORACLE_SHARED_LIBADD "@ORACLE_SHARED_LIBADD@"
-#define PHP_ORACLE_DIR "@ORACLE_DIR@"
-#define PHP_ORACLE_VERSION "@ORACLE_VERSION@"
-#define PHP_PGSQL_INCLUDE ""
-#define PHP_PGSQL_LFLAGS ""
-#define PHP_PGSQL_LIBS ""
#define PHP_PROG_SENDMAIL "@PROG_SENDMAIL@"
-#define PHP_SOLID_INCLUDE ""
-#define PHP_SOLID_LIBS ""
-#define PHP_EMPRESS_INCLUDE ""
-#define PHP_EMPRESS_LIBS ""
-#define PHP_SYBASE_INCLUDE ""
-#define PHP_SYBASE_LFLAGS ""
-#define PHP_SYBASE_LIBS ""
-#define PHP_DBM_TYPE ""
-#define PHP_DBM_LIB ""
-#define PHP_LDAP_LFLAGS ""
-#define PHP_LDAP_INCLUDE ""
-#define PHP_LDAP_LIBS ""
#define PEAR_INSTALLDIR "@EXPANDED_PEAR_INSTALLDIR@"
#define PHP_INCLUDE_PATH "@INCLUDE_PATH@"
#define PHP_EXTENSION_DIR "@EXPANDED_EXTENSION_DIR@"
diff --git a/main/explicit_bzero.c b/main/explicit_bzero.c
index 990a8047bc..57d12080c6 100644
--- a/main/explicit_bzero.c
+++ b/main/explicit_bzero.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -46,11 +46,3 @@ PHPAPI void php_explicit_bzero(void *dst, size_t siz)
#endif
}
#endif
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/fastcgi.c b/main/fastcgi.c
index 8dd791cc38..f8044ffce3 100644
--- a/main/fastcgi.c
+++ b/main/fastcgi.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -1769,12 +1769,3 @@ const char *fcgi_get_last_client_ip()
/* Unix socket */
return NULL;
}
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/fastcgi.h b/main/fastcgi.h
index aa7a8578f4..95aae11e41 100644
--- a/main/fastcgi.h
+++ b/main/fastcgi.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -126,12 +126,3 @@ void fcgi_impersonate(void);
void fcgi_set_mgmt_var(const char * name, size_t name_len, const char * value, size_t value_len);
void fcgi_free_mgmt_var_cb(zval *zv);
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/fopen_wrappers.c b/main/fopen_wrappers.c
index 1509c006d7..11d31366d7 100644
--- a/main/fopen_wrappers.c
+++ b/main/fopen_wrappers.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -558,9 +558,12 @@ PHPAPI zend_string *php_resolve_path(const char *filename, size_t filename_lengt
if (wrapper->wops->url_stat) {
php_stream_statbuf ssb;
- if (SUCCESS == wrapper->wops->url_stat(wrapper, trypath, 0, &ssb, NULL)) {
+ if (SUCCESS == wrapper->wops->url_stat(wrapper, trypath, PHP_STREAM_URL_STAT_QUIET, &ssb, NULL)) {
return zend_string_init(trypath, strlen(trypath), 0);
}
+ if (EG(exception)) {
+ return NULL;
+ }
}
continue;
}
@@ -595,9 +598,12 @@ PHPAPI zend_string *php_resolve_path(const char *filename, size_t filename_lengt
if (wrapper->wops->url_stat) {
php_stream_statbuf ssb;
- if (SUCCESS == wrapper->wops->url_stat(wrapper, trypath, 0, &ssb, NULL)) {
+ if (SUCCESS == wrapper->wops->url_stat(wrapper, trypath, PHP_STREAM_URL_STAT_QUIET, &ssb, NULL)) {
return zend_string_init(trypath, strlen(trypath), 0);
}
+ if (EG(exception)) {
+ return NULL;
+ }
}
return NULL;
}
@@ -828,12 +834,3 @@ PHPAPI char *expand_filepath_with_mode(const char *filepath, char *real_path, co
return real_path;
}
/* }}} */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/fopen_wrappers.h b/main/fopen_wrappers.h
index bf5d8b2627..17e15b7df0 100644
--- a/main/fopen_wrappers.h
+++ b/main/fopen_wrappers.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -47,11 +47,3 @@ PHPAPI ZEND_INI_MH(OnUpdateBaseDir);
END_EXTERN_C()
#endif
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/getopt.c b/main/getopt.c
index 9e802fa23c..9123cee0f2 100644
--- a/main/getopt.c
+++ b/main/getopt.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -195,12 +195,3 @@ PHPAPI int php_getopt(int argc, char* const *argv, const opt_struct opts[], char
return(0); /* never reached */
}
/* }}} */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/http_status_codes.h b/main/http_status_codes.h
index 8966b433e5..5d5cfb08c3 100644
--- a/main/http_status_codes.h
+++ b/main/http_status_codes.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -80,11 +80,3 @@ static const http_response_status_code_pair http_status_map[] = {
static const size_t http_status_map_len = (sizeof(http_status_map) / sizeof(http_response_status_code_pair)) - 1;
#endif /* HTTP_STATUS_CODES_H */
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/internal_functions.c.in b/main/internal_functions.c.in
index 6592824baf..59557c9651 100644
--- a/main/internal_functions.c.in
+++ b/main/internal_functions.c.in
@@ -1,8 +1,8 @@
-/* -*- C -*-
+/*
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -37,10 +37,3 @@ PHPAPI int php_register_internal_extensions(void)
{
return php_register_extensions(php_builtin_extensions, EXTCOUNT);
}
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- */
diff --git a/main/internal_functions_win32.c b/main/internal_functions_win32.c
index affbb39286..4a3301e49b 100644
--- a/main/internal_functions_win32.c
+++ b/main/internal_functions_win32.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -52,9 +52,7 @@
#if HAVE_CTYPE
#include "ext/ctype/php_ctype.h"
#endif
-#if HAVE_DATE
#include "ext/date/php_date.h"
-#endif
#if HAVE_FTP
#include "ext/ftp/php_ftp.h"
#endif
@@ -62,9 +60,7 @@
#include "ext/iconv/php_iconv.h"
#endif
#include "ext/standard/reg.h"
-#if HAVE_PCRE || HAVE_BUNDLED_PCRE
#include "ext/pcre/php_pcre.h"
-#endif
#if HAVE_UODBC
#include "ext/odbc/php_odbc.h"
#endif
@@ -92,13 +88,8 @@
#if HAVE_XML
#include "ext/xml/php_xml.h"
#endif
-#if HAVE_XML && HAVE_WDDX
-#include "ext/wddx/php_wddx.h"
-#endif
#include "ext/com_dotnet/php_com_dotnet.h"
-#ifdef HAVE_SPL
#include "ext/spl/php_spl.h"
-#endif
#if HAVE_XML && HAVE_XMLREADER
#include "ext/xmlreader/php_xmlreader.h"
#endif
@@ -121,15 +112,11 @@ static zend_module_entry * const php_builtin_extensions[] = {
#if HAVE_CTYPE
,phpext_ctype_ptr
#endif
-#if HAVE_DATE
,phpext_date_ptr
-#endif
#if HAVE_FTP
,phpext_ftp_ptr
#endif
-#if HAVE_HASH
,phpext_hash_ptr
-#endif
#if HAVE_ICONV
,phpext_iconv_ptr
#endif
@@ -139,9 +126,7 @@ static zend_module_entry * const php_builtin_extensions[] = {
#if HAVE_UODBC
,phpext_odbc_ptr
#endif
-#if HAVE_PCRE || HAVE_BUNDLED_PCRE
,phpext_pcre_ptr
-#endif
,phpext_reflection_ptr
#if HAVE_PHP_SESSION
,phpext_session_ptr
@@ -164,12 +149,7 @@ static zend_module_entry * const php_builtin_extensions[] = {
#if HAVE_XML
,phpext_xml_ptr
#endif
-#if HAVE_XML && HAVE_WDDX
- ,phpext_wddx_ptr
-#endif
-#if HAVE_SPL
,phpext_spl_ptr
-#endif
#if HAVE_XML && HAVE_XMLREADER
,phpext_xmlreader_ptr
#endif
@@ -185,12 +165,3 @@ PHPAPI int php_register_internal_extensions(void)
{
return php_register_extensions(php_builtin_extensions, EXTCOUNT);
}
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/main.c b/main/main.c
index 30629117d9..e1491db1fd 100644
--- a/main/main.c
+++ b/main/main.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -39,12 +39,9 @@
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
-#if HAVE_SIGNAL_H
+
#include <signal.h>
-#endif
-#if HAVE_SETLOCALE
#include <locale.h>
-#endif
#include "zend.h"
#include "zend_types.h"
#include "zend_extensions.h"
@@ -87,27 +84,6 @@
#include "rfc1867.h"
#include "ext/standard/html_tables.h"
-
-#if HAVE_MMAP || defined(PHP_WIN32)
-# if HAVE_UNISTD_H
-# include <unistd.h>
-# if defined(_SC_PAGESIZE)
-# define REAL_PAGE_SIZE sysconf(_SC_PAGESIZE);
-# elif defined(_SC_PAGE_SIZE)
-# define REAL_PAGE_SIZE sysconf(_SC_PAGE_SIZE);
-# endif
-# endif
-# if HAVE_SYS_MMAN_H
-# include <sys/mman.h>
-# endif
-# ifndef REAL_PAGE_SIZE
-# ifdef PAGE_SIZE
-# define REAL_PAGE_SIZE PAGE_SIZE
-# else
-# define REAL_PAGE_SIZE 4096
-# endif
-# endif
-#endif
/* }}} */
PHPAPI int (*php_register_internal_extensions_func)(void) = php_register_internal_extensions;
@@ -116,6 +92,7 @@ PHPAPI int (*php_register_internal_extensions_func)(void) = php_register_interna
php_core_globals core_globals;
#else
PHPAPI int core_globals_id;
+PHPAPI size_t core_globals_offset;
#endif
#define SAFE_FILENAME(f) ((f)?(f):"-")
@@ -584,11 +561,43 @@ static PHP_INI_DISP(display_errors_mode)
}
/* }}} */
+PHPAPI const char *php_get_internal_encoding() {
+ if (PG(internal_encoding) && PG(internal_encoding)[0]) {
+ return PG(internal_encoding);
+ } else if (SG(default_charset)) {
+ return SG(default_charset);
+ }
+ return "";
+}
+
+PHPAPI const char *php_get_input_encoding() {
+ if (PG(input_encoding) && PG(input_encoding)[0]) {
+ return PG(input_encoding);
+ } else if (SG(default_charset)) {
+ return SG(default_charset);
+ }
+ return "";
+}
+
+PHPAPI const char *php_get_output_encoding() {
+ if (PG(output_encoding) && PG(output_encoding)[0]) {
+ return PG(output_encoding);
+ } else if (SG(default_charset)) {
+ return SG(default_charset);
+ }
+ return "";
+}
+
+PHPAPI void (*php_internal_encoding_changed)(void) = NULL;
+
/* {{{ PHP_INI_MH
*/
static PHP_INI_MH(OnUpdateDefaultCharset)
{
OnUpdateString(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage);
+ if (php_internal_encoding_changed) {
+ php_internal_encoding_changed();
+ }
if (new_value) {
#ifdef PHP_WIN32
php_win32_cp_do_update(ZSTR_VAL(new_value));
@@ -603,6 +612,9 @@ static PHP_INI_MH(OnUpdateDefaultCharset)
static PHP_INI_MH(OnUpdateInternalEncoding)
{
OnUpdateString(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage);
+ if (php_internal_encoding_changed) {
+ php_internal_encoding_changed();
+ }
if (new_value) {
#ifdef PHP_WIN32
php_win32_cp_do_update(ZSTR_VAL(new_value));
@@ -617,6 +629,9 @@ static PHP_INI_MH(OnUpdateInternalEncoding)
static PHP_INI_MH(OnUpdateInputEncoding)
{
OnUpdateString(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage);
+ if (php_internal_encoding_changed) {
+ php_internal_encoding_changed();
+ }
if (new_value) {
#ifdef PHP_WIN32
php_win32_cp_do_update(NULL);
@@ -631,6 +646,9 @@ static PHP_INI_MH(OnUpdateInputEncoding)
static PHP_INI_MH(OnUpdateOutputEncoding)
{
OnUpdateString(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage);
+ if (php_internal_encoding_changed) {
+ php_internal_encoding_changed();
+ }
if (new_value) {
#ifdef PHP_WIN32
php_win32_cp_do_update(NULL);
@@ -925,8 +943,8 @@ PHPAPI size_t php_printf(const char *format, ...)
/* {{{ php_verror */
/* php_verror is called from php_error_docref<n> functions.
* Its purpose is to unify error messages and automatically generate clickable
- * html error messages if correcponding ini setting (html_errors) is activated.
- * See: CODING_STANDARDS for details.
+ * html error messages if corresponding ini setting (html_errors) is activated.
+ * See: CODING_STANDARDS.md for details.
*/
PHPAPI ZEND_COLD void php_verror(const char *docref, const char *params, int type, const char *format, va_list args)
{
@@ -1114,9 +1132,7 @@ PHPAPI ZEND_COLD void php_verror(const char *docref, const char *params, int typ
if (replace_buffer) {
zend_string_free(replace_buffer);
} else {
- if (buffer_len > 0) {
- efree(buffer);
- }
+ efree(buffer);
}
php_error(type, "%s", message);
@@ -1124,9 +1140,9 @@ PHPAPI ZEND_COLD void php_verror(const char *docref, const char *params, int typ
}
/* }}} */
-/* {{{ php_error_docref0 */
-/* See: CODING_STANDARDS for details. */
-PHPAPI ZEND_COLD void php_error_docref0(const char *docref, int type, const char *format, ...)
+/* {{{ php_error_docref */
+/* Generate an error which links to docref or the php.net documentation if docref is NULL */
+PHPAPI ZEND_COLD void php_error_docref(const char *docref, int type, const char *format, ...)
{
va_list args;
@@ -1137,7 +1153,7 @@ PHPAPI ZEND_COLD void php_error_docref0(const char *docref, int type, const char
/* }}} */
/* {{{ php_error_docref1 */
-/* See: CODING_STANDARDS for details. */
+/* See: CODING_STANDARDS.md for details. */
PHPAPI ZEND_COLD void php_error_docref1(const char *docref, const char *param1, int type, const char *format, ...)
{
va_list args;
@@ -1149,7 +1165,7 @@ PHPAPI ZEND_COLD void php_error_docref1(const char *docref, const char *param1,
/* }}} */
/* {{{ php_error_docref2 */
-/* See: CODING_STANDARDS for details. */
+/* See: CODING_STANDARDS.md for details. */
PHPAPI ZEND_COLD void php_error_docref2(const char *docref, const char *param1, const char *param2, int type, const char *format, ...)
{
char *params;
@@ -1166,24 +1182,18 @@ PHPAPI ZEND_COLD void php_error_docref2(const char *docref, const char *param1,
/* }}} */
#ifdef PHP_WIN32
-#define PHP_WIN32_ERROR_MSG_BUFFER_SIZE 512
PHPAPI ZEND_COLD void php_win32_docref2_from_error(DWORD error, const char *param1, const char *param2) {
- if (error == 0) {
- php_error_docref2(NULL, param1, param2, E_WARNING, "%s", strerror(errno));
- } else {
- char buf[PHP_WIN32_ERROR_MSG_BUFFER_SIZE + 1];
- size_t buf_len;
-
- FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, error, 0, buf, PHP_WIN32_ERROR_MSG_BUFFER_SIZE, NULL);
- buf_len = strlen(buf);
- if (buf_len >= 2) {
- buf[buf_len - 1] = '\0';
- buf[buf_len - 2] = '\0';
- }
- php_error_docref2(NULL, param1, param2, E_WARNING, "%s (code: %lu)", (char *)buf, error);
+ char *buf = php_win32_error_to_msg(error);
+ size_t buf_len;
+
+ buf_len = strlen(buf);
+ if (buf_len >= 2) {
+ buf[buf_len - 1] = '\0';
+ buf[buf_len - 2] = '\0';
}
+ php_error_docref2(NULL, param1, param2, E_WARNING, "%s (code: %lu)", buf, error);
+ php_win32_error_msg_free(buf);
}
-#undef PHP_WIN32_ERROR_MSG_BUFFER_SIZE
#endif
/* {{{ php_html_puts */
@@ -1550,17 +1560,18 @@ static void php_zend_stream_closer(void *handle) /* {{{ */
}
/* }}} */
-static void php_zend_stream_mmap_closer(void *handle) /* {{{ */
-{
- php_stream_mmap_unmap((php_stream*)handle);
- php_zend_stream_closer(handle);
-}
-/* }}} */
-
static size_t php_zend_stream_fsizer(void *handle) /* {{{ */
{
- php_stream_statbuf ssb;
- if (php_stream_stat((php_stream*)handle, &ssb) == 0) {
+ php_stream *stream = handle;
+ php_stream_statbuf ssb;
+
+ /* File size reported by stat() may be inaccurate if stream filters are used.
+ * TODO: Should stat() be generally disabled if filters are used? */
+ if (stream->readfilters.head) {
+ return 0;
+ }
+
+ if (php_stream_stat(stream, &ssb) == 0) {
return ssb.sb.st_size;
}
return 0;
@@ -1575,40 +1586,22 @@ static int php_stream_open_for_zend(const char *filename, zend_file_handle *hand
PHPAPI int php_stream_open_for_zend_ex(const char *filename, zend_file_handle *handle, int mode) /* {{{ */
{
- char *p;
- size_t len, mapped_len;
- php_stream *stream = php_stream_open_wrapper((char *)filename, "rb", mode, &handle->opened_path);
-
+ zend_string *opened_path;
+ php_stream *stream = php_stream_open_wrapper((char *)filename, "rb", mode, &opened_path);
if (stream) {
-#if HAVE_MMAP || defined(PHP_WIN32)
- size_t page_size = REAL_PAGE_SIZE;
-#endif
-
+ memset(handle, 0, sizeof(zend_file_handle));
+ handle->type = ZEND_HANDLE_STREAM;
handle->filename = (char*)filename;
- handle->free_filename = 0;
+ handle->opened_path = opened_path;
handle->handle.stream.handle = stream;
handle->handle.stream.reader = (zend_stream_reader_t)_php_stream_read;
handle->handle.stream.fsizer = php_zend_stream_fsizer;
handle->handle.stream.isatty = 0;
- /* can we mmap immediately? */
- memset(&handle->handle.stream.mmap, 0, sizeof(handle->handle.stream.mmap));
- len = php_zend_stream_fsizer(stream);
- if (len != 0
-#if HAVE_MMAP || defined(PHP_WIN32)
- && ((len - 1) % page_size) <= page_size - ZEND_MMAP_AHEAD
-#endif
- && php_stream_mmap_possible(stream)
- && (p = php_stream_mmap_range(stream, 0, len, PHP_STREAM_MAP_MODE_SHARED_READONLY, &mapped_len)) != NULL) {
- handle->handle.stream.closer = php_zend_stream_mmap_closer;
- handle->handle.stream.mmap.buf = p;
- handle->handle.stream.mmap.len = mapped_len;
- handle->type = ZEND_HANDLE_MAPPED;
- } else {
- handle->handle.stream.closer = php_zend_stream_closer;
- handle->type = ZEND_HANDLE_STREAM;
- }
+ handle->handle.stream.closer = php_zend_stream_closer;
/* suppress warning if this stream is not explicitly closed */
php_stream_auto_cleanup(stream);
+ /* Disable buffering to avoid double buffering between PHP and Zend streams. */
+ php_stream_set_option(stream, PHP_STREAM_OPTION_READ_BUFFER, PHP_STREAM_BUFFER_NONE, NULL);
return SUCCESS;
}
@@ -1685,7 +1678,11 @@ static ZEND_COLD void php_message_handler_for_zend(zend_long message, const void
snprintf(memory_leak_buf, 512, "Last leak repeated %lu time%s\n", leak_count, (leak_count>1?"s":""));
}
# if defined(PHP_WIN32)
- OutputDebugString(memory_leak_buf);
+ if (IsDebuggerPresent()) {
+ OutputDebugString(memory_leak_buf);
+ } else {
+ fprintf(stderr, "%s", memory_leak_buf);
+ }
# else
fprintf(stderr, "%s", memory_leak_buf);
# endif
@@ -1699,7 +1696,11 @@ static ZEND_COLD void php_message_handler_for_zend(zend_long message, const void
snprintf(memory_leak_buf, 512, "=== Total %d memory leaks detected ===\n", *((uint32_t *) data));
# if defined(PHP_WIN32)
- OutputDebugString(memory_leak_buf);
+ if (IsDebuggerPresent()) {
+ OutputDebugString(memory_leak_buf);
+ } else {
+ fprintf(stderr, "%s", memory_leak_buf);
+ }
# else
fprintf(stderr, "%s", memory_leak_buf);
# endif
@@ -1722,7 +1723,11 @@ static ZEND_COLD void php_message_handler_for_zend(zend_long message, const void
snprintf(memory_leak_buf, sizeof(memory_leak_buf), "[null] Script: '%s'\n", SAFE_FILENAME(SG(request_info).path_translated));
}
# if defined(PHP_WIN32)
- OutputDebugString(memory_leak_buf);
+ if (IsDebuggerPresent()) {
+ OutputDebugString(memory_leak_buf);
+ } else {
+ fprintf(stderr, "%s", memory_leak_buf);
+ }
# else
fprintf(stderr, "%s", memory_leak_buf);
# endif
@@ -1838,18 +1843,6 @@ int php_request_startup(void)
}
/* }}} */
-/* {{{ php_request_shutdown_for_exec
- */
-void php_request_shutdown_for_exec(void *dummy)
-{
-
- /* used to close fd's in the 3..255 range here, but it's problematic
- */
- zend_interned_strings_deactivate();
- shutdown_memory_manager(1, 1);
-}
-/* }}} */
-
/* {{{ php_request_shutdown
*/
void php_request_shutdown(void *dummy)
@@ -1953,12 +1946,7 @@ void php_request_shutdown(void *dummy)
shutdown_memory_manager(CG(unclean_shutdown) || !report_memleaks, 0);
} zend_end_try();
- /* 16. Reset max_execution_time */
- zend_try {
- zend_unset_timeout();
- } zend_end_try();
-
- /* 17. Deactivate Zend signals */
+ /* 16. Deactivate Zend signals */
#ifdef ZEND_SIGNALS
zend_signal_deactivate();
#endif
@@ -1990,14 +1978,6 @@ PHPAPI void php_com_initialize(void)
}
/* }}} */
-/* {{{ php_output_wrapper
- */
-static size_t php_output_wrapper(const char *str, size_t str_length)
-{
- return php_output_write(str, str_length);
-}
-/* }}} */
-
#ifdef ZTS
/* {{{ core_globals_ctor
*/
@@ -2162,7 +2142,7 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
php_output_startup();
#ifdef ZTS
- ts_allocate_id(&core_globals_id, sizeof(php_core_globals), (ts_allocate_ctor) core_globals_ctor, (ts_allocate_dtor) core_globals_dtor);
+ ts_allocate_fast_id(&core_globals_id, &core_globals_offset, sizeof(php_core_globals), (ts_allocate_ctor) core_globals_ctor, (ts_allocate_dtor) core_globals_dtor);
#ifdef PHP_WIN32
ts_allocate_id(&php_win32_core_globals_id, sizeof(php_win32_core_globals), (ts_allocate_ctor) php_win32_core_globals_ctor, (ts_allocate_dtor) php_win32_core_globals_dtor);
#endif
@@ -2174,7 +2154,7 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
zuf.error_function = php_error_cb;
zuf.printf_function = php_printf;
- zuf.write_function = php_output_wrapper;
+ zuf.write_function = php_output_write;
zuf.fopen_function = php_fopen_wrapper_for_zend;
zuf.message_handler = php_message_handler_for_zend;
zuf.get_configuration_directive = php_get_configuration_directive_for_zend;
@@ -2185,23 +2165,31 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
zuf.printf_to_smart_str_function = php_printf_to_smart_str;
zuf.getenv_function = sapi_getenv;
zuf.resolve_path_function = php_resolve_path_for_zend;
- zend_startup(&zuf, NULL);
-
-#if HAVE_SETLOCALE
+ zend_startup(&zuf);
setlocale(LC_CTYPE, "");
zend_update_current_locale();
-#endif
#if HAVE_TZSET
tzset();
#endif
#ifdef PHP_WIN32
+# if PHP_LINKER_MAJOR == 14
+ /* Extend for other CRT if needed. */
+ char *img_err;
+ if (!php_win32_crt_compatible("vcruntime140.dll", &img_err)) {
+ php_error(E_CORE_WARNING, img_err);
+ efree(img_err);
+ return FAILURE;
+ }
+# endif
+
/* start up winsock services */
if (WSAStartup(wVersionRequested, &wsaData) != 0) {
php_printf("\nwinsock.dll unusable. %d\n", WSAGetLastError());
return FAILURE;
}
+ php_win32_signal_ctrl_handler_init();
#endif
le_index_ptr = zend_register_list_destructors_ex(NULL, NULL, "index pointer", 0);
@@ -2288,7 +2276,7 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
#ifdef ZEND_WIN32
/* Until the current ini values was setup, the current cp is 65001.
- If the actual ini vaues are different, some stuff needs to be updated.
+ If the actual ini values are different, some stuff needs to be updated.
It concerns at least main_cwd_state and there might be more. As we're
still in the startup phase, lets use the chance and reinit the relevant
item according to the current codepage. Still, if ini_set() is used
@@ -2316,8 +2304,6 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
}
zuv.html_errors = 1;
- zuv.import_use_extension = ".php";
- zuv.import_use_extension_length = (uint32_t)strlen(zuv.import_use_extension);
php_startup_auto_globals();
zend_set_utility_values(&zuv);
php_startup_sapi_content_types();
@@ -2365,14 +2351,14 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
module->info_func = PHP_MINFO(php_core);
}
+ module_initialized = 1;
+
if (zend_post_startup() != SUCCESS) {
return FAILURE;
}
- module_initialized = 1;
-
/* Check for deprecated directives */
- /* NOTE: If you add anything here, remember to add it to Makefile.global! */
+ /* NOTE: If you add anything here, remember to add it to build/Makefile.global! */
{
struct {
const long error_level;
@@ -2384,6 +2370,7 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
"Directive '%s' is deprecated",
{
"track_errors",
+ "allow_url_include",
NULL
}
},
@@ -2453,11 +2440,6 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
}
/* }}} */
-void php_module_shutdown_for_exec(void)
-{
- /* used to close fd's in the range 3.255 here, but it's problematic */
-}
-
/* {{{ php_module_shutdown_wrapper
*/
int php_module_shutdown_wrapper(sapi_module_struct *sapi_globals)
@@ -2481,16 +2463,13 @@ void php_module_shutdown(void)
zend_interned_strings_switch_storage(0);
-#ifdef ZTS
- ts_free_worker_threads();
-#endif
-
#if ZEND_RC_DEBUG
zend_rc_debug = 0;
#endif
#ifdef PHP_WIN32
(void)php_win32_shutdown_random_bytes();
+ php_win32_signal_ctrl_handler_shutdown();
#endif
sapi_flush();
@@ -2523,6 +2502,13 @@ void php_module_shutdown(void)
zend_interned_strings_dtor();
#endif
+ if (zend_post_shutdown_cb) {
+ void (*cb)(void) = zend_post_shutdown_cb;
+
+ zend_post_shutdown_cb = NULL;
+ cb();
+ }
+
module_initialized = 0;
#ifndef ZTS
@@ -2545,7 +2531,7 @@ void php_module_shutdown(void)
PHPAPI int php_execute_script(zend_file_handle *primary_file)
{
zend_file_handle *prepend_file_p, *append_file_p;
- zend_file_handle prepend_file = {{0}, NULL, NULL, 0, 0}, append_file = {{0}, NULL, NULL, 0, 0};
+ zend_file_handle prepend_file, append_file;
#if HAVE_BROKEN_GETCWD
volatile int old_cwd_fd = -1;
#else
@@ -2597,20 +2583,14 @@ PHPAPI int php_execute_script(zend_file_handle *primary_file)
}
if (PG(auto_prepend_file) && PG(auto_prepend_file)[0]) {
- prepend_file.filename = PG(auto_prepend_file);
- prepend_file.opened_path = NULL;
- prepend_file.free_filename = 0;
- prepend_file.type = ZEND_HANDLE_FILENAME;
+ zend_stream_init_filename(&prepend_file, PG(auto_prepend_file));
prepend_file_p = &prepend_file;
} else {
prepend_file_p = NULL;
}
if (PG(auto_append_file) && PG(auto_append_file)[0]) {
- append_file.filename = PG(auto_append_file);
- append_file.opened_path = NULL;
- append_file.free_filename = 0;
- append_file.type = ZEND_HANDLE_FILENAME;
+ zend_stream_init_filename(&append_file, PG(auto_append_file));
append_file_p = &append_file;
} else {
append_file_p = NULL;
@@ -2624,15 +2604,13 @@ PHPAPI int php_execute_script(zend_file_handle *primary_file)
/*
If cli primary file has shabang line and there is a prepend file,
- the `start_lineno` will be used by prepend file but not primary 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(start_lineno) && prepend_file_p) {
- int orig_start_lineno = CG(start_lineno);
-
- CG(start_lineno) = 0;
+ if (CG(skip_shebang) && prepend_file_p) {
+ CG(skip_shebang) = 0;
if (zend_execute_scripts(ZEND_REQUIRE, NULL, 1, prepend_file_p) == SUCCESS) {
- CG(start_lineno) = orig_start_lineno;
+ CG(skip_shebang) = 1;
retval = (zend_execute_scripts(ZEND_REQUIRE, NULL, 2, primary_file, append_file_p) == SUCCESS);
}
} else {
@@ -2779,11 +2757,36 @@ PHPAPI int php_lint_script(zend_file_handle *file)
}
/* }}} */
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
+#ifdef ZTS
+/* {{{ php_reserve_tsrm_memory
*/
+PHPAPI void php_reserve_tsrm_memory(void)
+{
+ tsrm_reserve(
+ TSRM_ALIGNED_SIZE(sizeof(zend_compiler_globals)) +
+ TSRM_ALIGNED_SIZE(sizeof(zend_executor_globals)) +
+ TSRM_ALIGNED_SIZE(sizeof(zend_php_scanner_globals)) +
+ TSRM_ALIGNED_SIZE(sizeof(zend_ini_scanner_globals)) +
+ TSRM_ALIGNED_SIZE(sizeof(virtual_cwd_globals)) +
+#ifdef ZEND_SIGNALS
+ TSRM_ALIGNED_SIZE(sizeof(zend_signal_globals_t)) +
+#endif
+ TSRM_ALIGNED_SIZE(zend_mm_globals_size()) +
+ TSRM_ALIGNED_SIZE(zend_gc_globals_size()) +
+ TSRM_ALIGNED_SIZE(sizeof(php_core_globals)) +
+ TSRM_ALIGNED_SIZE(sizeof(sapi_globals_struct))
+ );
+}
+/* }}} */
+
+/* {{{ php_tsrm_startup
+ */
+PHPAPI int php_tsrm_startup(void)
+{
+ int ret = tsrm_startup(1, 1, 0, NULL);
+ php_reserve_tsrm_memory();
+ (void)ts_resource(0);
+ return ret;
+}
+/* }}} */
+#endif
diff --git a/main/mergesort.c b/main/mergesort.c
index d187635367..da6d8560bf 100644
--- a/main/mergesort.c
+++ b/main/mergesort.c
@@ -345,12 +345,3 @@ static void insertionsort(u_char *a, size_t n, size_t size, int (*cmp)(const voi
}
}
/* }}} */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: fdm=marker
- * vim: noet sw=4 ts=4
- */
diff --git a/main/network.c b/main/network.c
index 21f17e8ade..29b98ae69e 100644
--- a/main/network.c
+++ b/main/network.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -28,6 +28,7 @@
#ifdef PHP_WIN32
# include <Ws2tcpip.h>
# include "win32/inet.h"
+# include "win32/winutil.h"
# define O_RDONLY _O_RDONLY
# include "win32/param.h"
#else
@@ -1022,20 +1023,8 @@ PHPAPI char *php_socket_strerror(long err, char *buf, size_t bufsize)
}
return buf;
#else
- char *sysbuf;
- int free_it = 1;
-
- if (!FormatMessage(
- FORMAT_MESSAGE_ALLOCATE_BUFFER |
- FORMAT_MESSAGE_FROM_SYSTEM |
- FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL,
- err,
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
- (LPTSTR)&sysbuf,
- 0,
- NULL)) {
- free_it = 0;
+ char *sysbuf = php_win32_error_to_msg(err);
+ if (!sysbuf[0]) {
sysbuf = "Unknown Error";
}
@@ -1046,9 +1035,7 @@ PHPAPI char *php_socket_strerror(long err, char *buf, size_t bufsize)
buf[bufsize?(bufsize-1):0] = 0;
}
- if (free_it) {
- LocalFree(sysbuf);
- }
+ php_win32_error_msg_free(sysbuf);
return buf;
#endif
@@ -1065,28 +1052,15 @@ PHPAPI zend_string *php_socket_error_str(long err)
return zend_string_init(errstr, strlen(errstr), 0);
#else
zend_string *ret;
- char *sysbuf;
- int free_it = 1;
-
- if (!FormatMessage(
- FORMAT_MESSAGE_ALLOCATE_BUFFER |
- FORMAT_MESSAGE_FROM_SYSTEM |
- FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL,
- err,
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
- (LPTSTR)&sysbuf,
- 0,
- NULL)) {
- free_it = 0;
+
+ char *sysbuf = php_win32_error_to_msg(err);
+ if (!sysbuf[0]) {
sysbuf = "Unknown Error";
}
ret = zend_string_init(sysbuf, strlen(sysbuf), 0);
- if (free_it) {
- LocalFree(sysbuf);
- }
+ php_win32_error_msg_free(sysbuf);
return ret;
#endif
@@ -1347,12 +1321,3 @@ PHPAPI struct hostent* php_network_gethostbyname(char *name) {
return gethostname_re(name, &FG(tmp_host_info), &FG(tmp_host_buf), &FG(tmp_host_buf_len));
#endif
}
-
-/*
- * Local variables:
- * tab-width: 8
- * c-basic-offset: 8
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/output.c b/main/output.c
index 631c08178b..7751586dbc 100644
--- a/main/output.c
+++ b/main/output.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -58,12 +58,12 @@ static inline php_output_handler_status_t php_output_handler_op(php_output_handl
static inline int php_output_handler_append(php_output_handler *handler, const php_output_buffer *buf);
static inline zval *php_output_handler_status(php_output_handler *handler, zval *entry);
-static inline php_output_context *php_output_context_init(php_output_context *context, int op);
+static inline void php_output_context_init(php_output_context *context, int op);
static inline void php_output_context_reset(php_output_context *context);
static inline void php_output_context_swap(php_output_context *context);
static inline void php_output_context_dtor(php_output_context *context);
-static inline int php_output_stack_pop(int flags);
+static int php_output_stack_pop(int flags);
static int php_output_stack_apply_op(void *h, void *c);
static int php_output_stack_apply_clean(void *h, void *c);
@@ -79,7 +79,6 @@ static int php_output_handler_devnull_func(void **handler_context, php_output_co
* Initialize the module globals on MINIT */
static inline void php_output_init_globals(zend_output_globals *G)
{
- ZEND_TSRMLS_CACHE_UPDATE();
memset(G, 0, sizeof(*G));
}
/* }}} */
@@ -132,7 +131,7 @@ static void reverse_conflict_dtor(zval *zv)
}
/* {{{ void php_output_startup(void)
- * Set up module globals and initalize the conflict and reverse conflict hash tables */
+ * Set up module globals and initialize the conflict and reverse conflict hash tables */
PHPAPI void php_output_startup(void)
{
ZEND_INIT_MODULE_GLOBALS(output, php_output_init_globals, NULL);
@@ -159,7 +158,7 @@ PHPAPI void php_output_shutdown(void)
PHPAPI int php_output_activate(void)
{
#ifdef ZTS
- memset((*((void ***) ZEND_TSRMLS_CACHE))[TSRM_UNSHUFFLE_RSRC_ID(output_globals_id)], 0, sizeof(zend_output_globals));
+ memset(TSRMG_BULK_STATIC(output_globals_id, zend_output_globals*), 0, sizeof(zend_output_globals));
#else
memset(&output_globals, 0, sizeof(zend_output_globals));
#endif
@@ -781,16 +780,10 @@ static inline int php_output_lock_error(int op)
/* {{{ static php_output_context *php_output_context_init(php_output_context *context, int op)
* Initialize a new output context */
-static inline php_output_context *php_output_context_init(php_output_context *context, int op)
+static inline void php_output_context_init(php_output_context *context, int op)
{
- if (!context) {
- context = emalloc(sizeof(php_output_context));
- }
-
memset(context, 0, sizeof(php_output_context));
context->op = op;
-
- return context;
}
/* }}} */
@@ -1199,7 +1192,7 @@ static inline zval *php_output_handler_status(php_output_handler *handler, zval
/* {{{ static int php_output_stack_pop(int flags)
* Pops an output handler off the stack */
-static inline int php_output_stack_pop(int flags)
+static int php_output_stack_pop(int flags)
{
php_output_context context;
php_output_handler **current, *orphan = OG(active);
@@ -1571,12 +1564,3 @@ PHP_FUNCTION(output_add_rewrite_var)
}
}
/* }}} */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/php.h b/main/php.h
index 0b5a904b2c..dbd7673643 100644
--- a/main/php.h
+++ b/main/php.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -24,7 +24,7 @@
#include <dmalloc.h>
#endif
-#define PHP_API_VERSION 20180731
+#define PHP_API_VERSION 20190902
#define PHP_HAVE_STREAMS
#define YYDEBUG 0
#define PHP_DEFAULT_CHARSET "UTF-8"
@@ -36,8 +36,7 @@
#include "zend_API.h"
-#undef sprintf
-#define sprintf php_sprintf
+#define php_sprintf sprintf
/* Operating system family definition */
#ifdef PHP_WIN32
@@ -81,7 +80,6 @@
/* Windows specific defines */
#ifdef PHP_WIN32
# define PHP_PROG_SENDMAIL "Built in mailer"
-# define HAVE_DECLARED_TIMEZONE
# define WIN32_LEAN_AND_MEAN
# define NOOPENFILE
@@ -97,8 +95,6 @@
typedef int uid_t;
typedef int gid_t;
typedef char * caddr_t;
-typedef unsigned int uint;
-typedef unsigned long ulong;
typedef int pid_t;
# ifndef PHP_DEBUG
@@ -123,7 +119,6 @@ typedef int pid_t;
# endif
#endif
-#if HAVE_ASSERT_H
#if PHP_DEBUG
#undef NDEBUG
#else
@@ -132,11 +127,6 @@ typedef int pid_t;
#endif
#endif
#include <assert.h>
-#else /* HAVE_ASSERT_H */
-#define assert(expr) ((void) (0))
-#endif /* HAVE_ASSERT_H */
-
-#define APACHE 0
#if HAVE_UNIX_H
#include <unix.h>
@@ -228,34 +218,15 @@ typedef unsigned int socklen_t;
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
-#if HAVE_STDARG_H
+
#include <stdarg.h>
-#else
-# if HAVE_SYS_VARARGS_H
-# include <sys/varargs.h>
-# endif
-#endif
#include "php_stdint.h"
#include "zend_hash.h"
#include "zend_alloc.h"
#include "zend_stack.h"
-
-#if STDC_HEADERS
-# include <string.h>
-#else
-# ifndef HAVE_MEMCPY
-# define memcpy(d, s, n) bcopy((s), (d), (n))
-# endif
-# ifndef HAVE_MEMMOVE
-# define memmove(d, s, n) bcopy ((s), (d), (n))
-# endif
-#endif
-
-#ifndef HAVE_STRERROR
-char *strerror(int);
-#endif
+#include <string.h>
#if HAVE_PWD_H
# ifdef PHP_WIN32
@@ -266,9 +237,7 @@ char *strerror(int);
# endif
#endif
-#if HAVE_LIMITS_H
#include <limits.h>
-#endif
#ifndef LONG_MAX
#define LONG_MAX 2147483647L
@@ -370,7 +339,7 @@ static inline ZEND_ATTRIBUTE_DEPRECATED void php_std_error_handling() {}
PHPAPI ZEND_COLD void php_verror(const char *docref, const char *params, int type, const char *format, va_list args) PHP_ATTRIBUTE_FORMAT(printf, 4, 0);
/* PHPAPI void php_error(int type, const char *format, ...); */
-PHPAPI ZEND_COLD void php_error_docref0(const char *docref, int type, const char *format, ...)
+PHPAPI ZEND_COLD void php_error_docref(const char *docref, int type, const char *format, ...)
PHP_ATTRIBUTE_FORMAT(printf, 3, 4);
PHPAPI ZEND_COLD void php_error_docref1(const char *docref, const char *param1, int type, const char *format, ...)
PHP_ATTRIBUTE_FORMAT(printf, 4, 5);
@@ -381,8 +350,6 @@ PHPAPI ZEND_COLD void php_win32_docref2_from_error(DWORD error, const char *para
#endif
END_EXTERN_C()
-#define php_error_docref php_error_docref0
-
#define zenderror phperror
#define zendlex phplex
@@ -400,6 +367,11 @@ PHPAPI int php_mergesort(void *base, size_t nmemb, size_t size, int (*cmp)(const
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);
+
+PHPAPI const char *php_get_internal_encoding(void);
+PHPAPI const char *php_get_input_encoding(void);
+PHPAPI const char *php_get_output_encoding(void);
+PHPAPI extern void (*php_internal_encoding_changed)(void);
END_EXTERN_C()
/* PHP-named Zend macro wrappers */
@@ -474,48 +446,4 @@ END_EXTERN_C()
#include "php_reentrancy.h"
-/* Finding offsets of elements within structures.
- * Taken from the Apache code, which in turn, was taken from X code...
- */
-
-#ifndef XtOffset
-#if defined(CRAY) || (defined(__arm) && !(defined(LINUX) || defined(__riscos__)))
-#ifdef __STDC__
-#define XtOffset(p_type, field) _Offsetof(p_type, field)
-#else
-#ifdef CRAY2
-#define XtOffset(p_type, field) \
- (sizeof(int)*((unsigned int)&(((p_type)NULL)->field)))
-
-#else /* !CRAY2 */
-
-#define XtOffset(p_type, field) ((unsigned int)&(((p_type)NULL)->field))
-
-#endif /* !CRAY2 */
-#endif /* __STDC__ */
-#else /* ! (CRAY || __arm) */
-
-#define XtOffset(p_type, field) \
- ((zend_long) (((char *) (&(((p_type)NULL)->field))) - ((char *) NULL)))
-
-#endif /* !CRAY */
-#endif /* ! XtOffset */
-
-#ifndef XtOffsetOf
-#ifdef offsetof
-#define XtOffsetOf(s_type, field) offsetof(s_type, field)
-#else
-#define XtOffsetOf(s_type, field) XtOffset(s_type*, field)
-#endif
-#endif /* !XtOffsetOf */
-
#endif
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/php_compat.h b/main/php_compat.h
index fe3b87f7d9..01d3e326c5 100644
--- a/main/php_compat.h
+++ b/main/php_compat.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -400,11 +400,3 @@
#endif
#endif
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/php_content_types.c b/main/php_content_types.c
index 5f2faa9886..b53ee1ab84 100644
--- a/main/php_content_types.c
+++ b/main/php_content_types.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -64,12 +64,3 @@ int php_setup_sapi_content_types(void)
return SUCCESS;
}
/* }}} */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/php_content_types.h b/main/php_content_types.h
index d907d84d9d..145e8d4c5e 100644
--- a/main/php_content_types.h
+++ b/main/php_content_types.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -27,11 +27,3 @@ int php_startup_sapi_content_types(void);
int php_setup_sapi_content_types(void);
#endif /* PHP_CONTENT_TYPES_H */
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/php_getopt.h b/main/php_getopt.h
index 027e152952..c368aa7fa9 100644
--- a/main/php_getopt.h
+++ b/main/php_getopt.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -39,12 +39,3 @@ END_EXTERN_C()
#define PHP_GETOPT_INVALID_ARG (-2)
#endif
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/main/php_globals.h b/main/php_globals.h
index 077fa1f4bb..6b31d9eaa6 100644
--- a/main/php_globals.h
+++ b/main/php_globals.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -24,8 +24,9 @@
typedef struct _php_core_globals php_core_globals;
#ifdef ZTS
-# define PG(v) ZEND_TSRMG(core_globals_id, php_core_globals *, v)
+# define PG(v) ZEND_TSRMG_FAST(core_globals_offset, php_core_globals *, v)
extern PHPAPI int core_globals_id;
+extern PHPAPI size_t core_globals_offset;
#else
# define PG(v) (core_globals.v)
extern ZEND_API struct _php_core_globals core_globals;
@@ -173,12 +174,3 @@ struct _php_core_globals {
#endif /* PHP_GLOBALS_H */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/php_ini.c b/main/php_ini.c
index d5d920a807..cc2cf16cf8 100644
--- a/main/php_ini.c
+++ b/main/php_ini.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -29,6 +29,7 @@
#include "php_scandir.h"
#ifdef PHP_WIN32
#include "win32/php_registry.h"
+#include "win32/winutil.h"
#endif
#if HAVE_SCANDIR && HAVE_ALPHASORT && HAVE_DIRENT_H
@@ -68,7 +69,7 @@ PHPAPI char *php_ini_scanned_files=NULL;
/* {{{ php_ini_displayer_cb
*/
-static void php_ini_displayer_cb(zend_ini_entry *ini_entry, int type)
+static ZEND_COLD void php_ini_displayer_cb(zend_ini_entry *ini_entry, int type)
{
if (ini_entry->displayer) {
ini_entry->displayer(ini_entry, type);
@@ -114,69 +115,48 @@ static void php_ini_displayer_cb(zend_ini_entry *ini_entry, int type)
}
/* }}} */
-/* {{{ php_ini_displayer
- */
-static int php_ini_displayer(zval *el, void *arg)
-{
- zend_ini_entry *ini_entry = (zend_ini_entry*)Z_PTR_P(el);
- int module_number = *(int *)arg;
-
- if (ini_entry->module_number != module_number) {
- return 0;
- }
- if (!sapi_module.phpinfo_as_text) {
- PUTS("<tr>");
- PUTS("<td class=\"e\">");
- PHPWRITE(ZSTR_VAL(ini_entry->name), ZSTR_LEN(ini_entry->name));
- PUTS("</td><td class=\"v\">");
- php_ini_displayer_cb(ini_entry, ZEND_INI_DISPLAY_ACTIVE);
- PUTS("</td><td class=\"v\">");
- php_ini_displayer_cb(ini_entry, ZEND_INI_DISPLAY_ORIG);
- PUTS("</td></tr>\n");
- } else {
- PHPWRITE(ZSTR_VAL(ini_entry->name), ZSTR_LEN(ini_entry->name));
- PUTS(" => ");
- php_ini_displayer_cb(ini_entry, ZEND_INI_DISPLAY_ACTIVE);
- PUTS(" => ");
- php_ini_displayer_cb(ini_entry, ZEND_INI_DISPLAY_ORIG);
- PUTS("\n");
- }
- return 0;
-}
-/* }}} */
-
-/* {{{ php_ini_available
- */
-static int php_ini_available(zval *el, void *arg)
-{
- zend_ini_entry *ini_entry = (zend_ini_entry *)Z_PTR_P(el);
- int *module_number_available = (int *)arg;
- if (ini_entry->module_number == *(int *)module_number_available) {
- *(int *)module_number_available = -1;
- return ZEND_HASH_APPLY_STOP;
- } else {
- return ZEND_HASH_APPLY_KEEP;
- }
-}
-/* }}} */
-
/* {{{ display_ini_entries
*/
-PHPAPI void display_ini_entries(zend_module_entry *module)
+PHPAPI ZEND_COLD void display_ini_entries(zend_module_entry *module)
{
- int module_number, module_number_available;
+ int module_number;
+ zend_ini_entry *ini_entry;
+ zend_bool first = 1;
if (module) {
module_number = module->module_number;
} else {
module_number = 0;
}
- module_number_available = module_number;
- zend_hash_apply_with_argument(EG(ini_directives), php_ini_available, &module_number_available);
- if (module_number_available == -1) {
- php_info_print_table_start();
- php_info_print_table_header(3, "Directive", "Local Value", "Master Value");
- zend_hash_apply_with_argument(EG(ini_directives), php_ini_displayer, (void *)&module_number);
+
+ ZEND_HASH_FOREACH_PTR(EG(ini_directives), ini_entry) {
+ if (ini_entry->module_number != module_number) {
+ continue;
+ }
+ if (first) {
+ php_info_print_table_start();
+ php_info_print_table_header(3, "Directive", "Local Value", "Master Value");
+ first = 0;
+ }
+ if (!sapi_module.phpinfo_as_text) {
+ PUTS("<tr>");
+ PUTS("<td class=\"e\">");
+ PHPWRITE(ZSTR_VAL(ini_entry->name), ZSTR_LEN(ini_entry->name));
+ PUTS("</td><td class=\"v\">");
+ php_ini_displayer_cb(ini_entry, ZEND_INI_DISPLAY_ACTIVE);
+ PUTS("</td><td class=\"v\">");
+ php_ini_displayer_cb(ini_entry, ZEND_INI_DISPLAY_ORIG);
+ PUTS("</td></tr>\n");
+ } else {
+ PHPWRITE(ZSTR_VAL(ini_entry->name), ZSTR_LEN(ini_entry->name));
+ PUTS(" => ");
+ php_ini_displayer_cb(ini_entry, ZEND_INI_DISPLAY_ACTIVE);
+ PUTS(" => ");
+ php_ini_displayer_cb(ini_entry, ZEND_INI_DISPLAY_ORIG);
+ PUTS("\n");
+ }
+ } ZEND_HASH_FOREACH_END();
+ if (!first) {
php_info_print_table_end();
}
}
@@ -359,6 +339,13 @@ 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;
@@ -404,6 +391,16 @@ static void php_load_zend_extension_cb(void *arg)
efree(err1);
}
+#ifdef PHP_WIN32
+ if (!php_win32_image_compatible(libpath, &err1)) {
+ php_error(E_CORE_WARNING, err1);
+ efree(err1);
+ efree(libpath);
+ DL_UNLOAD(handle);
+ return;
+ }
+#endif
+
zend_load_extension_handle(handle, libpath);
efree(libpath);
}
@@ -422,8 +419,9 @@ int php_init_config(void)
int php_ini_scanned_path_len;
char *open_basedir;
int free_ini_search_path = 0;
- zend_file_handle fh;
zend_string *opened_path = NULL;
+ FILE *fp;
+ const char *filename;
zend_hash_init(&configuration_hash, 8, NULL, config_zval_dtor, 1);
@@ -575,7 +573,8 @@ int php_init_config(void)
* Find and open actual ini file
*/
- memset(&fh, 0, sizeof(fh));
+ fp = NULL;
+ filename = NULL;
/* If SAPI does not want to ignore all ini files OR an overriding file/path is given.
* This allows disabling scanning for ini files in the PHP_CONFIG_FILE_SCAN_DIR but still
@@ -588,31 +587,31 @@ int php_init_config(void)
if (!VCWD_STAT(php_ini_file_name, &statbuf)) {
if (!((statbuf.st_mode & S_IFMT) == S_IFDIR)) {
- fh.handle.fp = VCWD_FOPEN(php_ini_file_name, "r");
- if (fh.handle.fp) {
- fh.filename = expand_filepath(php_ini_file_name, NULL);
+ fp = VCWD_FOPEN(php_ini_file_name, "r");
+ if (fp) {
+ filename = expand_filepath(php_ini_file_name, NULL);
}
}
}
}
/* Otherwise search for php-%sapi-module-name%.ini file in search path */
- if (!fh.handle.fp) {
+ if (!fp) {
const char *fmt = "php-%s.ini";
char *ini_fname;
spprintf(&ini_fname, 0, fmt, sapi_module.name);
- fh.handle.fp = php_fopen_with_path(ini_fname, "r", php_ini_search_path, &opened_path);
+ fp = php_fopen_with_path(ini_fname, "r", php_ini_search_path, &opened_path);
efree(ini_fname);
- if (fh.handle.fp) {
- fh.filename = ZSTR_VAL(opened_path);
+ if (fp) {
+ filename = ZSTR_VAL(opened_path);
}
}
/* If still no ini file found, search for php.ini file in search path */
- if (!fh.handle.fp) {
- fh.handle.fp = php_fopen_with_path("php.ini", "r", php_ini_search_path, &opened_path);
- if (fh.handle.fp) {
- fh.filename = ZSTR_VAL(opened_path);
+ if (!fp) {
+ fp = php_fopen_with_path("php.ini", "r", php_ini_search_path, &opened_path);
+ if (fp) {
+ filename = ZSTR_VAL(opened_path);
}
}
}
@@ -623,8 +622,9 @@ int php_init_config(void)
PG(open_basedir) = open_basedir;
- if (fh.handle.fp) {
- fh.type = ZEND_HANDLE_FP;
+ if (fp) {
+ zend_file_handle fh;
+ zend_stream_init_fp(&fh, fp, filename);
RESET_ACTIVE_INI_HASH();
zend_parse_ini_file(&fh, 1, ZEND_INI_SCANNER_NORMAL, (zend_ini_parser_cb_t) php_ini_parser_cb, &configuration_hash);
@@ -658,7 +658,6 @@ int php_init_config(void)
zend_stat_t sb;
char ini_file[MAXPATHLEN];
char *p;
- zend_file_handle fh2;
zend_llist scanned_ini_list;
zend_llist_element *element;
int l, total_l = 0;
@@ -666,7 +665,6 @@ int php_init_config(void)
int lenpath;
zend_llist_init(&scanned_ini_list, sizeof(char *), (llist_dtor_func_t) free_estring, 1);
- memset(&fh2, 0, sizeof(fh2));
bufpath = estrdup(php_ini_scanned_path);
for (debpath = bufpath ; debpath ; debpath=endpath) {
@@ -700,11 +698,10 @@ int php_init_config(void)
}
if (VCWD_STAT(ini_file, &sb) == 0) {
if (S_ISREG(sb.st_mode)) {
- if ((fh2.handle.fp = VCWD_FOPEN(ini_file, "r"))) {
- fh2.filename = ini_file;
- fh2.type = ZEND_HANDLE_FP;
-
- if (zend_parse_ini_file(&fh2, 1, ZEND_INI_SCANNER_NORMAL, (zend_ini_parser_cb_t) php_ini_parser_cb, &configuration_hash) == SUCCESS) {
+ zend_file_handle fh;
+ zend_stream_init_fp(&fh, VCWD_FOPEN(ini_file, "r"), ini_file);
+ if (fh.handle.fp) {
+ if (zend_parse_ini_file(&fh, 1, ZEND_INI_SCANNER_NORMAL, (zend_ini_parser_cb_t) php_ini_parser_cb, &configuration_hash) == SUCCESS) {
/* Here, add it to the list of ini files read */
l = (int)strlen(ini_file);
total_l += l + 2;
@@ -787,17 +784,14 @@ PHPAPI int php_parse_user_ini_file(const char *dirname, char *ini_filename, Hash
{
zend_stat_t sb;
char ini_file[MAXPATHLEN];
- zend_file_handle fh;
snprintf(ini_file, MAXPATHLEN, "%s%c%s", dirname, DEFAULT_SLASH, ini_filename);
if (VCWD_STAT(ini_file, &sb) == 0) {
if (S_ISREG(sb.st_mode)) {
- memset(&fh, 0, sizeof(fh));
- if ((fh.handle.fp = VCWD_FOPEN(ini_file, "r"))) {
- fh.filename = ini_file;
- fh.type = ZEND_HANDLE_FP;
-
+ zend_file_handle fh;
+ zend_stream_init_fp(&fh, VCWD_FOPEN(ini_file, "r"), ini_file);
+ if (fh.handle.fp) {
/* Reset active ini section */
RESET_ACTIVE_INI_HASH();
@@ -966,13 +960,3 @@ PHPAPI HashTable* php_ini_get_configuration_hash(void) /* {{{ */
{
return &configuration_hash;
} /* }}} */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * indent-tabs-mode: t
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/php_ini.h b/main/php_ini.h
index 57a6427ab6..a4fad6c689 100644
--- a/main/php_ini.h
+++ b/main/php_ini.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -87,11 +87,3 @@ END_EXTERN_C()
#define php_ini_string zend_ini_string
#endif /* PHP_INI_H */
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/php_main.h b/main/php_main.h
index 82d6e0fe18..44eeb974d6 100644
--- a/main/php_main.h
+++ b/main/php_main.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -27,10 +27,8 @@
BEGIN_EXTERN_C()
PHPAPI int php_request_startup(void);
PHPAPI void php_request_shutdown(void *dummy);
-PHPAPI void php_request_shutdown_for_exec(void *dummy);
PHPAPI int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_modules, uint32_t num_additional_modules);
PHPAPI void php_module_shutdown(void);
-PHPAPI void php_module_shutdown_for_exec(void);
PHPAPI int php_module_shutdown_wrapper(sapi_module_struct *sapi_globals);
PHPAPI int php_register_extensions(zend_module_entry * const * ptr, int count);
@@ -49,14 +47,12 @@ PHPAPI int php_stream_open_for_zend_ex(const char *filename, zend_file_handle *h
/* environment module */
extern int php_init_environ(void);
extern int php_shutdown_environ(void);
+
+#ifdef ZTS
+PHPAPI void php_reserve_tsrm_memory(void);
+PHPAPI int php_tsrm_startup(void);
+#endif
+
END_EXTERN_C()
#endif
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/php_memory_streams.h b/main/php_memory_streams.h
index 4de8288dd5..7db25dd1dd 100644
--- a/main/php_memory_streams.h
+++ b/main/php_memory_streams.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -63,12 +63,3 @@ extern PHPAPI const php_stream_wrapper php_stream_rfc2397_wrapper;
#define PHP_STREAM_IS_TEMP &php_stream_temp_ops
#endif
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/php_network.h b/main/php_network.h
index 4d6b18f43a..241ca94e27 100644
--- a/main/php_network.h
+++ b/main/php_network.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -89,9 +89,7 @@ END_EXTERN_C()
#include <sys/time.h>
#endif
-#ifdef HAVE_STDDEF_H
#include <stddef.h>
-#endif
#ifdef PHP_WIN32
typedef SOCKET php_socket_t;
@@ -339,12 +337,3 @@ END_EXTERN_C()
#endif
#endif /* _PHP_NETWORK_H */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/php_open_temporary_file.c b/main/php_open_temporary_file.c
index 448c0c19a1..6fca7e4cab 100644
--- a/main/php_open_temporary_file.c
+++ b/main/php_open_temporary_file.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -342,12 +342,3 @@ PHPAPI FILE *php_open_temporary_file(const char *dir, const char *pfx, zend_stri
return fp;
}
/* }}} */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/php_open_temporary_file.h b/main/php_open_temporary_file.h
index 8d7c14cdd1..0195056e31 100644
--- a/main/php_open_temporary_file.h
+++ b/main/php_open_temporary_file.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -30,11 +30,3 @@ PHPAPI const char *php_get_temporary_directory(void);
END_EXTERN_C()
#endif /* PHP_OPEN_TEMPORARY_FILE_H */
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/php_output.h b/main/php_output.h
index a7384a6216..f76d61d841 100644
--- a/main/php_output.h
+++ b/main/php_output.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -262,12 +262,3 @@ PHP_FUNCTION(output_add_rewrite_var);
PHP_FUNCTION(output_reset_rewrite_vars);
#endif
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/php_reentrancy.h b/main/php_reentrancy.h
index c4d6a61e2a..bbc772b5db 100644
--- a/main/php_reentrancy.h
+++ b/main/php_reentrancy.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -49,13 +49,6 @@
BEGIN_EXTERN_C()
-#if defined(HAVE_POSIX_READDIR_R)
-#define php_readdir_r readdir_r
-#else
-PHPAPI int php_readdir_r(DIR *dirp, struct dirent *entry,
- struct dirent **result);
-#endif
-
#if !defined(HAVE_LOCALTIME_R) && defined(HAVE_LOCALTIME)
#define PHP_NEED_REENTRANCY 1
PHPAPI struct tm *php_localtime_r(const time_t *const timep, struct tm *p_tm);
@@ -129,11 +122,3 @@ void reentrancy_shutdown(void);
#endif
#endif
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/php_scandir.c b/main/php_scandir.c
index 76628528a4..7fdb49b77a 100644
--- a/main/php_scandir.c
+++ b/main/php_scandir.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -42,9 +42,7 @@
#ifndef HAVE_ALPHASORT
-#ifdef HAVE_STRING_H
#include <string.h>
-#endif
PHPAPI int php_alphasort(const struct dirent **a, const struct dirent **b)
{
@@ -59,8 +57,7 @@ PHPAPI int php_scandir(const char *dirname, struct dirent **namelist[], int (*se
struct dirent **vector = NULL;
int vector_size = 0;
int nfiles = 0;
- char entry[sizeof(struct dirent)+MAXPATHLEN];
- struct dirent *dp = (struct dirent *)&entry;
+ struct dirent *dp;
if (namelist == NULL) {
return -1;
@@ -70,7 +67,7 @@ PHPAPI int php_scandir(const char *dirname, struct dirent **namelist[], int (*se
return -1;
}
- while (!php_readdir_r(dirp, (struct dirent *)entry, &dp) && dp) {
+ while ((dp = readdir(dirp))) {
size_t dsize = 0;
struct dirent *newdp = NULL;
@@ -121,12 +118,3 @@ fail:
return -1;
}
#endif
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/php_scandir.h b/main/php_scandir.h
index ce31bc200c..04bf29f2c9 100644
--- a/main/php_scandir.h
+++ b/main/php_scandir.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -22,10 +22,6 @@
#include <sys/types.h>
-#ifdef HAVE_SYS_DIR_H
-#include <sys/dir.h>
-#endif
-
#ifdef PHP_WIN32
#include "config.w32.h"
#include "win32/readdir.h"
@@ -50,11 +46,3 @@ PHPAPI int php_alphasort(const struct dirent **a, const struct dirent **b);
#endif
#endif /* PHP_SCANDIR_H */
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/php_sprintf.c b/main/php_sprintf.c
deleted file mode 100644
index 2581e4575d..0000000000
--- a/main/php_sprintf.c
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
- +----------------------------------------------------------------------+
- | This source file is subject to version 3.01 of the PHP license, |
- | that is bundled with this package in the file LICENSE, and is |
- | available through the world-wide-web at the following url: |
- | http://www.php.net/license/3_01.txt |
- | If you did not receive a copy of the PHP license and are unable to |
- | obtain it through the world-wide-web, please send a note to |
- | license@php.net so we can mail you a copy immediately. |
- +----------------------------------------------------------------------+
- | Author: Jaakko Hyvätti <jaakko.hyvatti@iki.fi> |
- +----------------------------------------------------------------------+
- */
-
-#include <stdio.h>
-#include <stdarg.h>
-#include "php.h"
-#ifdef PHP_WIN32
-#include "config.w32.h"
-#else
-#include <php_config.h>
-#endif
-
-PHPAPI int
-php_sprintf (char*s, const char* format, ...)
-{
- va_list args;
- int ret;
-
- va_start (args, format);
- s[0] = '\0';
- ret = vsprintf (s, format, args);
- va_end (args);
- return (ret < 0) ? -1 : ret;
-}
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/php_stdint.h b/main/php_stdint.h
index 811725acef..3e5fd0016c 100644
--- a/main/php_stdint.h
+++ b/main/php_stdint.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -218,12 +218,3 @@ typedef unsigned long long uint64_t;
#endif /* !PHP_WIN32 */
#endif /* PHP_STDINT_H */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/php_streams.h b/main/php_streams.h
index a5e89bf96a..11e7c2aae7 100644
--- a/main/php_streams.h
+++ b/main/php_streams.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -115,8 +115,8 @@ typedef struct _php_stream_dirent {
/* operations on streams that are file-handles */
typedef struct _php_stream_ops {
/* stdio like functions - these are mandatory! */
- size_t (*write)(php_stream *stream, const char *buf, size_t count);
- size_t (*read)(php_stream *stream, char *buf, size_t count);
+ ssize_t (*write)(php_stream *stream, const char *buf, size_t count);
+ ssize_t (*read)(php_stream *stream, char *buf, size_t count);
int (*close)(php_stream *stream, int close_handle);
int (*flush)(php_stream *stream);
@@ -305,17 +305,19 @@ PHPAPI int _php_stream_seek(php_stream *stream, zend_off_t offset, int whence);
PHPAPI zend_off_t _php_stream_tell(php_stream *stream);
#define php_stream_tell(stream) _php_stream_tell((stream))
-PHPAPI size_t _php_stream_read(php_stream *stream, char *buf, size_t count);
+PHPAPI ssize_t _php_stream_read(php_stream *stream, char *buf, size_t count);
#define php_stream_read(stream, buf, count) _php_stream_read((stream), (buf), (count))
-PHPAPI size_t _php_stream_write(php_stream *stream, const char *buf, size_t count);
+PHPAPI zend_string *php_stream_read_to_str(php_stream *stream, size_t len);
+
+PHPAPI ssize_t _php_stream_write(php_stream *stream, const char *buf, size_t count);
#define php_stream_write_string(stream, str) _php_stream_write(stream, str, strlen(str))
#define php_stream_write(stream, buf, count) _php_stream_write(stream, (buf), (count))
-PHPAPI void _php_stream_fill_read_buffer(php_stream *stream, size_t size);
+PHPAPI int _php_stream_fill_read_buffer(php_stream *stream, size_t size);
#define php_stream_fill_read_buffer(stream, size) _php_stream_fill_read_buffer((stream), (size))
-PHPAPI size_t _php_stream_printf(php_stream *stream, const char *fmt, ...) PHP_ATTRIBUTE_FORMAT(printf, 2, 3);
+PHPAPI ssize_t _php_stream_printf(php_stream *stream, const char *fmt, ...) PHP_ATTRIBUTE_FORMAT(printf, 2, 3);
/* php_stream_printf macro & function require */
#define php_stream_printf _php_stream_printf
@@ -462,7 +464,7 @@ PHPAPI zend_string *_php_stream_copy_to_mem(php_stream *src, size_t maxlen, int
#define php_stream_copy_to_mem(src, maxlen, persistent) _php_stream_copy_to_mem((src), (maxlen), (persistent) STREAMS_CC)
/* output all data from a stream */
-PHPAPI size_t _php_stream_passthru(php_stream * src STREAMS_DC);
+PHPAPI ssize_t _php_stream_passthru(php_stream * src STREAMS_DC);
#define php_stream_passthru(stream) _php_stream_passthru((stream) STREAMS_CC)
END_EXTERN_C()
@@ -606,11 +608,3 @@ END_EXTERN_C()
#define PHP_STREAM_META_GROUP_NAME 4
#define PHP_STREAM_META_GROUP 5
#define PHP_STREAM_META_ACCESS 6
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/php_syslog.c b/main/php_syslog.c
index 561a63cf00..987ef9cc0c 100644
--- a/main/php_syslog.c
+++ b/main/php_syslog.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 2017-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -18,7 +18,6 @@
#include <stdio.h>
#include <string.h>
-#include <assert.h>
#include <stdlib.h>
#include "php.h"
#include "php_syslog.h"
@@ -116,12 +115,3 @@ PHPAPI void php_syslog(int priority, const char *format, ...) /* {{{ */
}
/* }}} */
#endif
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/php_syslog.h b/main/php_syslog.h
index 401f498194..2c499269a4 100644
--- a/main/php_syslog.h
+++ b/main/php_syslog.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -42,12 +42,3 @@ PHPAPI void php_openlog(const char *, int, int);
END_EXTERN_C()
#endif
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/php_ticks.c b/main/php_ticks.c
index 4a284eac5d..f5b0dd0c58 100644
--- a/main/php_ticks.c
+++ b/main/php_ticks.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -70,12 +70,3 @@ void php_run_ticks(int count)
{
zend_llist_apply_with_argument(&PG(tick_functions), (llist_apply_with_arg_func_t) php_tick_iterator, &count);
}
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/php_ticks.h b/main/php_ticks.h
index d1e1c13914..5b2bb057e6 100644
--- a/main/php_ticks.h
+++ b/main/php_ticks.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -30,12 +30,3 @@ PHPAPI void php_remove_tick_function(void (*func)(int, void *), void * arg);
END_EXTERN_C()
#endif
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/php_variables.c b/main/php_variables.c
index d804a3860f..1a40c2a19f 100644
--- a/main/php_variables.c
+++ b/main/php_variables.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -370,9 +370,9 @@ SAPI_API SAPI_POST_HANDLER_FUNC(php_std_post_handler)
while (!php_stream_eof(s)) {
char buf[SAPI_POST_HANDLER_BUFSIZ] = {0};
- size_t len = php_stream_read(s, buf, SAPI_POST_HANDLER_BUFSIZ);
+ ssize_t len = php_stream_read(s, buf, SAPI_POST_HANDLER_BUFSIZ);
- if (len && len != (size_t) -1) {
+ if (len > 0) {
smart_str_appendl(&post_data.str, buf, len);
if (SUCCESS != add_post_vars(arr, &post_data, 0)) {
@@ -479,6 +479,9 @@ SAPI_API SAPI_TREAT_DATA_FUNC(php_default_treat_data)
var = php_strtok_r(res, separator, &strtok_buf);
while (var) {
+ size_t val_len;
+ size_t new_val_len;
+
val = strchr(var, '=');
if (arg == PARSE_COOKIE) {
@@ -497,29 +500,25 @@ SAPI_API SAPI_TREAT_DATA_FUNC(php_default_treat_data)
}
if (val) { /* have a value */
- size_t val_len;
- size_t new_val_len;
*val++ = '\0';
- php_url_decode(var, strlen(var));
- val_len = php_url_decode(val, strlen(val));
- val = estrndup(val, val_len);
- if (sapi_module.input_filter(arg, var, &val, val_len, &new_val_len)) {
- php_register_variable_safe(var, val, new_val_len, &array);
+
+ if (arg == PARSE_COOKIE) {
+ val_len = php_raw_url_decode(val, strlen(val));
+ } else {
+ val_len = php_url_decode(val, strlen(val));
}
- efree(val);
} else {
- size_t val_len;
- size_t new_val_len;
-
- php_url_decode(var, strlen(var));
- val_len = 0;
- val = estrndup("", val_len);
- if (sapi_module.input_filter(arg, var, &val, val_len, &new_val_len)) {
- php_register_variable_safe(var, val, new_val_len, &array);
- }
- efree(val);
+ val = "";
+ val_len = 0;
+ }
+
+ val = estrndup(val, val_len);
+ php_url_decode(var, strlen(var));
+ if (sapi_module.input_filter(arg, var, &val, val_len, &new_val_len)) {
+ php_register_variable_safe(var, val, new_val_len, &array);
}
+ efree(val);
next_cookie:
var = php_strtok_r(NULL, separator, &strtok_buf);
}
@@ -580,6 +579,8 @@ void _php_import_environment_variables(zval *array_ptr)
char *environment, *env;
#endif
+ tsrm_env_lock();
+
#ifndef PHP_WIN32
for (env = environ; env != NULL && *env != NULL; env++) {
import_environment_variable(Z_ARRVAL_P(array_ptr), *env);
@@ -591,6 +592,8 @@ void _php_import_environment_variables(zval *array_ptr)
}
FreeEnvironmentStringsA(environment);
#endif
+
+ tsrm_env_unlock();
}
zend_bool php_std_auto_global_callback(char *name, uint32_t name_len)
@@ -934,12 +937,3 @@ void php_startup_auto_globals(void)
zend_register_auto_global(zend_string_init_interned("_REQUEST", sizeof("_REQUEST")-1, 1), PG(auto_globals_jit), php_auto_globals_create_request);
zend_register_auto_global(zend_string_init_interned("_FILES", sizeof("_FILES")-1, 1), 0, php_auto_globals_create_files);
}
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/php_variables.h b/main/php_variables.h
index bc2da53732..7dc33d328a 100644
--- a/main/php_variables.h
+++ b/main/php_variables.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -46,11 +46,3 @@ END_EXTERN_C()
#define NUM_TRACK_VARS 6
#endif /* PHP_VARIABLES_H */
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/php_version.h b/main/php_version.h
index 83cfdacd7c..27e342e367 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 3
-#define PHP_RELEASE_VERSION 16
+#define PHP_MINOR_VERSION 4
+#define PHP_RELEASE_VERSION 3
#define PHP_EXTRA_VERSION "-dev"
-#define PHP_VERSION "7.3.16-dev"
-#define PHP_VERSION_ID 70316
+#define PHP_VERSION "7.4.3-dev"
+#define PHP_VERSION_ID 70403
diff --git a/main/reentrancy.c b/main/reentrancy.c
index 213e82bd8c..08f03e76dd 100644
--- a/main/reentrancy.c
+++ b/main/reentrancy.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -109,54 +109,6 @@ PHPAPI struct tm *php_gmtime_r(const time_t *const timep, struct tm *p_tm)
#endif
-#if !defined(HAVE_POSIX_READDIR_R)
-
-PHPAPI int php_readdir_r(DIR *dirp, struct dirent *entry,
- struct dirent **result)
-{
-#if defined(HAVE_OLD_READDIR_R)
- int ret = 0;
-
- /* We cannot rely on the return value of readdir_r
- as it differs between various platforms
- (HPUX returns 0 on success whereas Solaris returns non-zero)
- */
- entry->d_name[0] = '\0';
- readdir_r(dirp, entry);
-
- if (entry->d_name[0] == '\0') {
- *result = NULL;
- ret = errno;
- } else {
- *result = entry;
- }
- return ret;
-#else
- struct dirent *ptr;
- int ret = 0;
-
- local_lock(READDIR_R);
-
- errno = 0;
-
- ptr = readdir(dirp);
-
- if (!ptr && errno != 0)
- ret = errno;
-
- if (ptr)
- memcpy(entry, ptr, sizeof(*ptr));
-
- *result = ptr;
-
- local_unlock(READDIR_R);
-
- return ret;
-#endif
-}
-
-#endif
-
#if !defined(HAVE_LOCALTIME_R) && defined(HAVE_LOCALTIME)
PHPAPI struct tm *php_localtime_r(const time_t *const timep, struct tm *p_tm)
@@ -425,12 +377,3 @@ cont:
}
#endif
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/rfc1867.c b/main/rfc1867.c
index 8a8e335ef4..1ee7b925a1 100644
--- a/main/rfc1867.c
+++ b/main/rfc1867.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -190,15 +190,6 @@ static void register_http_post_files_variable_ex(char *var, zval *val, zval *htt
}
/* }}} */
-static int unlink_filename(zval *el) /* {{{ */
-{
- zend_string *filename = Z_STR_P(el);
- VCWD_UNLINK(ZSTR_VAL(filename));
- return 0;
-}
-/* }}} */
-
-
static void free_filename(zval *el) {
zend_string *filename = Z_STR_P(el);
zend_string_release_ex(filename, 0);
@@ -206,7 +197,12 @@ static void free_filename(zval *el) {
PHPAPI void destroy_uploaded_files_hash(void) /* {{{ */
{
- zend_hash_apply(SG(rfc1867_uploaded_files), unlink_filename);
+ zval *el;
+
+ ZEND_HASH_FOREACH_VAL(SG(rfc1867_uploaded_files), el) {
+ zend_string *filename = Z_STR_P(el);
+ VCWD_UNLINK(ZSTR_VAL(filename));
+ } ZEND_HASH_FOREACH_END();
zend_hash_destroy(SG(rfc1867_uploaded_files));
FREE_HASHTABLE(SG(rfc1867_uploaded_files));
}
@@ -281,11 +277,7 @@ static int fill_buffer(multipart_buffer *self)
/* eof if we are out of bytes, or if we hit the final boundary */
static int multipart_buffer_eof(multipart_buffer *self)
{
- if ( (self->bytes_in_buffer == 0 && fill_buffer(self) < 1) ) {
- return 1;
- } else {
- return 0;
- }
+ return self->bytes_in_buffer == 0 && fill_buffer(self) < 1;
}
/* create new multipart_buffer structure */
@@ -1339,12 +1331,3 @@ SAPI_API void php_rfc1867_set_multibyte_callbacks(
php_rfc1867_basename = basename;
}
/* }}} */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/rfc1867.h b/main/rfc1867.h
index ae8058d81b..bfb9bb51c6 100644
--- a/main/rfc1867.h
+++ b/main/rfc1867.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -87,11 +87,3 @@ SAPI_API void php_rfc1867_set_multibyte_callbacks(
php_rfc1867_basename_t basename);
#endif /* RFC1867_H */
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/snprintf.c b/main/snprintf.c
index 5990e3df91..61a5dfffce 100644
--- a/main/snprintf.c
+++ b/main/snprintf.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -34,7 +34,6 @@
#include <inttypes.h>
#endif
-#ifdef HAVE_LOCALE_H
#include <locale.h>
#ifdef ZTS
#include "ext/standard/php_string.h"
@@ -42,9 +41,6 @@
#else
#define LCONV_DECIMAL_POINT (*lconv->decimal_point)
#endif
-#else
-#define LCONV_DECIMAL_POINT '.'
-#endif
/*
* Copyright (c) 2002, 2006 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -191,8 +187,7 @@ PHPAPI char *php_gcvt(double value, int ndigit, char dec_point, char exponent, c
*dst = '\0';
} else {
/* XXX - optimize */
- for (sign = decpt, i = 0; (sign /= 10) != 0; i++)
- continue;
+ for (sign = decpt, i = 0; (sign /= 10) != 0; i++);
dst[i + 1] = '\0';
while (decpt != 0) {
dst[i--] = '0' + decpt % 10;
@@ -573,7 +568,7 @@ typedef struct buf_area buffy;
INS_CHAR( ch, sp, bep, cc ) ; \
width-- ; \
} \
- while ( width > len )
+ while ( (size_t)width > len )
/*
* Prefix the character ch to the string str
@@ -613,13 +608,11 @@ static int format_converter(register buffy * odp, const char *fmt, va_list ap) /
char num_buf[NUM_BUF_SIZE];
char char_buf[2]; /* for printing %% and %<unknown> */
-#ifdef HAVE_LOCALE_H
#ifdef ZTS
struct lconv lconv;
#else
struct lconv *lconv = NULL;
#endif
-#endif
/*
* Flag variables
@@ -1026,7 +1019,6 @@ static int format_converter(register buffy * odp, const char *fmt, va_list ap) /
s = "INF";
s_len = 3;
} else {
-#ifdef HAVE_LOCALE_H
#ifdef ZTS
localeconv_r(&lconv);
#else
@@ -1034,7 +1026,6 @@ static int format_converter(register buffy * odp, const char *fmt, va_list ap) /
lconv = localeconv();
}
#endif
-#endif
s = php_conv_fp((*fmt == 'f')?'F':*fmt, fp_num, alternate_form,
(adjust_precision == NO) ? FLOAT_DIGITS : precision,
(*fmt == 'f')?LCONV_DECIMAL_POINT:'.',
@@ -1087,7 +1078,6 @@ static int format_converter(register buffy * odp, const char *fmt, va_list ap) /
/*
* * We use &num_buf[ 1 ], so that we have room for the sign
*/
-#ifdef HAVE_LOCALE_H
#ifdef ZTS
localeconv_r(&lconv);
#else
@@ -1095,7 +1085,6 @@ static int format_converter(register buffy * odp, const char *fmt, va_list ap) /
lconv = localeconv();
}
#endif
-#endif
s = php_gcvt(fp_num, precision, (*fmt=='H' || *fmt == 'k') ? '.' : LCONV_DECIMAL_POINT, (*fmt == 'G' || *fmt == 'H')?'E':'e', &num_buf[1]);
if (*s == '-') {
prefix_char = *s++;
@@ -1199,7 +1188,7 @@ fmt_error:
s_len--;
min_width--;
}
- PAD((size_t)min_width, s_len, pad_char);
+ PAD(min_width, s_len, pad_char);
}
/*
* Print the string s.
@@ -1210,7 +1199,7 @@ fmt_error:
}
if (adjust_width && adjust == LEFT && (size_t)min_width > s_len)
- PAD((size_t)min_width, s_len, pad_char);
+ PAD(min_width, s_len, pad_char);
if (free_zcopy) {
zval_ptr_dtor_str(&zcopy);
}
@@ -1342,12 +1331,3 @@ PHPAPI int ap_php_asprintf(char **buf, const char *format, ...) /* {{{ */
return cc;
}
/* }}} */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/snprintf.h b/main/snprintf.h
index 9dd27e662a..93d2034bb6 100644
--- a/main/snprintf.h
+++ b/main/snprintf.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -44,7 +44,7 @@ spprintf is the dynamical version of snprintf. It allocates the buffer in size
as needed and allows a maximum setting as snprintf (turn this feature
off by setting max_len to 0). spprintf is a little bit slower than
snprintf and offers possible memory leakes if you miss freeing the
- buffer allocated by the function. Therfore this function should be
+ buffer allocated by the function. Therefore this function should be
used where either no maximum is known or the maximum is much bigger
than normal size required. spprintf always terminates the buffer.
@@ -82,7 +82,6 @@ PHPAPI int ap_php_snprintf(char *, size_t, const char *, ...) ZEND_ATTRIBUTE_FOR
PHPAPI int ap_php_vsnprintf(char *, size_t, const char *, va_list ap);
PHPAPI int ap_php_vasprintf(char **buf, const char *format, va_list ap);
PHPAPI int ap_php_asprintf(char **buf, const char *format, ...) ZEND_ATTRIBUTE_FORMAT(printf, 2, 3);
-PHPAPI int php_sprintf (char* s, const char* format, ...) PHP_ATTRIBUTE_FORMAT(printf, 2, 3);
PHPAPI char * php_gcvt(double value, int ndigit, char dec_point, char exponent, char *buf);
PHPAPI char * php_0cvt(double value, int ndigit, char dec_point, char exponent, char *buf);
PHPAPI char * php_conv_fp(char format, double num,
@@ -118,11 +117,6 @@ END_EXTERN_C()
#define asprintf ap_php_asprintf
#endif
-#ifdef sprintf
-#undef sprintf
-#endif
-#define sprintf php_sprintf
-
typedef enum {
LM_STD = 0,
#if SIZEOF_INTMAX_T
@@ -142,8 +136,6 @@ typedef enum {
#ifdef PHP_WIN32
# define WIDE_INT __int64
-#elif SIZEOF_LONG_LONG_INT
-# define WIDE_INT long long int
#elif SIZEOF_LONG_LONG
# define WIDE_INT long long
#else
@@ -170,12 +162,3 @@ PHPAPI char * ap_php_conv_p2(u_wide_int num, int nbits,
#define FORMAT_CONV_MAX_PRECISION 500
#endif /* SNPRINTF_H */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/spprintf.c b/main/spprintf.c
index 464dda492b..a20705016a 100644
--- a/main/spprintf.c
+++ b/main/spprintf.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -89,7 +89,6 @@
#include <inttypes.h>
#endif
-#ifdef HAVE_LOCALE_H
#include <locale.h>
#ifdef ZTS
#include "ext/standard/php_string.h"
@@ -97,9 +96,6 @@
#else
#define LCONV_DECIMAL_POINT (*lconv->decimal_point)
#endif
-#else
-#define LCONV_DECIMAL_POINT '.'
-#endif
#include "snprintf.h"
@@ -215,13 +211,11 @@ static void xbuf_format_converter(void *xbuf, zend_bool is_char, const char *fmt
char num_buf[NUM_BUF_SIZE];
char char_buf[2]; /* for printing %% and %<unknown> */
-#ifdef HAVE_LOCALE_H
#ifdef ZTS
struct lconv lconv;
#else
struct lconv *lconv = NULL;
#endif
-#endif
/*
* Flag variables
@@ -633,7 +627,6 @@ static void xbuf_format_converter(void *xbuf, zend_bool is_char, const char *fmt
s = "inf";
s_len = 3;
} else {
-#ifdef HAVE_LOCALE_H
#ifdef ZTS
localeconv_r(&lconv);
#else
@@ -641,7 +634,6 @@ static void xbuf_format_converter(void *xbuf, zend_bool is_char, const char *fmt
lconv = localeconv();
}
#endif
-#endif
s = php_conv_fp((*fmt == 'f')?'F':*fmt, fp_num, alternate_form,
(adjust_precision == NO) ? FLOAT_DIGITS : precision,
(*fmt == 'f')?LCONV_DECIMAL_POINT:'.',
@@ -693,7 +685,6 @@ static void xbuf_format_converter(void *xbuf, zend_bool is_char, const char *fmt
/*
* * We use &num_buf[ 1 ], so that we have room for the sign
*/
-#ifdef HAVE_LOCALE_H
#ifdef ZTS
localeconv_r(&lconv);
#else
@@ -701,7 +692,6 @@ static void xbuf_format_converter(void *xbuf, zend_bool is_char, const char *fmt
lconv = localeconv();
}
#endif
-#endif
s = php_gcvt(fp_num, precision, (*fmt=='H' || *fmt == 'k') ? '.' : LCONV_DECIMAL_POINT, (*fmt == 'G' || *fmt == 'H')?'E':'e', &num_buf[1]);
if (*s == '-')
prefix_char = *s++;
@@ -836,12 +826,3 @@ PHPAPI void php_printf_to_smart_str(smart_str *buf, const char *format, va_list
xbuf_format_converter(buf, 0, format, ap);
}
/* }}} */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/spprintf.h b/main/spprintf.h
index a0c687b6eb..bbb7add25c 100644
--- a/main/spprintf.h
+++ b/main/spprintf.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -33,13 +33,4 @@ END_EXTERN_C()
#define vspprintf zend_vspprintf
#define vstrpprintf zend_vstrpprintf
-#endif /* SNPRINTF_H */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
+#endif /* SPPRINTF_H */
diff --git a/main/streams/cast.c b/main/streams/cast.c
index 6cfa651977..262ec5e38f 100644
--- a/main/streams/cast.c
+++ b/main/streams/cast.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -84,7 +84,8 @@ static int stream_cookie_closer(void *cookie)
/* prevent recursion */
stream->fclose_stdiocast = PHP_STREAM_FCLOSE_NONE;
- return php_stream_free(stream, PHP_STREAM_FREE_CLOSE | PHP_STREAM_FREE_KEEP_RSRC);
+ return php_stream_free(stream,
+ PHP_STREAM_FREE_CLOSE | PHP_STREAM_FREE_KEEP_RSRC | PHP_STREAM_FREE_RSRC_DTOR);
}
#elif defined(HAVE_FOPENCOOKIE)
static ssize_t stream_cookie_reader(void *cookie, char *buffer, size_t size)
@@ -126,7 +127,8 @@ static int stream_cookie_closer(void *cookie)
/* prevent recursion */
stream->fclose_stdiocast = PHP_STREAM_FCLOSE_NONE;
- return php_stream_free(stream, PHP_STREAM_FREE_CLOSE | PHP_STREAM_FREE_KEEP_RSRC);
+ return php_stream_free(stream,
+ PHP_STREAM_FREE_CLOSE | PHP_STREAM_FREE_KEEP_RSRC | PHP_STREAM_FREE_RSRC_DTOR);
}
#endif /* elif defined(HAVE_FOPENCOOKIE) */
@@ -404,12 +406,3 @@ PHPAPI int _php_stream_make_seekable(php_stream *origstream, php_stream **newstr
return PHP_STREAM_RELEASED;
}
/* }}} */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/main/streams/filter.c b/main/streams/filter.c
index c66d193c6b..f536b92a02 100644
--- a/main/streams/filter.c
+++ b/main/streams/filter.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -239,8 +239,9 @@ PHPAPI php_stream_filter *php_stream_filter_create(const char *filtername, zval
memcpy(wildname, filtername, n+1);
period = wildname + (period - filtername);
while (period && !filter) {
- *period = '\0';
- strncat(wildname, ".*", 2);
+ ZEND_ASSERT(period[0] == '.');
+ period[1] = '*';
+ period[2] = '\0';
if (NULL != (factory = zend_hash_str_find_ptr(filter_hash, wildname, strlen(wildname)))) {
filter = factory->create_filter(filtername, filterparams, persistent);
}
@@ -501,12 +502,3 @@ PHPAPI php_stream_filter *php_stream_filter_remove(php_stream_filter *filter, in
}
return filter;
}
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/main/streams/glob_wrapper.c b/main/streams/glob_wrapper.c
index dcdbabf185..0e72558a2a 100644
--- a/main/streams/glob_wrapper.c
+++ b/main/streams/glob_wrapper.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -45,7 +45,7 @@ typedef struct {
size_t pattern_len;
} glob_s_t;
-PHPAPI char* _php_glob_stream_get_path(php_stream *stream, int copy, size_t *plen STREAMS_DC) /* {{{ */
+PHPAPI char* _php_glob_stream_get_path(php_stream *stream, size_t *plen STREAMS_DC) /* {{{ */
{
glob_s_t *pglob = (glob_s_t *)stream->abstract;
@@ -53,11 +53,7 @@ PHPAPI char* _php_glob_stream_get_path(php_stream *stream, int copy, size_t *ple
if (plen) {
*plen = pglob->path_len;
}
- if (copy) {
- return estrndup(pglob->path, pglob->path_len);
- } else {
- return pglob->path;
- }
+ return pglob->path;
} else {
if (plen) {
*plen = 0;
@@ -67,7 +63,7 @@ PHPAPI char* _php_glob_stream_get_path(php_stream *stream, int copy, size_t *ple
}
/* }}} */
-PHPAPI char* _php_glob_stream_get_pattern(php_stream *stream, int copy, size_t *plen STREAMS_DC) /* {{{ */
+PHPAPI char* _php_glob_stream_get_pattern(php_stream *stream, size_t *plen STREAMS_DC) /* {{{ */
{
glob_s_t *pglob = (glob_s_t *)stream->abstract;
@@ -75,11 +71,7 @@ PHPAPI char* _php_glob_stream_get_pattern(php_stream *stream, int copy, size_t *
if (plen) {
*plen = pglob->pattern_len;
}
- if (copy) {
- return estrndup(pglob->pattern, pglob->pattern_len);
- } else {
- return pglob->pattern;
- }
+ return pglob->pattern;
} else {
if (plen) {
*plen = 0;
@@ -135,7 +127,7 @@ static void php_glob_stream_path_split(glob_s_t *pglob, const char *path, int ge
}
/* }}} */
-static size_t php_glob_stream_read(php_stream *stream, char *buf, size_t count) /* {{{ */
+static ssize_t php_glob_stream_read(php_stream *stream, char *buf, size_t count) /* {{{ */
{
glob_s_t *pglob = (glob_s_t *)stream->abstract;
php_stream_dirent *ent = (php_stream_dirent*)buf;
@@ -155,7 +147,7 @@ static size_t php_glob_stream_read(php_stream *stream, char *buf, size_t count)
}
}
- return 0;
+ return -1;
}
/* }}} */
@@ -279,12 +271,3 @@ const php_stream_wrapper php_glob_stream_wrapper = {
0
};
#endif /* HAVE_GLOB */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/main/streams/memory.c b/main/streams/memory.c
index d088f43c2f..4b92fc2ffd 100644
--- a/main/streams/memory.c
+++ b/main/streams/memory.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -44,13 +44,13 @@ typedef struct {
/* {{{ */
-static size_t php_stream_memory_write(php_stream *stream, const char *buf, size_t count)
+static ssize_t php_stream_memory_write(php_stream *stream, const char *buf, size_t count)
{
php_stream_memory_data *ms = (php_stream_memory_data*)stream->abstract;
assert(ms != NULL);
if (ms->mode & TEMP_STREAM_READONLY) {
- return 0;
+ return (ssize_t) -1;
} else if (ms->mode & TEMP_STREAM_APPEND) {
ms->fpos = ms->fsize;
}
@@ -77,7 +77,7 @@ static size_t php_stream_memory_write(php_stream *stream, const char *buf, size_
/* {{{ */
-static size_t php_stream_memory_read(php_stream *stream, char *buf, size_t count)
+static ssize_t php_stream_memory_read(php_stream *stream, char *buf, size_t count)
{
php_stream_memory_data *ms = (php_stream_memory_data*)stream->abstract;
assert(ms != NULL);
@@ -368,7 +368,7 @@ typedef struct {
/* {{{ */
-static size_t php_stream_temp_write(php_stream *stream, const char *buf, size_t count)
+static ssize_t php_stream_temp_write(php_stream *stream, const char *buf, size_t count)
{
php_stream_temp_data *ts = (php_stream_temp_data*)stream->abstract;
assert(ts != NULL);
@@ -398,7 +398,7 @@ static size_t php_stream_temp_write(php_stream *stream, const char *buf, size_t
/* {{{ */
-static size_t php_stream_temp_read(php_stream *stream, char *buf, size_t count)
+static ssize_t php_stream_temp_read(php_stream *stream, char *buf, size_t count)
{
php_stream_temp_data *ts = (php_stream_temp_data*)stream->abstract;
size_t got;
@@ -789,12 +789,3 @@ PHPAPI const php_stream_wrapper php_stream_rfc2397_wrapper = {
NULL,
1, /* is_url */
};
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/main/streams/mmap.c b/main/streams/mmap.c
index 94c80a9dc5..63bae87505 100644
--- a/main/streams/mmap.c
+++ b/main/streams/mmap.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -29,12 +29,6 @@ PHPAPI char *_php_stream_mmap_range(php_stream *stream, size_t offset, size_t le
range.mode = mode;
range.mapped = NULL;
- /* For now, we impose an arbitrary limit to avoid
- * runaway swapping when large files are passed through. */
- if (length > 4 * 1024 * 1024) {
- return NULL;
- }
-
if (PHP_STREAM_OPTION_RETURN_OK == php_stream_set_option(stream, PHP_STREAM_OPTION_MMAP_API, PHP_STREAM_MMAP_MAP_RANGE, &range)) {
if (mapped_len) {
*mapped_len = range.length;
@@ -46,7 +40,7 @@ PHPAPI char *_php_stream_mmap_range(php_stream *stream, size_t offset, size_t le
PHPAPI int _php_stream_mmap_unmap(php_stream *stream)
{
- return php_stream_set_option(stream, PHP_STREAM_OPTION_MMAP_API, PHP_STREAM_MMAP_UNMAP, NULL) == PHP_STREAM_OPTION_RETURN_OK ? 1 : 0;
+ return php_stream_set_option(stream, PHP_STREAM_OPTION_MMAP_API, PHP_STREAM_MMAP_UNMAP, NULL) == PHP_STREAM_OPTION_RETURN_OK;
}
PHPAPI int _php_stream_mmap_unmap_ex(php_stream *stream, zend_off_t readden)
@@ -62,12 +56,3 @@ PHPAPI int _php_stream_mmap_unmap_ex(php_stream *stream, zend_off_t readden)
return ret;
}
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/main/streams/php_stream_context.h b/main/streams/php_stream_context.h
index 083178b23a..c477dda4ac 100644
--- a/main/streams/php_stream_context.h
+++ b/main/streams/php_stream_context.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -114,13 +114,3 @@ END_EXTERN_C()
#define php_stream_notify_error(context, code, xmsg, xcode) do { if ((context) && (context)->notifier) {\
php_stream_notification_notify((context), (code), PHP_STREAM_NOTIFY_SEVERITY_ERR, \
(xmsg), (xcode), 0, 0, NULL); } } while(0)
-
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/streams/php_stream_filter_api.h b/main/streams/php_stream_filter_api.h
index 09714249b8..4d5760e2cf 100644
--- a/main/streams/php_stream_filter_api.h
+++ b/main/streams/php_stream_filter_api.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -21,7 +21,7 @@
/* The filter API works on the principle of "Bucket-Brigades". This is
* partially inspired by the Apache 2 method of doing things, although
- * it is intentially a light-weight implementation.
+ * it is intentionally a light-weight implementation.
*
* Each stream can have a chain of filters for reading and another for writing.
*
@@ -149,12 +149,3 @@ PHPAPI int php_stream_filter_unregister_factory(const char *filterpattern);
PHPAPI int php_stream_filter_register_factory_volatile(zend_string *filterpattern, const php_stream_filter_factory *factory);
PHPAPI php_stream_filter *php_stream_filter_create(const char *filtername, zval *filterparams, uint8_t persistent);
END_EXTERN_C()
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/streams/php_stream_glob_wrapper.h b/main/streams/php_stream_glob_wrapper.h
index 174fb4f395..644e5ab7e4 100644
--- a/main/streams/php_stream_glob_wrapper.h
+++ b/main/streams/php_stream_glob_wrapper.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -21,22 +21,13 @@ PHPAPI extern const php_stream_ops php_glob_stream_ops;
BEGIN_EXTERN_C()
-PHPAPI char* _php_glob_stream_get_path(php_stream *stream, int copy, size_t *plen STREAMS_DC);
-#define php_glob_stream_get_path(stream, copy, plen) _php_glob_stream_get_path((stream), (copy), (plen) STREAMS_CC)
+PHPAPI char* _php_glob_stream_get_path(php_stream *stream, size_t *plen STREAMS_DC);
+#define php_glob_stream_get_path(stream, plen) _php_glob_stream_get_path((stream), (plen) STREAMS_CC)
-PHPAPI char* _php_glob_stream_get_pattern(php_stream *stream, int copy, size_t *plen STREAMS_DC);
-#define php_glob_stream_get_pattern(stream, copy, plen) _php_glob_stream_get_pattern((stream), (copy), (plen) STREAMS_CC)
+PHPAPI char* _php_glob_stream_get_pattern(php_stream *stream, size_t *plen STREAMS_DC);
+#define php_glob_stream_get_pattern(stream, plen) _php_glob_stream_get_pattern((stream), (plen) STREAMS_CC)
PHPAPI int _php_glob_stream_get_count(php_stream *stream, int *pflags STREAMS_DC);
#define php_glob_stream_get_count(stream, pflags) _php_glob_stream_get_count((stream), (pflags) STREAMS_CC)
END_EXTERN_C()
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/streams/php_stream_mmap.h b/main/streams/php_stream_mmap.h
index 6db0bdcb90..132f3214c1 100644
--- a/main/streams/php_stream_mmap.h
+++ b/main/streams/php_stream_mmap.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -75,12 +75,3 @@ PHPAPI int _php_stream_mmap_unmap(php_stream *stream);
PHPAPI int _php_stream_mmap_unmap_ex(php_stream *stream, zend_off_t readden);
#define php_stream_mmap_unmap_ex(stream, readden) _php_stream_mmap_unmap_ex((stream), (readden))
END_EXTERN_C()
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/main/streams/php_stream_plain_wrapper.h b/main/streams/php_stream_plain_wrapper.h
index 17c0e72082..4af8b86cdd 100644
--- a/main/streams/php_stream_plain_wrapper.h
+++ b/main/streams/php_stream_plain_wrapper.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -56,12 +56,3 @@ PHPAPI FILE * _php_stream_open_wrapper_as_file(char * path, char * mode, int opt
PHPAPI int php_stream_parse_fopen_modes(const char *mode, int *open_flags);
END_EXTERN_C()
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/streams/php_stream_transport.h b/main/streams/php_stream_transport.h
index a4a851b399..f49d9c787d 100644
--- a/main/streams/php_stream_transport.h
+++ b/main/streams/php_stream_transport.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -171,21 +171,23 @@ typedef enum {
STREAM_CRYPTO_METHOD_TLSv1_0_CLIENT = (1 << 3 | 1),
STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT = (1 << 4 | 1),
STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT = (1 << 5 | 1),
+ STREAM_CRYPTO_METHOD_TLSv1_3_CLIENT = (1 << 6 | 1),
/* TLS equates to TLS_ANY as of PHP 7.2 */
- STREAM_CRYPTO_METHOD_TLS_CLIENT = ((1 << 3) | (1 << 4) | (1 << 5) | 1),
- STREAM_CRYPTO_METHOD_TLS_ANY_CLIENT = ((1 << 3) | (1 << 4) | (1 << 5) | 1),
- STREAM_CRYPTO_METHOD_ANY_CLIENT = ((1 << 1) | (1 << 2) | (1 << 3) | (1 << 4) | (1 << 5) | 1),
+ STREAM_CRYPTO_METHOD_TLS_CLIENT = ((1 << 3) | (1 << 4) | (1 << 5) | (1 << 6) | 1),
+ STREAM_CRYPTO_METHOD_TLS_ANY_CLIENT = ((1 << 3) | (1 << 4) | (1 << 5) | (1 << 6) | 1),
+ STREAM_CRYPTO_METHOD_ANY_CLIENT = ((1 << 1) | (1 << 2) | (1 << 3) | (1 << 4) | (1 << 5) | (1 << 6) | 1),
STREAM_CRYPTO_METHOD_SSLv2_SERVER = (1 << 1),
STREAM_CRYPTO_METHOD_SSLv3_SERVER = (1 << 2),
/* v23 no longer negotiates SSL2 or SSL3 */
- STREAM_CRYPTO_METHOD_SSLv23_SERVER = ((1 << 3) | (1 << 4) | (1 << 5)),
+ STREAM_CRYPTO_METHOD_SSLv23_SERVER = ((1 << 3) | (1 << 4) | (1 << 5) | (1 << 6)),
STREAM_CRYPTO_METHOD_TLSv1_0_SERVER = (1 << 3),
STREAM_CRYPTO_METHOD_TLSv1_1_SERVER = (1 << 4),
STREAM_CRYPTO_METHOD_TLSv1_2_SERVER = (1 << 5),
+ STREAM_CRYPTO_METHOD_TLSv1_3_SERVER = (1 << 6),
/* TLS equates to TLS_ANY as of PHP 7.2 */
- STREAM_CRYPTO_METHOD_TLS_SERVER = ((1 << 3) | (1 << 4) | (1 << 5)),
- STREAM_CRYPTO_METHOD_TLS_ANY_SERVER = ((1 << 3) | (1 << 4) | (1 << 5)),
- STREAM_CRYPTO_METHOD_ANY_SERVER = ((1 << 1) | (1 << 2) | (1 << 3) | (1 << 4) | (1 << 5))
+ STREAM_CRYPTO_METHOD_TLS_SERVER = ((1 << 3) | (1 << 4) | (1 << 5) | (1 << 6)),
+ STREAM_CRYPTO_METHOD_TLS_ANY_SERVER = ((1 << 3) | (1 << 4) | (1 << 5) | (1 << 6)),
+ STREAM_CRYPTO_METHOD_ANY_SERVER = ((1 << 1) | (1 << 2) | (1 << 3) | (1 << 4) | (1 << 5) | (1 << 6))
} php_stream_xport_crypt_method_t;
/* These functions provide crypto support on the underlying transport */
@@ -214,12 +216,3 @@ BEGIN_EXTERN_C()
PHPAPI HashTable *php_stream_xport_get_hash(void);
PHPAPI php_stream_transport_factory_func php_stream_generic_socket_factory;
END_EXTERN_C()
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/main/streams/php_stream_userspace.h b/main/streams/php_stream_userspace.h
index 1324d70da0..389d591921 100644
--- a/main/streams/php_stream_userspace.h
+++ b/main/streams/php_stream_userspace.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -21,12 +21,3 @@ PHPAPI extern const php_stream_ops php_stream_userspace_ops;
PHPAPI extern const php_stream_ops php_stream_userspace_dir_ops;
#define PHP_STREAM_IS_USERSPACE &php_stream_userspace_ops
#define PHP_STREAM_IS_USERSPACE_DIR &php_stream_userspace_dir_ops
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/streams/php_streams_int.h b/main/streams/php_streams_int.h
index addaf0ce7b..1bc6fdc89c 100644
--- a/main/streams/php_streams_int.h
+++ b/main/streams/php_streams_int.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
diff --git a/main/streams/plain_wrapper.c b/main/streams/plain_wrapper.c
index c975997981..8f7774a30e 100644
--- a/main/streams/plain_wrapper.c
+++ b/main/streams/plain_wrapper.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -125,10 +125,12 @@ typedef struct {
FILE *file;
int fd; /* underlying file descriptor */
unsigned is_process_pipe:1; /* use pclose instead of fclose */
- unsigned is_pipe:1; /* don't try and seek */
+ unsigned is_pipe:1; /* stream is an actual pipe, currently Windows only*/
unsigned cached_fstat:1; /* sb is valid */
unsigned is_pipe_blocking:1; /* allow blocking read() on pipes, currently Windows only */
- unsigned _reserved:28;
+ unsigned no_forced_fstat:1; /* Use fstat cache even if forced */
+ unsigned is_seekable:1; /* don't try and seek, if not set */
+ unsigned _reserved:26;
int lock_flag; /* stores the lock state */
zend_string *temp_name; /* if non-null, this is the path to a temporary file that
@@ -152,7 +154,7 @@ typedef struct {
static int do_fstat(php_stdio_stream_data *d, int force)
{
- if (!d->cached_fstat || force) {
+ if (!d->cached_fstat || (force && !d->no_forced_fstat)) {
int fd;
int r;
@@ -172,6 +174,7 @@ static php_stream *_php_stream_fopen_from_fd_int(int fd, const char *mode, const
self = pemalloc_rel_orig(sizeof(*self), persistent_id);
memset(self, 0, sizeof(*self));
self->file = NULL;
+ self->is_seekable = 1;
self->is_pipe = 0;
self->lock_flag = LOCK_UN;
self->is_process_pipe = 0;
@@ -191,6 +194,7 @@ static php_stream *_php_stream_fopen_from_file_int(FILE *file, const char *mode
self = emalloc_rel_orig(sizeof(*self));
memset(self, 0, sizeof(*self));
self->file = file;
+ self->is_seekable = 1;
self->is_pipe = 0;
self->lock_flag = LOCK_UN;
self->is_process_pipe = 0;
@@ -241,6 +245,24 @@ PHPAPI php_stream *_php_stream_fopen_tmpfile(int dummy STREAMS_DC)
return php_stream_fopen_temporary_file(NULL, "php", NULL);
}
+static void detect_is_seekable(php_stdio_stream_data *self) {
+#if defined(S_ISFIFO) && defined(S_ISCHR)
+ if (self->fd >= 0 && do_fstat(self, 0) == 0) {
+ self->is_seekable = !(S_ISFIFO(self->sb.st_mode) || S_ISCHR(self->sb.st_mode));
+ self->is_pipe = S_ISFIFO(self->sb.st_mode);
+ }
+#elif defined(PHP_WIN32)
+ zend_uintptr_t handle = _get_osfhandle(self->fd);
+
+ if (handle != (zend_uintptr_t)INVALID_HANDLE_VALUE) {
+ DWORD file_type = GetFileType((HANDLE)handle);
+
+ self->is_seekable = !(file_type == FILE_TYPE_PIPE || file_type == FILE_TYPE_CHAR);
+ self->is_pipe = file_type == FILE_TYPE_PIPE;
+ }
+#endif
+}
+
PHPAPI php_stream *_php_stream_fopen_from_fd(int fd, const char *mode, const char *persistent_id STREAMS_DC)
{
php_stream *stream = php_stream_fopen_from_fd_int_rel(fd, mode, persistent_id);
@@ -248,30 +270,17 @@ PHPAPI php_stream *_php_stream_fopen_from_fd(int fd, const char *mode, const cha
if (stream) {
php_stdio_stream_data *self = (php_stdio_stream_data*)stream->abstract;
-#ifdef S_ISFIFO
- /* detect if this is a pipe */
- if (self->fd >= 0) {
- self->is_pipe = (do_fstat(self, 0) == 0 && S_ISFIFO(self->sb.st_mode)) ? 1 : 0;
- }
-#elif defined(PHP_WIN32)
- {
- zend_uintptr_t handle = _get_osfhandle(self->fd);
-
- if (handle != (zend_uintptr_t)INVALID_HANDLE_VALUE) {
- self->is_pipe = GetFileType((HANDLE)handle) == FILE_TYPE_PIPE;
- }
- }
-#endif
-
- if (self->is_pipe) {
+ detect_is_seekable(self);
+ if (!self->is_seekable) {
stream->flags |= PHP_STREAM_FLAG_NO_SEEK;
+ stream->position = -1;
} else {
stream->position = zend_lseek(self->fd, 0, SEEK_CUR);
#ifdef ESPIPE
+ /* FIXME: Is this code still needed? */
if (stream->position == (zend_off_t)-1 && errno == ESPIPE) {
- stream->position = 0;
stream->flags |= PHP_STREAM_FLAG_NO_SEEK;
- self->is_pipe = 1;
+ self->is_seekable = 0;
}
#endif
}
@@ -287,23 +296,10 @@ PHPAPI php_stream *_php_stream_fopen_from_file(FILE *file, const char *mode STRE
if (stream) {
php_stdio_stream_data *self = (php_stdio_stream_data*)stream->abstract;
-#ifdef S_ISFIFO
- /* detect if this is a pipe */
- if (self->fd >= 0) {
- self->is_pipe = (do_fstat(self, 0) == 0 && S_ISFIFO(self->sb.st_mode)) ? 1 : 0;
- }
-#elif defined(PHP_WIN32)
- {
- zend_uintptr_t handle = _get_osfhandle(self->fd);
-
- if (handle != (zend_uintptr_t)INVALID_HANDLE_VALUE) {
- self->is_pipe = GetFileType((HANDLE)handle) == FILE_TYPE_PIPE;
- }
- }
-#endif
-
- if (self->is_pipe) {
+ detect_is_seekable(self);
+ if (!self->is_seekable) {
stream->flags |= PHP_STREAM_FLAG_NO_SEEK;
+ stream->position = -1;
} else {
stream->position = zend_ftell(file);
}
@@ -320,6 +316,7 @@ PHPAPI php_stream *_php_stream_fopen_from_pipe(FILE *file, const char *mode STRE
self = emalloc_rel_orig(sizeof(*self));
memset(self, 0, sizeof(*self));
self->file = file;
+ self->is_seekable = 0;
self->is_pipe = 1;
self->lock_flag = LOCK_UN;
self->is_process_pipe = 1;
@@ -334,7 +331,7 @@ PHPAPI php_stream *_php_stream_fopen_from_pipe(FILE *file, const char *mode STRE
return stream;
}
-static size_t php_stdiop_write(php_stream *stream, const char *buf, size_t count)
+static ssize_t php_stdiop_write(php_stream *stream, const char *buf, size_t count)
{
php_stdio_stream_data *data = (php_stdio_stream_data*)stream->abstract;
@@ -342,33 +339,42 @@ static size_t php_stdiop_write(php_stream *stream, const char *buf, size_t count
if (data->fd >= 0) {
#ifdef PHP_WIN32
- int bytes_written;
+ ssize_t bytes_written;
if (ZEND_SIZE_T_UINT_OVFL(count)) {
count = UINT_MAX;
}
bytes_written = _write(data->fd, buf, (unsigned int)count);
#else
- int bytes_written = write(data->fd, buf, count);
+ ssize_t bytes_written = write(data->fd, buf, count);
#endif
- if (bytes_written < 0) return 0;
- return (size_t) bytes_written;
+ if (bytes_written < 0) {
+ if (errno == EWOULDBLOCK || errno == EAGAIN) {
+ return 0;
+ }
+ if (errno == EINTR) {
+ /* 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));
+ }
+ return bytes_written;
} else {
#if HAVE_FLUSHIO
- if (!data->is_pipe && data->last_op == 'r') {
+ if (data->is_seekable && data->last_op == 'r') {
zend_fseek(data->file, 0, SEEK_CUR);
}
data->last_op = 'w';
#endif
- return fwrite(buf, 1, count, data->file);
+ return (ssize_t) fwrite(buf, 1, count, data->file);
}
}
-static size_t php_stdiop_read(php_stream *stream, char *buf, size_t count)
+static ssize_t php_stdiop_read(php_stream *stream, char *buf, size_t count)
{
php_stdio_stream_data *data = (php_stdio_stream_data*)stream->abstract;
- size_t ret;
+ ssize_t ret;
assert(data != NULL);
@@ -410,11 +416,27 @@ static size_t php_stdiop_read(php_stream *stream, char *buf, size_t count)
ret = read(data->fd, buf, PLAIN_WRAP_BUF_SIZE(count));
}
- stream->eof = (ret == 0 || (ret == (size_t)-1 && errno != EWOULDBLOCK && errno != EINTR && errno != EBADF));
+ if (ret < 0) {
+ if (errno == EWOULDBLOCK || errno == EAGAIN) {
+ /* Not an error. */
+ ret = 0;
+ } 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));
+
+ /* TODO: Remove this special-case? */
+ if (errno != EBADF) {
+ stream->eof = 1;
+ }
+ }
+ } else if (ret == 0) {
+ stream->eof = 1;
+ }
} else {
#if HAVE_FLUSHIO
- if (!data->is_pipe && data->last_op == 'w')
+ if (data->is_seekable && data->last_op == 'w')
zend_fseek(data->file, 0, SEEK_CUR);
data->last_op = 'r';
#endif
@@ -515,8 +537,8 @@ static int php_stdiop_seek(php_stream *stream, zend_off_t offset, int whence, ze
assert(data != NULL);
- if (data->is_pipe) {
- php_error_docref(NULL, E_WARNING, "cannot seek on a pipe");
+ if (!data->is_seekable) {
+ php_error_docref(NULL, E_WARNING, "cannot seek on this stream");
return -1;
}
@@ -920,19 +942,18 @@ PHPAPI php_stream_ops php_stream_stdio_ops = {
/* }}} */
/* {{{ plain files opendir/readdir implementation */
-static size_t php_plain_files_dirstream_read(php_stream *stream, char *buf, size_t count)
+static ssize_t php_plain_files_dirstream_read(php_stream *stream, char *buf, size_t count)
{
DIR *dir = (DIR*)stream->abstract;
- /* avoid libc5 readdir problems */
- char entry[sizeof(struct dirent)+MAXPATHLEN];
- struct dirent *result = (struct dirent *)&entry;
+ struct dirent *result;
php_stream_dirent *ent = (php_stream_dirent*)buf;
/* avoid problems if someone mis-uses the stream */
if (count != sizeof(php_stream_dirent))
- return 0;
+ return -1;
- if (php_readdir_r(dir, (struct dirent *)entry, &result) == 0 && result) {
+ result = readdir(dir);
+ if (result) {
PHP_STRLCPY(ent->d_name, result->d_name, sizeof(ent->d_name), strlen(result->d_name));
return sizeof(php_stream_dirent);
}
@@ -1077,6 +1098,10 @@ PHPAPI php_stream *_php_stream_fopen(const char *filename, const char *mode, zen
php_stream_close(ret);
return NULL;
}
+
+ /* Make sure the fstat result is reused when we later try to get the
+ * file size. */
+ self->no_forced_fstat = 1;
}
if (options & STREAM_USE_BLOCKING_PIPE) {
@@ -1614,12 +1639,3 @@ stream_skip:
}
/* }}} */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/main/streams/streams.c b/main/streams/streams.c
index 5daf4fe83d..f269f06f3e 100644
--- a/main/streams/streams.c
+++ b/main/streams/streams.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -91,7 +91,11 @@ fprintf(stderr, "forget_persistent: %s:%p\n", stream->ops->label, stream);
PHP_RSHUTDOWN_FUNCTION(streams)
{
- zend_hash_apply(&EG(persistent_list), forget_persistent_resource_id_numbers);
+ zval *el;
+
+ ZEND_HASH_FOREACH_VAL(&EG(persistent_list), el) {
+ forget_persistent_resource_id_numbers(el);
+ } ZEND_HASH_FOREACH_END();
return SUCCESS;
}
@@ -363,15 +367,22 @@ PHPAPI int _php_stream_free(php_stream *stream, int close_options) /* {{{ */
int ret = 1;
int preserve_handle = close_options & PHP_STREAM_FREE_PRESERVE_HANDLE ? 1 : 0;
int release_cast = 1;
- php_stream_context *context = NULL;
+ php_stream_context *context;
- /* on an resource list destruction, the context, another resource, may have
- * already been freed (if it was created after the stream resource), so
- * don't reference it */
- if (EG(active)) {
- context = PHP_STREAM_CONTEXT(stream);
+ /* During shutdown resources may be released before other resources still holding them.
+ * When only resoruces are referenced this is not a problem, because they are refcounted
+ * and will only be fully freed once the refcount drops to zero. However, if php_stream*
+ * is held directly, we don't have this guarantee. To avoid use-after-free we ignore all
+ * stream free operations in shutdown unless they come from the resource list destruction,
+ * or by freeing an enclosed stream (in which case resource list destruction will not have
+ * freed it). */
+ if ((EG(flags) & EG_FLAGS_IN_RESOURCE_SHUTDOWN) &&
+ !(close_options & (PHP_STREAM_FREE_RSRC_DTOR|PHP_STREAM_FREE_IGNORE_ENCLOSING))) {
+ return 1;
}
+ context = PHP_STREAM_CONTEXT(stream);
+
if (stream->flags & PHP_STREAM_FLAG_NO_CLOSE) {
preserve_handle = 1;
}
@@ -520,21 +531,20 @@ fprintf(stderr, "stream_free: %s:%p[%s] preserve_handle=%d release_cast=%d remov
/* {{{ generic stream operations */
-PHPAPI void _php_stream_fill_read_buffer(php_stream *stream, size_t size)
+PHPAPI int _php_stream_fill_read_buffer(php_stream *stream, size_t size)
{
/* allocate/fill the buffer */
if (stream->readfilters.head) {
char *chunk_buf;
- int err_flag = 0;
php_stream_bucket_brigade brig_in = { NULL, NULL }, brig_out = { NULL, NULL };
php_stream_bucket_brigade *brig_inp = &brig_in, *brig_outp = &brig_out, *brig_swap;
/* allocate a buffer for reading chunks */
chunk_buf = emalloc(stream->chunk_size);
- while (!stream->eof && !err_flag && (stream->writepos - stream->readpos < (zend_off_t)size)) {
- size_t justread = 0;
+ while (!stream->eof && (stream->writepos - stream->readpos < (zend_off_t)size)) {
+ ssize_t justread = 0;
int flags;
php_stream_bucket *bucket;
php_stream_filter_status_t status = PSFS_ERR_FATAL;
@@ -542,7 +552,10 @@ PHPAPI void _php_stream_fill_read_buffer(php_stream *stream, size_t size)
/* read a chunk into a bucket */
justread = stream->ops->read(stream, chunk_buf, stream->chunk_size);
- if (justread && justread != (size_t)-1) {
+ if (justread < 0 && stream->writepos == stream->readpos) {
+ efree(chunk_buf);
+ return FAILURE;
+ } else if (justread > 0) {
bucket = php_stream_bucket_new(stream, chunk_buf, justread, 0, 0);
/* after this call, bucket is owned by the brigade */
@@ -591,7 +604,9 @@ PHPAPI void _php_stream_fill_read_buffer(php_stream *stream, size_t size)
stream->readbuf = perealloc(stream->readbuf, stream->readbuflen,
stream->is_persistent);
}
- memcpy(stream->readbuf + stream->writepos, bucket->buf, bucket->buflen);
+ if (bucket->buflen) {
+ memcpy(stream->readbuf + stream->writepos, bucket->buf, bucket->buflen);
+ }
stream->writepos += bucket->buflen;
php_stream_bucket_unlink(bucket);
@@ -603,31 +618,28 @@ PHPAPI void _php_stream_fill_read_buffer(php_stream *stream, size_t size)
/* when a filter needs feeding, there is no brig_out to deal with.
* we simply continue the loop; if the caller needs more data,
* we will read again, otherwise out job is done here */
- if (justread == 0) {
- /* there is no data */
- err_flag = 1;
- break;
- }
- continue;
+ break;
case PSFS_ERR_FATAL:
/* some fatal error. Theoretically, the stream is borked, so all
* further reads should fail. */
- err_flag = 1;
- break;
+ stream->eof = 1;
+ efree(chunk_buf);
+ return FAILURE;
}
- if (justread == 0 || justread == (size_t)-1) {
+ if (justread <= 0) {
break;
}
}
efree(chunk_buf);
+ return SUCCESS;
} else {
/* is there enough data in the buffer ? */
if (stream->writepos - stream->readpos < (zend_off_t)size) {
- size_t justread = 0;
+ ssize_t justread = 0;
/* reduce buffer memory consumption if possible, to avoid a realloc */
if (stream->readbuf && stream->readbuflen - stream->writepos < stream->chunk_size) {
@@ -649,17 +661,18 @@ PHPAPI void _php_stream_fill_read_buffer(php_stream *stream, size_t size)
justread = stream->ops->read(stream, (char*)stream->readbuf + stream->writepos,
stream->readbuflen - stream->writepos
);
-
- if (justread != (size_t)-1) {
- stream->writepos += justread;
+ if (justread < 0) {
+ return FAILURE;
}
+ stream->writepos += justread;
}
+ return SUCCESS;
}
}
-PHPAPI size_t _php_stream_read(php_stream *stream, char *buf, size_t size)
+PHPAPI ssize_t _php_stream_read(php_stream *stream, char *buf, size_t size)
{
- size_t toread = 0, didread = 0;
+ ssize_t toread = 0, didread = 0;
while (size > 0) {
@@ -688,15 +701,24 @@ PHPAPI size_t _php_stream_read(php_stream *stream, char *buf, size_t size)
if (!stream->readfilters.head && (stream->flags & PHP_STREAM_FLAG_NO_BUFFER || stream->chunk_size == 1)) {
toread = stream->ops->read(stream, buf, size);
- if (toread == (size_t) -1) {
- /* e.g. underlying read(2) returned -1 */
+ if (toread < 0) {
+ /* Report an error if the read failed and we did not read any data
+ * before that. Otherwise return the data we did read. */
+ if (didread == 0) {
+ return toread;
+ }
break;
}
} else {
- php_stream_fill_read_buffer(stream, size);
+ if (php_stream_fill_read_buffer(stream, size) != SUCCESS) {
+ if (didread == 0) {
+ return -1;
+ }
+ break;
+ }
toread = stream->writepos - stream->readpos;
- if (toread > size) {
+ if ((size_t) toread > size) {
toread = size;
}
@@ -729,6 +751,26 @@ PHPAPI size_t _php_stream_read(php_stream *stream, char *buf, size_t size)
return didread;
}
+/* Like php_stream_read(), but reading into a zend_string buffer. This has some similarity
+ * to the copy_to_mem() operation, but only performs a single direct read. */
+PHPAPI zend_string *php_stream_read_to_str(php_stream *stream, size_t len)
+{
+ zend_string *str = zend_string_alloc(len, 0);
+ ssize_t read = php_stream_read(stream, ZSTR_VAL(str), len);
+ if (read < 0) {
+ zend_string_efree(str);
+ return NULL;
+ }
+
+ ZSTR_LEN(str) = read;
+ ZSTR_VAL(str)[read] = 0;
+
+ if ((size_t) read < len / 2) {
+ return zend_string_truncate(str, read, 0);
+ }
+ return str;
+}
+
PHPAPI int _php_stream_eof(php_stream *stream)
{
/* if there is data in the buffer, it's not EOF */
@@ -772,7 +814,7 @@ PHPAPI int _php_stream_puts(php_stream *stream, const char *buf)
char newline[2] = "\n"; /* is this OK for Win? */
len = strlen(buf);
- if (len > 0 && php_stream_write(stream, buf, len) && php_stream_write(stream, newline, 1)) {
+ if (len > 0 && php_stream_write(stream, buf, len) > 0 && php_stream_write(stream, newline, 1) > 0) {
return 1;
}
return 0;
@@ -1070,9 +1112,9 @@ 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 size_t _php_stream_write_buffer(php_stream *stream, const char *buf, size_t count)
+static ssize_t _php_stream_write_buffer(php_stream *stream, const char *buf, size_t count)
{
- size_t didwrite = 0, towrite, justwrote;
+ ssize_t didwrite = 0, justwrote;
/* 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
@@ -1085,29 +1127,32 @@ static size_t _php_stream_write_buffer(php_stream *stream, const char *buf, size
while (count > 0) {
- towrite = count;
+ size_t towrite = count;
if (towrite > stream->chunk_size)
towrite = stream->chunk_size;
justwrote = stream->ops->write(stream, buf, towrite);
+ if (justwrote <= 0) {
+ /* If we already successfully wrote some bytes and a write error occurred
+ * later, report the successfully written bytes. */
+ if (didwrite == 0) {
+ return justwrote;
+ }
+ return didwrite;
+ }
- /* convert justwrote to an integer, since normally it is unsigned */
- if ((int)justwrote > 0) {
- buf += justwrote;
- count -= justwrote;
- didwrite += justwrote;
+ buf += justwrote;
+ count -= justwrote;
+ didwrite += justwrote;
- /* Only screw with the buffer if we can seek, otherwise we lose data
- * buffered from fifos and sockets */
- if (stream->ops->seek && (stream->flags & PHP_STREAM_FLAG_NO_SEEK) == 0) {
- stream->position += justwrote;
- }
- } else {
- break;
+ /* Only screw with the buffer if we can seek, otherwise we lose data
+ * buffered from fifos and sockets */
+ if (stream->ops->seek && (stream->flags & PHP_STREAM_FLAG_NO_SEEK) == 0) {
+ stream->position += justwrote;
}
}
- return didwrite;
+ return didwrite;
}
/* push some data through the write filter chain.
@@ -1115,7 +1160,7 @@ static size_t _php_stream_write_buffer(php_stream *stream, const char *buf, size
* This may trigger a real write to the stream.
* Returns the number of bytes consumed from buf by the first filter in the chain.
* */
-static size_t _php_stream_write_filtered(php_stream *stream, const char *buf, size_t count, int flags)
+static ssize_t _php_stream_write_filtered(php_stream *stream, const char *buf, size_t count, int flags)
{
size_t consumed = 0;
php_stream_bucket *bucket;
@@ -1153,7 +1198,10 @@ static size_t _php_stream_write_filtered(php_stream *stream, const char *buf, si
* underlying stream */
while (brig_inp->head) {
bucket = brig_inp->head;
- _php_stream_write_buffer(stream, bucket->buf, bucket->buflen);
+ if (_php_stream_write_buffer(stream, bucket->buf, bucket->buflen) < 0) {
+ consumed = (ssize_t) -1;
+ }
+
/* Potential error situation - eg: no space on device. Perhaps we should keep this brigade
* hanging around and try to write it later.
* At the moment, we just drop it on the floor
@@ -1170,7 +1218,7 @@ static size_t _php_stream_write_filtered(php_stream *stream, const char *buf, si
case PSFS_ERR_FATAL:
/* some fatal error. Theoretically, the stream is borked, so all
* further writes should fail. */
- break;
+ return (ssize_t) -1;
}
return consumed;
@@ -1193,14 +1241,20 @@ PHPAPI int _php_stream_flush(php_stream *stream, int closing)
return ret;
}
-PHPAPI size_t _php_stream_write(php_stream *stream, const char *buf, size_t count)
+PHPAPI ssize_t _php_stream_write(php_stream *stream, const char *buf, size_t count)
{
- size_t bytes;
+ ssize_t bytes;
- if (buf == NULL || count == 0 || stream->ops->write == NULL) {
+ if (count == 0) {
return 0;
}
+ ZEND_ASSERT(buf != NULL);
+ if (stream->ops->write == NULL) {
+ php_error_docref(NULL, E_NOTICE, "Stream is not writable");
+ return (ssize_t) -1;
+ }
+
if (stream->writefilters.head) {
bytes = _php_stream_write_filtered(stream, buf, count, PSFS_FLAG_NORMAL);
} else {
@@ -1214,9 +1268,9 @@ PHPAPI size_t _php_stream_write(php_stream *stream, const char *buf, size_t coun
return bytes;
}
-PHPAPI size_t _php_stream_printf(php_stream *stream, const char *fmt, ...)
+PHPAPI ssize_t _php_stream_printf(php_stream *stream, const char *fmt, ...)
{
- size_t count;
+ ssize_t count;
char *buf;
va_list ap;
@@ -1225,7 +1279,7 @@ PHPAPI size_t _php_stream_printf(php_stream *stream, const char *fmt, ...)
va_end(ap);
if (!buf) {
- return 0; /* error condition */
+ return -1; /* error condition */
}
count = php_stream_write(stream, buf, count);
@@ -1302,9 +1356,9 @@ PHPAPI int _php_stream_seek(php_stream *stream, zend_off_t offset, int whence)
/* emulate forward moving seeks with reads */
if (whence == SEEK_CUR && offset >= 0) {
char tmp[1024];
- size_t didread;
- while(offset > 0) {
- if ((didread = php_stream_read(stream, tmp, MIN(offset, sizeof(tmp)))) == 0) {
+ ssize_t didread;
+ while (offset > 0) {
+ if ((didread = php_stream_read(stream, tmp, MIN(offset, sizeof(tmp)))) <= 0) {
return -1;
}
offset -= didread;
@@ -1357,11 +1411,11 @@ PHPAPI int _php_stream_truncate_set_size(php_stream *stream, size_t newsize)
return php_stream_set_option(stream, PHP_STREAM_OPTION_TRUNCATE_API, PHP_STREAM_TRUNCATE_SET_SIZE, &newsize);
}
-PHPAPI size_t _php_stream_passthru(php_stream * stream STREAMS_DC)
+PHPAPI ssize_t _php_stream_passthru(php_stream * stream STREAMS_DC)
{
size_t bcount = 0;
char buf[8192];
- size_t b;
+ ssize_t b;
if (php_stream_mmap_possible(stream)) {
char *p;
@@ -1388,13 +1442,17 @@ PHPAPI size_t _php_stream_passthru(php_stream * stream STREAMS_DC)
bcount += b;
}
+ if (b < 0 && bcount == 0) {
+ return b;
+ }
+
return bcount;
}
PHPAPI zend_string *_php_stream_copy_to_mem(php_stream *src, size_t maxlen, int persistent STREAMS_DC)
{
- size_t ret = 0;
+ ssize_t ret = 0;
char *ptr;
size_t len = 0, max_len;
int step = CHUNK_SIZE;
@@ -1415,7 +1473,8 @@ PHPAPI zend_string *_php_stream_copy_to_mem(php_stream *src, size_t maxlen, int
ptr = ZSTR_VAL(result);
while ((len < maxlen) && !php_stream_eof(src)) {
ret = php_stream_read(src, ptr, maxlen - len);
- if (!ret) {
+ if (ret <= 0) {
+ // TODO: Propagate error?
break;
}
len += ret;
@@ -1451,7 +1510,8 @@ PHPAPI zend_string *_php_stream_copy_to_mem(php_stream *src, size_t maxlen, int
result = zend_string_alloc(max_len, persistent);
ptr = ZSTR_VAL(result);
- while ((ret = php_stream_read(src, ptr, max_len - len))) {
+ // TODO: Propagate error?
+ while ((ret = php_stream_read(src, ptr, max_len - len)) > 0){
len += ret;
if (len + min_room >= max_len) {
result = zend_string_extend(result, max_len + step, persistent);
@@ -1476,9 +1536,8 @@ PHPAPI zend_string *_php_stream_copy_to_mem(php_stream *src, size_t maxlen, int
PHPAPI int _php_stream_copy_to_stream_ex(php_stream *src, php_stream *dest, size_t maxlen, size_t *len STREAMS_DC)
{
char buf[CHUNK_SIZE];
- size_t readchunk;
size_t haveread = 0;
- size_t didread, didwrite, towrite;
+ size_t towrite;
size_t dummy;
php_stream_statbuf ssbuf;
@@ -1513,7 +1572,11 @@ PHPAPI int _php_stream_copy_to_stream_ex(php_stream *src, php_stream *dest, size
p = php_stream_mmap_range(src, php_stream_tell(src), maxlen, PHP_STREAM_MAP_MODE_SHARED_READONLY, &mapped);
if (p) {
- didwrite = php_stream_write(dest, p, mapped);
+ ssize_t didwrite = php_stream_write(dest, p, mapped);
+ if (didwrite < 0) {
+ *len = 0;
+ return FAILURE;
+ }
php_stream_mmap_unmap_ex(src, mapped);
@@ -1530,34 +1593,33 @@ PHPAPI int _php_stream_copy_to_stream_ex(php_stream *src, php_stream *dest, size
}
while(1) {
- readchunk = sizeof(buf);
+ size_t readchunk = sizeof(buf);
+ ssize_t didread;
+ char *writeptr;
if (maxlen && (maxlen - haveread) < readchunk) {
readchunk = maxlen - haveread;
}
didread = php_stream_read(src, buf, readchunk);
+ if (didread <= 0) {
+ *len = haveread;
+ return didread < 0 ? FAILURE : SUCCESS;
+ }
- if (didread) {
- /* extra paranoid */
- char *writeptr;
-
- towrite = didread;
- writeptr = buf;
- haveread += didread;
+ towrite = didread;
+ writeptr = buf;
+ haveread += didread;
- while(towrite) {
- didwrite = php_stream_write(dest, writeptr, towrite);
- if (didwrite == 0) {
- *len = haveread - (didread - towrite);
- return FAILURE;
- }
-
- towrite -= didwrite;
- writeptr += didwrite;
+ while (towrite) {
+ ssize_t didwrite = php_stream_write(dest, writeptr, towrite);
+ if (didwrite <= 0) {
+ *len = haveread - (didread - towrite);
+ return FAILURE;
}
- } else {
- break;
+
+ towrite -= didwrite;
+ writeptr += didwrite;
}
if (maxlen - haveread == 0) {
@@ -2019,6 +2081,9 @@ PHPAPI php_stream *_php_stream_open_wrapper_ex(const char *path, const char *mod
options |= STREAM_ASSUME_REALPATH;
options &= ~USE_PATH;
}
+ if (EG(exception)) {
+ return NULL;
+ }
}
path_to_open = path;
@@ -2302,12 +2367,3 @@ PHPAPI int _php_stream_scandir(const char *dirname, zend_string **namelist[], in
return nfiles;
}
/* }}} */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/main/streams/transports.c b/main/streams/transports.c
index 1853f3ea9e..74fbef58d8 100644
--- a/main/streams/transports.c
+++ b/main/streams/transports.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -512,12 +512,3 @@ PHPAPI int php_stream_xport_shutdown(php_stream *stream, stream_shutdown_t how)
}
return -1;
}
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/main/streams/userspace.c b/main/streams/userspace.c
index 3b513cb7f1..9cf1580a35 100644
--- a/main/streams/userspace.c
+++ b/main/streams/userspace.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -588,14 +588,14 @@ PHP_FUNCTION(stream_wrapper_restore)
}
/* }}} */
-static size_t php_userstreamop_write(php_stream *stream, const char *buf, size_t count)
+static ssize_t php_userstreamop_write(php_stream *stream, const char *buf, size_t count)
{
zval func_name;
zval retval;
int call_result;
php_userstream_data_t *us = (php_userstream_data_t *)stream->abstract;
zval args[1];
- size_t didwrite = 0;
+ ssize_t didwrite;
assert(us != NULL);
@@ -612,22 +612,25 @@ static size_t php_userstreamop_write(php_stream *stream, const char *buf, size_t
zval_ptr_dtor(&args[0]);
zval_ptr_dtor(&func_name);
- didwrite = 0;
-
if (EG(exception)) {
- return 0;
+ return -1;
}
if (call_result == SUCCESS && Z_TYPE(retval) != IS_UNDEF) {
- convert_to_long(&retval);
- didwrite = Z_LVAL(retval);
- } else if (call_result == FAILURE) {
+ if (Z_TYPE(retval) == IS_FALSE) {
+ didwrite = -1;
+ } else {
+ convert_to_long(&retval);
+ didwrite = Z_LVAL(retval);
+ }
+ } else {
php_error_docref(NULL, E_WARNING, "%s::" USERSTREAM_WRITE " is not implemented!",
us->wrapper->classname);
+ didwrite = -1;
}
/* don't allow strange buffer overruns due to bogus return */
- if (didwrite > count) {
+ 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,
(zend_long)(didwrite - count), (zend_long)didwrite, (zend_long)count);
@@ -639,7 +642,7 @@ static size_t php_userstreamop_write(php_stream *stream, const char *buf, size_t
return didwrite;
}
-static size_t php_userstreamop_read(php_stream *stream, char *buf, size_t count)
+static ssize_t php_userstreamop_read(php_stream *stream, char *buf, size_t count)
{
zval func_name;
zval retval;
@@ -668,19 +671,28 @@ static size_t php_userstreamop_read(php_stream *stream, char *buf, size_t count)
return -1;
}
- if (call_result == SUCCESS && Z_TYPE(retval) != IS_UNDEF) {
- convert_to_string(&retval);
- didread = Z_STRLEN(retval);
+ if (call_result == FAILURE) {
+ php_error_docref(NULL, E_WARNING, "%s::" USERSTREAM_READ " is not implemented!",
+ us->wrapper->classname);
+ return -1;
+ }
+
+ if (Z_TYPE(retval) == IS_FALSE) {
+ return -1;
+ }
+
+ if (!try_convert_to_string(&retval)) {
+ return -1;
+ }
+
+ didread = Z_STRLEN(retval);
+ 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);
didread = count;
}
- if (didread > 0)
- memcpy(buf, Z_STRVAL(retval), didread);
- } else if (call_result == FAILURE) {
- php_error_docref(NULL, E_WARNING, "%s::" USERSTREAM_READ " is not implemented!",
- us->wrapper->classname);
+ memcpy(buf, Z_STRVAL(retval), didread);
}
zval_ptr_dtor(&retval);
@@ -689,12 +701,17 @@ static size_t php_userstreamop_read(php_stream *stream, char *buf, size_t count)
/* since the user stream has no way of setting the eof flag directly, we need to ask it if we hit eof */
ZVAL_STRINGL(&func_name, USERSTREAM_EOF, sizeof(USERSTREAM_EOF)-1);
-
call_result = call_user_function(NULL,
Z_ISUNDEF(us->object)? NULL : &us->object,
&func_name,
&retval,
0, NULL);
+ zval_ptr_dtor(&func_name);
+
+ if (EG(exception)) {
+ stream->eof = 1;
+ return -1;
+ }
if (call_result == SUCCESS && Z_TYPE(retval) != IS_UNDEF && zval_is_true(&retval)) {
stream->eof = 1;
@@ -707,7 +724,6 @@ static size_t php_userstreamop_read(php_stream *stream, char *buf, size_t count)
}
zval_ptr_dtor(&retval);
- zval_ptr_dtor(&func_name);
return didread;
}
@@ -868,7 +884,7 @@ static int statbuf_from_array(zval *array, php_stream_statbuf *ssb)
#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
STAT_PROP_ENTRY(blksize);
#endif
-#ifdef HAVE_ST_BLOCKS
+#ifdef HAVE_STRUCT_STAT_ST_BLOCKS
STAT_PROP_ENTRY(blocks);
#endif
@@ -1398,7 +1414,7 @@ static int user_wrapper_stat_url(php_stream_wrapper *wrapper, const char *url, i
}
-static size_t php_userstreamop_readdir(php_stream *stream, char *buf, size_t count)
+static ssize_t php_userstreamop_readdir(php_stream *stream, char *buf, size_t count)
{
zval func_name;
zval retval;
@@ -1409,7 +1425,7 @@ static size_t php_userstreamop_readdir(php_stream *stream, char *buf, size_t cou
/* avoid problems if someone mis-uses the stream */
if (count != sizeof(php_stream_dirent))
- return 0;
+ return -1;
ZVAL_STRINGL(&func_name, USERSTREAM_DIR_READ, sizeof(USERSTREAM_DIR_READ)-1);
diff --git a/main/streams/xp_socket.c b/main/streams/xp_socket.c
index acdb1f8876..56fc4fcd4f 100644
--- a/main/streams/xp_socket.c
+++ b/main/streams/xp_socket.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -56,10 +56,10 @@ const php_stream_ops php_stream_unixdg_socket_ops;
static int php_tcp_sockop_set_option(php_stream *stream, int option, int value, void *ptrparam);
/* {{{ Generic socket stream operations */
-static size_t php_sockop_write(php_stream *stream, const char *buf, size_t count)
+static ssize_t php_sockop_write(php_stream *stream, const char *buf, size_t count)
{
php_netstream_data_t *sock = (php_netstream_data_t*)stream->abstract;
- int didwrite;
+ ssize_t didwrite;
struct timeval *ptimeout;
if (!sock || sock->socket == -1) {
@@ -75,30 +75,36 @@ retry:
didwrite = send(sock->socket, buf, XP_SOCK_BUF_SIZE(count), (sock->is_blocked && ptimeout) ? MSG_DONTWAIT : 0);
if (didwrite <= 0) {
- int err = php_socket_errno();
char *estr;
+ int err = php_socket_errno();
+ if (err == EWOULDBLOCK || err == EAGAIN) {
+ if (sock->is_blocked) {
+ int retval;
- if (sock->is_blocked && (err == EWOULDBLOCK || err == EAGAIN)) {
- int retval;
+ sock->timeout_event = 0;
- sock->timeout_event = 0;
+ do {
+ retval = php_pollfd_for(sock->socket, POLLOUT, ptimeout);
- do {
- retval = php_pollfd_for(sock->socket, POLLOUT, ptimeout);
-
- if (retval == 0) {
- sock->timeout_event = 1;
- break;
- }
+ if (retval == 0) {
+ sock->timeout_event = 1;
+ break;
+ }
- if (retval > 0) {
- /* writable now; retry */
- goto retry;
- }
+ if (retval > 0) {
+ /* writable now; retry */
+ goto retry;
+ }
- err = php_socket_errno();
- } while (err == EINTR);
+ err = php_socket_errno();
+ } while (err == EINTR);
+ } else {
+ /* EWOULDBLOCK/EAGAIN is not an error for a non-blocking stream.
+ * Report zero byte write instead. */
+ return 0;
+ }
}
+
estr = php_socket_strerror(err, NULL, 0);
php_error_docref(NULL, E_NOTICE, "send of " ZEND_LONG_FMT " bytes failed with errno=%d %s",
(zend_long)count, err, estr);
@@ -109,10 +115,6 @@ retry:
php_stream_notify_progress_increment(PHP_STREAM_CONTEXT(stream), didwrite, 0);
}
- if (didwrite < 0) {
- didwrite = 0;
- }
-
return didwrite;
}
@@ -146,14 +148,14 @@ static void php_sock_stream_wait_for_data(php_stream *stream, php_netstream_data
}
}
-static size_t php_sockop_read(php_stream *stream, char *buf, size_t count)
+static ssize_t php_sockop_read(php_stream *stream, char *buf, size_t count)
{
php_netstream_data_t *sock = (php_netstream_data_t*)stream->abstract;
ssize_t nr_bytes = 0;
int err;
if (!sock || sock->socket == -1) {
- return 0;
+ return -1;
}
if (sock->is_blocked) {
@@ -165,16 +167,20 @@ static size_t php_sockop_read(php_stream *stream, char *buf, size_t count)
nr_bytes = recv(sock->socket, buf, XP_SOCK_BUF_SIZE(count), (sock->is_blocked && sock->timeout.tv_sec != -1) ? MSG_DONTWAIT : 0);
err = php_socket_errno();
- stream->eof = (nr_bytes == 0 || (nr_bytes == -1 && err != EWOULDBLOCK && err != EAGAIN));
+ if (nr_bytes < 0) {
+ if (err == EAGAIN || err == EWOULDBLOCK) {
+ nr_bytes = 0;
+ } else {
+ stream->eof = 1;
+ }
+ } else if (nr_bytes == 0) {
+ stream->eof = 1;
+ }
if (nr_bytes > 0) {
php_stream_notify_progress_increment(PHP_STREAM_CONTEXT(stream), nr_bytes, 0);
}
- if (nr_bytes < 0) {
- nr_bytes = 0;
- }
-
return nr_bytes;
}
@@ -925,13 +931,3 @@ PHPAPI php_stream *php_stream_generic_socket_factory(const char *proto, size_t p
return stream;
}
-
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/main/strlcat.c b/main/strlcat.c
index 2050c67070..6ef5644568 100644
--- a/main/strlcat.c
+++ b/main/strlcat.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -94,12 +94,3 @@ PHPAPI size_t php_strlcat(dst, src, siz)
}
#endif /* !HAVE_STRLCAT */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */
diff --git a/main/strlcpy.c b/main/strlcpy.c
index 5c19ced513..31e13489d8 100644
--- a/main/strlcpy.c
+++ b/main/strlcpy.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -94,12 +94,3 @@ PHPAPI size_t php_strlcpy(dst, src, siz)
}
#endif /* !HAVE_STRLCPY */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */