summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
Diffstat (limited to 'main')
-rw-r--r--main/SAPI.c22
-rw-r--r--main/SAPI.h3
-rw-r--r--main/build-defs.h.in2
-rw-r--r--main/explicit_bzero.c43
-rw-r--r--main/fopen_wrappers.c14
-rw-r--r--main/internal_functions_nw.c100
-rw-r--r--main/main.c58
-rw-r--r--main/network.c18
-rw-r--r--main/php.h60
-rw-r--r--main/php_getopt.h8
-rw-r--r--main/php_globals.h1
-rw-r--r--main/php_main.h2
-rw-r--r--main/php_open_temporary_file.c7
-rw-r--r--main/php_output.h4
-rw-r--r--main/php_scandir.c2
-rw-r--r--main/php_sprintf.c2
-rw-r--r--main/php_streams.h30
-rw-r--r--main/php_variables.c7
-rw-r--r--main/php_version.h10
-rw-r--r--main/rfc1867.c2
-rw-r--r--main/spprintf.c72
-rw-r--r--main/spprintf.h31
-rw-r--r--main/streams/filter.c8
-rw-r--r--main/streams/glob_wrapper.c4
-rw-r--r--main/streams/memory.c8
-rw-r--r--main/streams/php_stream_filter_api.h12
-rw-r--r--main/streams/plain_wrapper.c8
-rw-r--r--main/streams/streams.c2
-rw-r--r--main/streams/userspace.c6
-rw-r--r--main/streams/xp_socket.c2
-rw-r--r--main/strlcat.c37
-rw-r--r--main/strlcpy.c28
-rw-r--r--main/win95nt.h88
33 files changed, 257 insertions, 444 deletions
diff --git a/main/SAPI.c b/main/SAPI.c
index 2a064bce48..26846fb47c 100644
--- a/main/SAPI.c
+++ b/main/SAPI.c
@@ -180,7 +180,7 @@ SAPI_API void sapi_handle_post(void *arg)
static void sapi_read_post_data(void)
{
sapi_post_entry *post_entry;
- uint content_type_length = (uint)strlen(SG(request_info).content_type);
+ uint32_t content_type_length = (uint32_t)strlen(SG(request_info).content_type);
char *content_type = estrndup(SG(request_info).content_type, content_type_length);
char *p;
char oldchar=0;
@@ -302,21 +302,21 @@ SAPI_API SAPI_POST_READER_FUNC(sapi_read_standard_form_data)
}
-static inline char *get_default_content_type(uint prefix_len, uint *len)
+static inline char *get_default_content_type(uint32_t prefix_len, uint32_t *len)
{
char *mimetype, *charset, *content_type;
- uint mimetype_len, charset_len;
+ uint32_t mimetype_len, charset_len;
if (SG(default_mimetype)) {
mimetype = SG(default_mimetype);
- mimetype_len = (uint)strlen(SG(default_mimetype));
+ mimetype_len = (uint32_t)strlen(SG(default_mimetype));
} else {
mimetype = SAPI_DEFAULT_MIMETYPE;
mimetype_len = sizeof(SAPI_DEFAULT_MIMETYPE) - 1;
}
if (SG(default_charset)) {
charset = SG(default_charset);
- charset_len = (uint)strlen(SG(default_charset));
+ charset_len = (uint32_t)strlen(SG(default_charset));
} else {
charset = SAPI_DEFAULT_CHARSET;
charset_len = sizeof(SAPI_DEFAULT_CHARSET) - 1;
@@ -344,7 +344,7 @@ static inline char *get_default_content_type(uint prefix_len, uint *len)
SAPI_API char *sapi_get_default_content_type(void)
{
- uint len;
+ uint32_t len;
return get_default_content_type(0, &len);
}
@@ -352,7 +352,7 @@ SAPI_API char *sapi_get_default_content_type(void)
SAPI_API void sapi_get_default_content_type_header(sapi_header_struct *default_header)
{
- uint len;
+ uint32_t len;
default_header->header = get_default_content_type(sizeof("Content-type: ")-1, &len);
default_header->header_len = len;
@@ -733,7 +733,7 @@ SAPI_API int sapi_header_op(sapi_header_op_enum op, void *arg)
return SUCCESS;
} else {
/* new line/NUL character safety check */
- uint i;
+ uint32_t i;
for (i = 0; i < header_line_len; i++) {
/* RFC 7230 ch. 3.2.4 deprecates folding support */
if (header_line[i] == '\n' || header_line[i] == '\r') {
@@ -795,7 +795,7 @@ SAPI_API int sapi_header_op(sapi_header_op_enum op, void *arg)
PHP_STRLCPY(newheader, "Content-type: ", newlen, sizeof("Content-type: ")-1);
strlcat(newheader, mimetype, newlen);
sapi_header.header = newheader;
- sapi_header.header_len = (uint)(newlen - 1);
+ sapi_header.header_len = (uint32_t)(newlen - 1);
efree(header_line);
}
efree(mimetype);
@@ -855,7 +855,7 @@ SAPI_API int sapi_send_headers(void)
* in case of an error situation.
*/
if (SG(sapi_headers).send_default_content_type && sapi_module.send_headers) {
- uint len = 0;
+ uint32_t len = 0;
char *default_mimetype = get_default_content_type(0, &len);
if (default_mimetype && len) {
@@ -902,7 +902,7 @@ SAPI_API int sapi_send_headers(void)
if (SG(sapi_headers).http_status_line) {
http_status_line.header = SG(sapi_headers).http_status_line;
- http_status_line.header_len = (uint)strlen(SG(sapi_headers).http_status_line);
+ http_status_line.header_len = (uint32_t)strlen(SG(sapi_headers).http_status_line);
} else {
http_status_line.header = buf;
http_status_line.header_len = slprintf(buf, sizeof(buf), "HTTP/1.0 %d X", SG(sapi_headers).http_response_code);
diff --git a/main/SAPI.h b/main/SAPI.h
index f857d3ec94..6914ed4327 100644
--- a/main/SAPI.h
+++ b/main/SAPI.h
@@ -27,7 +27,6 @@
#include "zend_llist.h"
#include "zend_operators.h"
#ifdef PHP_WIN32
-#include "win95nt.h"
#include "win32/php_stdint.h"
#endif
#include <sys/stat.h>
@@ -273,7 +272,7 @@ struct _sapi_module_struct {
struct _sapi_post_entry {
char *content_type;
- uint content_type_len;
+ uint32_t content_type_len;
void (*post_reader)(void);
void (*post_handler)(char *content_type_dup, void *arg);
};
diff --git a/main/build-defs.h.in b/main/build-defs.h.in
index 7748d739c7..c82982a32a 100644
--- a/main/build-defs.h.in
+++ b/main/build-defs.h.in
@@ -12,7 +12,7 @@
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
- | Author: Stig Sæther Bakken <ssb@php.net> |
+ | Author: Stig Sæther Bakken <ssb@php.net> |
+----------------------------------------------------------------------+
*/
diff --git a/main/explicit_bzero.c b/main/explicit_bzero.c
new file mode 100644
index 0000000000..6bea9e3df2
--- /dev/null
+++ b/main/explicit_bzero.c
@@ -0,0 +1,43 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 7 |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 1997-2017 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: |
+ +----------------------------------------------------------------------+
+*/
+
+/* $Id$ */
+
+#include "php.h"
+
+#ifndef HAVE_EXPLICIT_BZERO
+
+/* $OpenBSD: explicit_bzero.c,v 1.4 2015/08/31 02:53:57 guenther Exp $ */
+/*
+ * Public domain.
+ * Written by Matthew Dempsky.
+ */
+
+#include <string.h>
+
+__attribute__((weak)) void
+__explicit_bzero_hook(void *dst, size_t siz)
+{
+}
+
+PHPAPI void php_explicit_bzero(void *dst, size_t siz)
+{
+ memset(dst, 0, siz);
+ __explicit_bzero_hook(dst, siz);
+}
+#endif
diff --git a/main/fopen_wrappers.c b/main/fopen_wrappers.c
index 17dd27a6ff..578e5d5170 100644
--- a/main/fopen_wrappers.c
+++ b/main/fopen_wrappers.c
@@ -55,8 +55,6 @@
#ifdef PHP_WIN32
#include <winsock2.h>
-#elif defined(NETWARE) && defined(USE_WINSOCK)
-#include <novsock2.h>
#else
#include <netinet/in.h>
#include <netdb.h>
@@ -65,7 +63,7 @@
#endif
#endif
-#if defined(PHP_WIN32) || defined(__riscos__) || defined(NETWARE)
+#if defined(PHP_WIN32) || defined(__riscos__)
#undef AF_UNIX
#endif
@@ -184,7 +182,7 @@ PHPAPI int php_check_specific_open_basedir(const char *basedir, const char *path
}
#endif
-#if defined(PHP_WIN32) || defined(NETWARE)
+#ifdef PHP_WIN32
path_file = strrchr(path_tmp, DEFAULT_SLASH);
if (!path_file) {
path_file = strrchr(path_tmp, '/');
@@ -197,7 +195,7 @@ PHPAPI int php_check_specific_open_basedir(const char *basedir, const char *path
return -1;
} else {
path_len = path_file - path_tmp + 1;
-#if defined(PHP_WIN32) || defined(NETWARE)
+#ifdef PHP_WIN32
if (path_len > 1 && path_tmp[path_len - 2] == ':') {
if (path_len != 3) {
return -1;
@@ -219,7 +217,7 @@ PHPAPI int php_check_specific_open_basedir(const char *basedir, const char *path
int basedir_len = (int)strlen(basedir);
/* Handler for basedirs that end with a / */
resolved_basedir_len = (int)strlen(resolved_basedir);
-#if defined(PHP_WIN32) || defined(NETWARE)
+#ifdef PHP_WIN32
if (basedir[basedir_len - 1] == PHP_DIR_SEPARATOR || basedir[basedir_len - 1] == '/') {
#else
if (basedir[basedir_len - 1] == PHP_DIR_SEPARATOR) {
@@ -242,7 +240,7 @@ PHPAPI int php_check_specific_open_basedir(const char *basedir, const char *path
}
/* Check the path */
-#if defined(PHP_WIN32) || defined(NETWARE)
+#ifdef PHP_WIN32
if (strncasecmp(resolved_basedir, resolved_name, resolved_basedir_len) == 0) {
#else
if (strncmp(resolved_basedir, resolved_name, resolved_basedir_len) == 0) {
@@ -257,7 +255,7 @@ PHPAPI int php_check_specific_open_basedir(const char *basedir, const char *path
} else {
/* /openbasedir/ and /openbasedir are the same directory */
if (resolved_basedir_len == (resolved_name_len + 1) && resolved_basedir[resolved_basedir_len - 1] == PHP_DIR_SEPARATOR) {
-#if defined(PHP_WIN32) || defined(NETWARE)
+#ifdef PHP_WIN32
if (strncasecmp(resolved_basedir, resolved_name, resolved_name_len) == 0) {
#else
if (strncmp(resolved_basedir, resolved_name, resolved_name_len) == 0) {
diff --git a/main/internal_functions_nw.c b/main/internal_functions_nw.c
deleted file mode 100644
index 54555c157a..0000000000
--- a/main/internal_functions_nw.c
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2017 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. |
- +----------------------------------------------------------------------+
- | Authors: Andi Gutmans <andi@zend.com> |
- | Zeev Suraski <zeev@zend.com> |
- | Modified for NetWare: Novell, Inc. |
- +----------------------------------------------------------------------+
- */
-
-/* $Id$ */
-
-/* {{{ includes
- */
-#include "php.h"
-#include "php_main.h"
-#include "zend_modules.h"
-#include "zend_compile.h"
-#include <stdarg.h>
-#include <stdlib.h>
-#include <stdio.h>
-
-#include "ext/bcmath/php_bcmath.h"
-#include "ext/gd/php_gd.h"
-#include "ext/standard/dl.h"
-#include "ext/standard/file.h"
-#include "ext/standard/fsock.h"
-#include "ext/standard/head.h"
-#include "ext/standard/pack.h"
-#include "ext/standard/php_browscap.h"
-/*#include "ext/standard/php_crypt.h"*/
-#include "ext/standard/php_dir.h"
-#include "ext/standard/php_filestat.h"
-#include "ext/standard/php_mail.h"
-/*#include "ext/standard/php_ext_syslog.h"*/
-#include "ext/standard/php_standard.h"
-#include "ext/standard/php_lcg.h"
-#include "ext/standard/php_array.h"
-#include "ext/standard/php_assert.h"
-#include "ext/calendar/php_calendar.h"
-/*#include "ext/com/php_COM.h"
-#include "ext/com/php_VARIANT.h"*/
-#include "ext/ftp/php_ftp.h"
-#include "ext/standard/reg.h"
-#include "ext/pcre/php_pcre.h"
-/*#include "ext/odbc/php_odbc.h"*/ /* Commented out for now */
-#include "ext/session/php_session.h"
-/*#include "ext/xml/php_xml.h"
-#include "ext/wddx/php_wddx.h"
-#include "ext/mysql/php_mysql.h"*/ /* Commented out for now */
-/* }}} */
-
-/* {{{ php_builtin_extensions[]
- */
-static zend_module_entry *php_builtin_extensions[] = {
- phpext_standard_ptr,
-#if HAVE_BCMATH
- phpext_bcmath_ptr,
-#endif
- phpext_calendar_ptr,
-/* COM_module_ptr,*/
- phpext_ftp_ptr,
-#if defined(MBSTR_ENC_TRANS)
- phpext_mbstring_ptr,
-#endif
-/* phpext_mysql_ptr,*/ /* Commented out for now */
-/* phpext_odbc_ptr, */ /* Commented out for now */
- phpext_pcre_ptr,
- phpext_session_ptr,
-/* phpext_xml_ptr,
- phpext_wddx_ptr */ /* Commented out for now */
-};
-/* }}} */
-
-#define EXTCOUNT (sizeof(php_builtin_extensions)/sizeof(zend_module_entry *))
-
-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 2ac432a687..ab01757efa 100644
--- a/main/main.c
+++ b/main/main.c
@@ -34,11 +34,6 @@
#include "win32/php_win32_globals.h"
#include "win32/winutil.h"
#include <process.h>
-#elif defined(NETWARE)
-#include <sys/timeval.h>
-#ifdef USE_WINSOCK
-#include <novsock2.h>
-#endif
#endif
#if HAVE_SYS_TIME_H
#include <sys/time.h>
@@ -511,8 +506,8 @@ PHP_INI_MH(OnChangeBrowscap);
* PHP_INCLUDE_PATH
*/
- /* Windows and Netware use the internal mail */
-#if defined(PHP_WIN32) || defined(NETWARE)
+ /* Windows use the internal mail */
+#if defined(PHP_WIN32)
# define DEFAULT_SENDMAIL_PATH NULL
#elif defined(PHP_PROG_SENDMAIL)
# define DEFAULT_SENDMAIL_PATH PHP_PROG_SENDMAIL " -t -i "
@@ -552,7 +547,6 @@ PHP_INI_BEGIN()
STD_PHP_INI_BOOLEAN("register_argc_argv", "1", PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateBool, register_argc_argv, php_core_globals, core_globals)
STD_PHP_INI_BOOLEAN("auto_globals_jit", "1", PHP_INI_PERDIR|PHP_INI_SYSTEM, OnUpdateBool, auto_globals_jit, php_core_globals, core_globals)
STD_PHP_INI_BOOLEAN("short_open_tag", DEFAULT_SHORT_OPEN_TAG, PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateBool, short_tags, zend_compiler_globals, compiler_globals)
- STD_PHP_INI_BOOLEAN("sql.safe_mode", "0", PHP_INI_SYSTEM, OnUpdateBool, sql_safe_mode, php_core_globals, core_globals)
STD_PHP_INI_BOOLEAN("track_errors", "0", PHP_INI_ALL, OnUpdateBool, track_errors, php_core_globals, core_globals)
STD_PHP_INI_ENTRY("unserialize_callback_func", NULL, PHP_INI_ALL, OnUpdateString, unserialize_callback_func, php_core_globals, core_globals)
@@ -1010,7 +1004,7 @@ PHPAPI void php_html_puts(const char *str, size_t size)
/* {{{ php_error_cb
extended error handling function */
-static ZEND_COLD void php_error_cb(int type, const char *error_filename, const uint error_lineno, const char *format, va_list args)
+static ZEND_COLD void php_error_cb(int type, const char *error_filename, const uint32_t error_lineno, const char *format, va_list args)
{
char *buffer;
int buffer_len, display;
@@ -2052,15 +2046,15 @@ void dummy_invalid_parameter_handler(
/* {{{ php_module_startup
*/
-int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_modules, uint num_additional_modules)
+int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_modules, uint32_t num_additional_modules)
{
zend_utility_functions zuf;
zend_utility_values zuv;
int retval = SUCCESS, module_number=0; /* for REGISTER_INI_ENTRIES() */
- char *php_os;
+ char *php_os, *php_os_family;
zend_module_entry *module;
-#if defined(PHP_WIN32) || (defined(NETWARE) && defined(USE_WINSOCK))
+#ifdef PHP_WIN32
WORD wVersionRequested = MAKEWORD(2, 0);
WSADATA wsaData;
#endif
@@ -2079,6 +2073,21 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
php_os = PHP_OS;
#endif
+#if defined(PHP_WIN32)
+ php_os_family = "WIN";
+#elif defined(BSD) || defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
+ php_os_family = "BSD";
+#elif defined(__APPLE__) || defined(__MACH__)
+ php_os_family = "OSX";
+#elif defined(__sun__)
+ php_os_family = "SOLARIS";
+#elif defined(__linux__)
+ php_os_family = "LINUX";
+#else
+ php_os_family = "unknown";
+#endif
+
+
#ifdef ZTS
(void)ts_resource(0);
#endif
@@ -2120,8 +2129,8 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
zuf.ticks_function = php_run_ticks;
zuf.on_timeout = php_on_timeout;
zuf.stream_open_function = php_stream_open_for_zend;
- zuf.vspprintf_function = vspprintf;
- zuf.vstrpprintf_function = vstrpprintf;
+ zuf.printf_to_smart_string_function = php_printf_to_smart_string;
+ 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);
@@ -2135,7 +2144,7 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
tzset();
#endif
-#if defined(PHP_WIN32) || (defined(NETWARE) && defined(USE_WINSOCK))
+#ifdef PHP_WIN32
/* start up winsock services */
if (WSAStartup(wVersionRequested, &wsaData) != 0) {
php_printf("\nwinsock.dll unusable. %d\n", WSAGetLastError());
@@ -2159,6 +2168,7 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
#endif
REGISTER_MAIN_LONG_CONSTANT("PHP_DEBUG", PHP_DEBUG, CONST_PERSISTENT | CONST_CS);
REGISTER_MAIN_STRINGL_CONSTANT("PHP_OS", php_os, strlen(php_os), CONST_PERSISTENT | CONST_CS);
+ REGISTER_MAIN_STRINGL_CONSTANT("PHP_OS_FAMILY", php_os_family, strlen(php_os_family), CONST_PERSISTENT | CONST_CS);
REGISTER_MAIN_STRINGL_CONSTANT("PHP_SAPI", sapi_module.name, strlen(sapi_module.name), CONST_PERSISTENT | CONST_CS);
REGISTER_MAIN_STRINGL_CONSTANT("DEFAULT_INCLUDE_PATH", PHP_INCLUDE_PATH, sizeof(PHP_INCLUDE_PATH)-1, CONST_PERSISTENT | CONST_CS);
REGISTER_MAIN_STRINGL_CONSTANT("PEAR_INSTALL_DIR", PEAR_INSTALLDIR, sizeof(PEAR_INSTALLDIR)-1, CONST_PERSISTENT | CONST_CS);
@@ -2182,6 +2192,10 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod
REGISTER_MAIN_LONG_CONSTANT("PHP_INT_MIN", ZEND_LONG_MIN, CONST_PERSISTENT | CONST_CS);
REGISTER_MAIN_LONG_CONSTANT("PHP_INT_SIZE", SIZEOF_ZEND_LONG, CONST_PERSISTENT | CONST_CS);
REGISTER_MAIN_LONG_CONSTANT("PHP_FD_SETSIZE", FD_SETSIZE, CONST_PERSISTENT | CONST_CS);
+ REGISTER_MAIN_LONG_CONSTANT("PHP_FLOAT_DIG", DBL_DIG, CONST_PERSISTENT | CONST_CS);
+ REGISTER_MAIN_DOUBLE_CONSTANT("PHP_FLOAT_EPSILON", DBL_EPSILON, CONST_PERSISTENT | CONST_CS);
+ REGISTER_MAIN_DOUBLE_CONSTANT("PHP_FLOAT_MAX", DBL_MAX, CONST_PERSISTENT | CONST_CS);
+ REGISTER_MAIN_DOUBLE_CONSTANT("PHP_FLOAT_MIN", DBL_MIN, CONST_PERSISTENT | CONST_CS);
#ifdef PHP_WIN32
REGISTER_MAIN_LONG_CONSTANT("PHP_WINDOWS_VERSION_MAJOR", EG(windows_version_info).dwMajorVersion, CONST_PERSISTENT | CONST_CS);
@@ -2235,7 +2249,7 @@ 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 = (uint)strlen(zuv.import_use_extension);
+ 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();
@@ -2391,11 +2405,6 @@ void php_module_shutdown(void)
ts_free_worker_threads();
#endif
-#if defined(PHP_WIN32) || (defined(NETWARE) && defined(USE_WINSOCK))
- /*close winsock */
- WSACleanup();
-#endif
-
#ifdef PHP_WIN32
php_win32_free_rng_lock();
#endif
@@ -2404,6 +2413,11 @@ void php_module_shutdown(void)
zend_shutdown();
+#ifdef PHP_WIN32
+ /*close winsock */
+ WSACleanup();
+#endif
+
/* Destroys filter & transport registries too */
php_shutdown_stream_wrappers(module_number);
@@ -2484,7 +2498,7 @@ PHPAPI int php_execute_script(zend_file_handle *primary_file)
* otherwise it will get opened and added to the included_files list in zend_execute_scripts
*/
if (primary_file->filename &&
- (primary_file->filename[0] != '-' || primary_file->filename[1] != 0) &&
+ strcmp("Standard input code", primary_file->filename) &&
primary_file->opened_path == NULL &&
primary_file->type != ZEND_HANDLE_FILENAME
) {
diff --git a/main/network.c b/main/network.c
index d0866708e9..be9a6f198a 100644
--- a/main/network.c
+++ b/main/network.c
@@ -32,9 +32,6 @@
# include "win32/inet.h"
# define O_RDONLY _O_RDONLY
# include "win32/param.h"
-#elif defined(NETWARE)
-#include <sys/timeval.h>
-#include <sys/param.h>
#else
#include <sys/param.h>
#endif
@@ -55,17 +52,8 @@
#include <sys/poll.h>
#endif
-#if defined(NETWARE)
-#ifdef USE_WINSOCK
-#include <novsock2.h>
-#else
-#include <arpa/inet.h>
-#include <netinet/in.h>
-#include <netdb.h>
-#include <sys/select.h>
-#include <sys/socket.h>
-#endif
-#elif !defined(PHP_WIN32)
+
+#ifndef PHP_WIN32
#include <netinet/in.h>
#include <netdb.h>
#if HAVE_ARPA_INET_H
@@ -79,7 +67,7 @@ int inet_aton(const char *, struct in_addr *);
#include "php_network.h"
-#if defined(PHP_WIN32) || defined(__riscos__) || defined(NETWARE)
+#if defined(PHP_WIN32) || defined(__riscos__)
#undef AF_UNIX
#endif
diff --git a/main/php.h b/main/php.h
index 1da67b2909..23d365d9e3 100644
--- a/main/php.h
+++ b/main/php.h
@@ -26,7 +26,7 @@
#include <dmalloc.h>
#endif
-#define PHP_API_VERSION 20160303
+#define PHP_API_VERSION 20160731
#define PHP_HAVE_STREAMS
#define YYDEBUG 0
#define PHP_DEFAULT_CHARSET "UTF-8"
@@ -47,7 +47,6 @@
#ifdef PHP_WIN32
# include "tsrm_win32.h"
-# include "win95nt.h"
# ifdef PHP_EXPORTS
# define PHPAPI __declspec(dllexport)
# else
@@ -66,10 +65,51 @@
# define PHP_EOL "\n"
#endif
-#ifdef NETWARE
-/* For php_get_uname() function */
-#define PHP_UNAME "NetWare"
-#define PHP_OS PHP_UNAME
+/* Windows specific defines */
+#ifdef PHP_WIN32
+# define PHP_PROG_SENDMAIL "Built in mailer"
+# define HAVE_DECLARED_TIMEZONE
+# define WIN32_LEAN_AND_MEAN
+# define NOOPENFILE
+
+# include <io.h>
+# include <malloc.h>
+# include <direct.h>
+# include <stdlib.h>
+# include <stdio.h>
+# include <stdarg.h>
+# include <sys/types.h>
+# include <process.h>
+
+typedef int uid_t;
+typedef int gid_t;
+typedef char * caddr_t;
+typedef unsigned int uint;
+typedef unsigned long ulong;
+# if !NSAPI
+typedef int pid_t;
+# endif
+
+# ifndef PHP_DEBUG
+# ifdef inline
+# undef inline
+# endif
+# define inline __inline
+# endif
+
+# define M_TWOPI (M_PI * 2.0)
+# define off_t _off_t
+
+# define lstat(x, y) php_sys_lstat(x, y)
+# define chdir(path) _chdir(path)
+# define mkdir(a, b) _mkdir(a)
+# define rmdir(a) _rmdir(a)
+# define getpid _getpid
+# define php_sleep(t) SleepEx(t*1000, TRUE)
+
+# ifndef getcwd
+# define getcwd(a, b) _getcwd(a, b)
+# endif
#endif
#if HAVE_ASSERT_H
@@ -136,6 +176,14 @@ END_EXTERN_C()
#define strlcat php_strlcat
#endif
+#ifndef HAVE_EXPLICIT_BZERO
+BEGIN_EXTERN_C()
+PHPAPI void php_explicit_bzero(void *dst, size_t siz);
+END_EXTERN_C()
+#undef explicit_bzero
+#define explicit_bzero php_explicit_bzero
+#endif
+
#ifndef HAVE_STRTOK_R
BEGIN_EXTERN_C()
char *strtok_r(char *s, const char *delim, char **last);
diff --git a/main/php_getopt.h b/main/php_getopt.h
index 6ae23cc73f..ad240fa537 100644
--- a/main/php_getopt.h
+++ b/main/php_getopt.h
@@ -23,14 +23,6 @@
#include "php.h"
-#ifdef NETWARE
-/*
-As NetWare LibC has optind and optarg macros defined in unistd.h our local variables were getting mistakenly preprocessed so undeffing optind and optarg
-*/
-#undef optarg
-#undef optind
-#endif
-
/* Define structure for one recognized option (both single char and long name).
* If short_open is '-' this is the last option. */
typedef struct _opt_struct {
diff --git a/main/php_globals.h b/main/php_globals.h
index b067805e14..e039f32f23 100644
--- a/main/php_globals.h
+++ b/main/php_globals.h
@@ -58,7 +58,6 @@ struct _php_core_globals {
zend_long output_buffering;
- zend_bool sql_safe_mode;
zend_bool enable_dl;
char *output_handler;
diff --git a/main/php_main.h b/main/php_main.h
index ffafaaf3bf..2965048737 100644
--- a/main/php_main.h
+++ b/main/php_main.h
@@ -30,7 +30,7 @@ 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, uint num_additional_modules);
+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);
diff --git a/main/php_open_temporary_file.c b/main/php_open_temporary_file.c
index 9426297133..50107f6bb8 100644
--- a/main/php_open_temporary_file.c
+++ b/main/php_open_temporary_file.c
@@ -30,13 +30,6 @@
#define O_RDONLY _O_RDONLY
#include "win32/param.h"
#include "win32/winutil.h"
-#elif defined(NETWARE)
-#ifdef USE_WINSOCK
-#include <novsock2.h>
-#else
-#include <sys/socket.h>
-#endif
-#include <sys/param.h>
#else
#include <sys/param.h>
#include <sys/socket.h>
diff --git a/main/php_output.h b/main/php_output.h
index 03bd6cca1d..6c8d50f367 100644
--- a/main/php_output.h
+++ b/main/php_output.h
@@ -94,8 +94,8 @@ typedef struct _php_output_buffer {
char *data;
size_t size;
size_t used;
- uint free:1;
- uint _reserved:31;
+ uint32_t free:1;
+ uint32_t _reserved:31;
} php_output_buffer;
typedef struct _php_output_context {
diff --git a/main/php_scandir.c b/main/php_scandir.c
index b56018aa7d..2bfecee3ae 100644
--- a/main/php_scandir.c
+++ b/main/php_scandir.c
@@ -38,9 +38,7 @@
#endif
#include <stdlib.h>
-#ifndef NETWARE
#include <search.h>
-#endif
#endif /* HAVE_SCANDIR */
diff --git a/main/php_sprintf.c b/main/php_sprintf.c
index c0dae7af2d..60ad09c0ac 100644
--- a/main/php_sprintf.c
+++ b/main/php_sprintf.c
@@ -12,7 +12,7 @@
| 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> |
+ | Author: Jaakko Hyvätti <jaakko.hyvatti@iki.fi> |
+----------------------------------------------------------------------+
*/
diff --git a/main/php_streams.h b/main/php_streams.h
index d6e627808d..d10d087fb4 100644
--- a/main/php_streams.h
+++ b/main/php_streams.h
@@ -197,22 +197,26 @@ struct _php_stream {
void *wrapperthis; /* convenience pointer for a instance of a wrapper */
zval wrapperdata; /* fgetwrapperdata retrieves this */
- int fgetss_state; /* for fgetss to handle multiline tags */
- int is_persistent;
- char mode[16]; /* "rwb" etc. ala stdio */
- zend_resource *res; /* used for auto-cleanup */
- int in_free; /* to prevent recursion during free */
+ uint8_t is_persistent:1;
+ uint8_t in_free:2; /* to prevent recursion during free */
+ uint8_t eof:1;
+ uint8_t __exposed:1; /* non-zero if exposed as a zval somewhere */
+
/* so we know how to clean it up correctly. This should be set to
* PHP_STREAM_FCLOSE_XXX as appropriate */
- int fclose_stdiocast;
+ uint8_t fclose_stdiocast:2;
+
+ uint8_t fgetss_state; /* for fgetss to handle multiline tags */
+
+ char mode[16]; /* "rwb" etc. ala stdio */
+
+ uint32_t flags; /* PHP_STREAM_FLAG_XXX */
+
+ zend_resource *res; /* used for auto-cleanup */
FILE *stdiocast; /* cache this, otherwise we might leak! */
- int __exposed; /* non-zero if exposed as a zval somewhere */
char *orig_path;
zend_resource *ctx;
- int flags; /* PHP_STREAM_FLAG_XXX */
-
- int eof;
/* buffer */
zend_off_t position; /* of underlying stream */
@@ -226,7 +230,7 @@ struct _php_stream {
#if ZEND_DEBUG
const char *open_filename;
- uint open_lineno;
+ uint32_t open_lineno;
#endif
struct _php_stream *enclosing_stream; /* this is a private stream owned by enclosing_stream */
@@ -249,11 +253,11 @@ END_EXTERN_C()
#define php_stream_get_resource_id(stream) ((php_stream *)(stream))->res->handle
/* use this to tell the stream that it is OK if we don't explicitly close it */
-#define php_stream_auto_cleanup(stream) { (stream)->__exposed++; }
+#define php_stream_auto_cleanup(stream) { (stream)->__exposed = 1; }
/* use this to assign the stream to a zval and tell the stream that is
* has been exported to the engine; it will expect to be closed automatically
* when the resources are auto-destructed */
-#define php_stream_to_zval(stream, zval) { ZVAL_RES(zval, (stream)->res); (stream)->__exposed++; }
+#define php_stream_to_zval(stream, zval) { ZVAL_RES(zval, (stream)->res); (stream)->__exposed = 1; }
#define php_stream_from_zval(xstr, pzval) do { \
if (((xstr) = (php_stream*)zend_fetch_resource2_ex((pzval), \
diff --git a/main/php_variables.c b/main/php_variables.c
index 3854c54880..c1fb36d6ad 100644
--- a/main/php_variables.c
+++ b/main/php_variables.c
@@ -542,7 +542,7 @@ void _php_import_environment_variables(zval *array_ptr)
}
}
-zend_bool php_std_auto_global_callback(char *name, uint name_len)
+zend_bool php_std_auto_global_callback(char *name, uint32_t name_len)
{
zend_printf("%s\n", name);
return 0; /* don't rearm */
@@ -801,6 +801,11 @@ static zend_bool php_auto_globals_create_server(zend_string *name)
zend_hash_update(&EG(symbol_table), name, &PG(http_globals)[TRACK_VARS_SERVER]);
Z_ADDREF(PG(http_globals)[TRACK_VARS_SERVER]);
+ /* TODO: TRACK_VARS_SERVER is modified in a number of places (e.g. phar) past this point,
+ * where rc>1 due to the $_SERVER global. Ideally this shouldn't happen, but for now we
+ * ignore this issue, as it would probably require larger changes. */
+ HT_ALLOW_COW_VIOLATION(Z_ARRVAL(PG(http_globals)[TRACK_VARS_SERVER]));
+
return 0; /* don't rearm */
}
diff --git a/main/php_version.h b/main/php_version.h
index 8f6afb8654..62cdcfceda 100644
--- a/main/php_version.h
+++ b/main/php_version.h
@@ -1,8 +1,8 @@
/* automatically generated by configure */
-/* edit configure.in to change version number */
+/* edit configure.ac to change version number */
#define PHP_MAJOR_VERSION 7
-#define PHP_MINOR_VERSION 1
-#define PHP_RELEASE_VERSION 3
+#define PHP_MINOR_VERSION 2
+#define PHP_RELEASE_VERSION 0
#define PHP_EXTRA_VERSION "-dev"
-#define PHP_VERSION "7.1.3-dev"
-#define PHP_VERSION_ID 70103
+#define PHP_VERSION "7.2.0-dev"
+#define PHP_VERSION_ID 70200
diff --git a/main/rfc1867.c b/main/rfc1867.c
index 264b234aa3..74f47f63a2 100644
--- a/main/rfc1867.c
+++ b/main/rfc1867.c
@@ -33,7 +33,7 @@
#include "php_variables.h"
#include "rfc1867.h"
#include "ext/standard/php_string.h"
-#include "ext/standard/php_smart_string.h"
+#include "zend_smart_string.h"
#if defined(PHP_WIN32) && !defined(HAVE_ATOLL)
# define atoll(s) _atoi64(s)
diff --git a/main/spprintf.c b/main/spprintf.c
index c8ec27dfcc..dd53fcd764 100644
--- a/main/spprintf.c
+++ b/main/spprintf.c
@@ -117,7 +117,7 @@
#define EXPONENT_LENGTH 10
#include "zend_smart_str.h"
-#include "ext/standard/php_smart_string.h"
+#include "zend_smart_string.h"
/* {{{ macros */
@@ -138,7 +138,6 @@
} while (0);
#define PAD_CHAR(xbuf, ch, count, is_char) do { \
- size_t newlen; \
if ((is_char)) { \
smart_string_alloc(((smart_string *)(xbuf)), (count), 0); \
memset(((smart_string *)(xbuf))->c + ((smart_string *)(xbuf))->len, (ch), (count)); \
@@ -828,76 +827,15 @@ skip_output:
}
/* }}} */
-/*
- * This is the general purpose conversion function.
- */
-PHPAPI size_t vspprintf(char **pbuf, size_t max_len, const char *format, va_list ap) /* {{{ */
+PHPAPI void php_printf_to_smart_string(smart_string *buf, const char *format, va_list ap) /* {{{ */
{
- smart_string buf = {0};
-
- /* since there are places where (v)spprintf called without checking for null,
- a bit of defensive coding here */
- if(!pbuf) {
- return 0;
- }
- xbuf_format_converter(&buf, 1, format, ap);
-
- if (max_len && buf.len > max_len) {
- buf.len = max_len;
- }
-
- smart_string_0(&buf);
-
- if (buf.c) {
- *pbuf = buf.c;
- return buf.len;
- } else {
- *pbuf = estrndup("", 0);
- return 0;
- }
+ xbuf_format_converter(buf, 1, format, ap);
}
/* }}} */
-PHPAPI size_t spprintf(char **pbuf, size_t max_len, const char *format, ...) /* {{{ */
+PHPAPI void php_printf_to_smart_str(smart_str *buf, const char *format, va_list ap) /* {{{ */
{
- size_t cc;
- va_list ap;
-
- va_start(ap, format);
- cc = vspprintf(pbuf, max_len, format, ap);
- va_end(ap);
- return (cc);
-}
-/* }}} */
-
-PHPAPI zend_string *vstrpprintf(size_t max_len, const char *format, va_list ap) /* {{{ */
-{
- smart_str buf = {0};
-
- xbuf_format_converter(&buf, 0, format, ap);
-
- if (!buf.s) {
- return ZSTR_EMPTY_ALLOC();
- }
-
- if (max_len && ZSTR_LEN(buf.s) > max_len) {
- ZSTR_LEN(buf.s) = max_len;
- }
-
- smart_str_0(&buf);
- return buf.s;
-}
-/* }}} */
-
-PHPAPI zend_string *strpprintf(size_t max_len, const char *format, ...) /* {{{ */
-{
- va_list ap;
- zend_string *str;
-
- va_start(ap, format);
- str = vstrpprintf(max_len, format, ap);
- va_end(ap);
- return str;
+ xbuf_format_converter(buf, 0, format, ap);
}
/* }}} */
diff --git a/main/spprintf.h b/main/spprintf.h
index 2a8f9aeb8e..89f23f19aa 100644
--- a/main/spprintf.h
+++ b/main/spprintf.h
@@ -16,36 +16,23 @@
+----------------------------------------------------------------------+
*/
-/* $Id$ */
-
-/*
-
-The pbuf parameter of all spprintf version receives a pointer to the allocated
-buffer. This buffer must be freed manually after usage using efree() function.
-The buffer will always be terminated by a zero character. When pbuf is NULL
-the function can be used to calculate the required size of the buffer but for
-that purpose snprintf is faster. When both pbuf and the return value are 0
-than you are out of memory.
-
-There is also snprintf: See difference explained in snprintf.h
-
-*/
-
#ifndef SPPRINTF_H
#define SPPRINTF_H
#include "snprintf.h"
+#include "zend_smart_str_public.h"
+#include "zend_smart_string_public.h"
BEGIN_EXTERN_C()
-PHPAPI size_t spprintf( char **pbuf, size_t max_len, const char *format, ...) PHP_ATTRIBUTE_FORMAT(printf, 3, 4);
-
-PHPAPI size_t vspprintf(char **pbuf, size_t max_len, const char *format, va_list ap) PHP_ATTRIBUTE_FORMAT(printf, 3, 0);
-
-PHPAPI zend_string *vstrpprintf(size_t max_len, const char *format, va_list ap) PHP_ATTRIBUTE_FORMAT(printf, 2, 0);
-
-PHPAPI zend_string *strpprintf(size_t max_len, const char *format, ...) PHP_ATTRIBUTE_FORMAT(printf, 2, 3);
+PHPAPI void php_printf_to_smart_string(smart_string *buf, const char *format, va_list ap);
+PHPAPI void php_printf_to_smart_str(smart_str *buf, const char *format, va_list ap);
END_EXTERN_C()
+#define spprintf zend_spprintf
+#define strpprintf zend_strpprintf
+#define vspprintf zend_vspprintf
+#define vstrpprintf zend_vstrpprintf
+
#endif /* SNPRINTF_H */
/*
diff --git a/main/streams/filter.c b/main/streams/filter.c
index 6c3cdb0e4d..dea4e442b5 100644
--- a/main/streams/filter.c
+++ b/main/streams/filter.c
@@ -68,7 +68,7 @@ PHPAPI int php_stream_filter_register_factory_volatile(const char *filterpattern
/* Buckets */
-PHPAPI php_stream_bucket *php_stream_bucket_new(php_stream *stream, char *buf, size_t buflen, int own_buf, int buf_persistent)
+PHPAPI php_stream_bucket *php_stream_bucket_new(php_stream *stream, char *buf, size_t buflen, uint8_t own_buf, uint8_t buf_persistent)
{
int is_persistent = php_stream_is_persistent(stream);
php_stream_bucket *bucket;
@@ -247,7 +247,7 @@ PHPAPI void php_stream_bucket_unlink(php_stream_bucket *bucket)
* match. If that fails, we try "convert.charset.*", then "convert.*"
* This means that we don't need to clog up the hashtable with a zillion
* charsets (for example) but still be able to provide them all as filters */
-PHPAPI php_stream_filter *php_stream_filter_create(const char *filtername, zval *filterparams, int persistent)
+PHPAPI php_stream_filter *php_stream_filter_create(const char *filtername, zval *filterparams, uint8_t persistent)
{
HashTable *filter_hash = (FG(stream_filters) ? FG(stream_filters) : &stream_filters_hash);
php_stream_filter_factory *factory = NULL;
@@ -290,7 +290,7 @@ PHPAPI php_stream_filter *php_stream_filter_create(const char *filtername, zval
return filter;
}
-PHPAPI php_stream_filter *_php_stream_filter_alloc(php_stream_filter_ops *fops, void *abstract, int persistent STREAMS_DC)
+PHPAPI php_stream_filter *_php_stream_filter_alloc(php_stream_filter_ops *fops, void *abstract, uint8_t persistent STREAMS_DC)
{
php_stream_filter *filter;
@@ -358,7 +358,7 @@ PHPAPI int php_stream_filter_append_ex(php_stream_filter_chain *chain, php_strea
php_stream_bucket_append(brig_inp, bucket);
status = filter->fops->filter(stream, filter, brig_inp, brig_outp, &consumed, PSFS_FLAG_NORMAL);
- if (stream->readpos + consumed > (uint)stream->writepos) {
+ if (stream->readpos + consumed > (uint32_t)stream->writepos) {
/* No behaving filter should cause this. */
status = PSFS_ERR_FATAL;
}
diff --git a/main/streams/glob_wrapper.c b/main/streams/glob_wrapper.c
index 1288fa6bad..1350962837 100644
--- a/main/streams/glob_wrapper.c
+++ b/main/streams/glob_wrapper.c
@@ -116,7 +116,7 @@ static void php_glob_stream_path_split(glob_s_t *pglob, const char *path, int ge
if ((pos = strrchr(path, '/')) != NULL) {
path = pos+1;
}
-#if defined(PHP_WIN32) || defined(NETWARE)
+#ifdef PHP_WIN32
if ((pos = strrchr(path, '\\')) != NULL) {
path = pos+1;
}
@@ -240,7 +240,7 @@ static php_stream *php_glob_stream_opener(php_stream_wrapper *wrapper, const cha
if ((tmp = strrchr(pos, '/')) != NULL) {
pos = tmp+1;
}
-#if defined(PHP_WIN32) || defined(NETWARE)
+#ifdef PHP_WIN32
if ((tmp = strrchr(pos, '\\')) != NULL) {
pos = tmp+1;
}
diff --git a/main/streams/memory.c b/main/streams/memory.c
index b1483e0786..41c09faca8 100644
--- a/main/streams/memory.c
+++ b/main/streams/memory.c
@@ -214,17 +214,9 @@ static int php_stream_memory_stat(php_stream *stream, php_stream_statbuf *ssb) /
ssb->sb.st_size = ms->fsize;
ssb->sb.st_mode |= S_IFREG; /* regular file */
-
-#ifdef NETWARE
- ssb->sb.st_mtime.tv_sec = timestamp;
- ssb->sb.st_atime.tv_sec = timestamp;
- ssb->sb.st_ctime.tv_sec = timestamp;
-#else
ssb->sb.st_mtime = timestamp;
ssb->sb.st_atime = timestamp;
ssb->sb.st_ctime = timestamp;
-#endif
-
ssb->sb.st_nlink = 1;
ssb->sb.st_rdev = -1;
/* this is only for APC, so use /dev/null device - no chance of conflict there! */
diff --git a/main/streams/php_stream_filter_api.h b/main/streams/php_stream_filter_api.h
index 3b9ca16145..c109ca9993 100644
--- a/main/streams/php_stream_filter_api.h
+++ b/main/streams/php_stream_filter_api.h
@@ -48,8 +48,8 @@ struct _php_stream_bucket {
char *buf;
size_t buflen;
/* if non-zero, buf should be pefreed when the bucket is destroyed */
- int own_buf;
- int is_persistent;
+ uint8_t own_buf;
+ uint8_t is_persistent;
/* destroy this struct when refcount falls to zero */
int refcount;
@@ -67,7 +67,7 @@ typedef enum {
/* Buckets API. */
BEGIN_EXTERN_C()
-PHPAPI php_stream_bucket *php_stream_bucket_new(php_stream *stream, char *buf, size_t buflen, int own_buf, int buf_persistent);
+PHPAPI php_stream_bucket *php_stream_bucket_new(php_stream *stream, char *buf, size_t buflen, uint8_t own_buf, uint8_t buf_persistent);
PHPAPI int php_stream_bucket_split(php_stream_bucket *in, php_stream_bucket **left, php_stream_bucket **right, size_t length);
PHPAPI void php_stream_bucket_delref(php_stream_bucket *bucket);
#define php_stream_bucket_addref(bucket) (bucket)->refcount++
@@ -131,7 +131,7 @@ PHPAPI int php_stream_filter_append_ex(php_stream_filter_chain *chain, php_strea
PHPAPI int _php_stream_filter_flush(php_stream_filter *filter, int finish);
PHPAPI php_stream_filter *php_stream_filter_remove(php_stream_filter *filter, int call_dtor);
PHPAPI void php_stream_filter_free(php_stream_filter *filter);
-PHPAPI php_stream_filter *_php_stream_filter_alloc(php_stream_filter_ops *fops, void *abstract, int persistent STREAMS_DC);
+PHPAPI php_stream_filter *_php_stream_filter_alloc(php_stream_filter_ops *fops, void *abstract, uint8_t persistent STREAMS_DC);
END_EXTERN_C()
#define php_stream_filter_alloc(fops, thisptr, persistent) _php_stream_filter_alloc((fops), (thisptr), (persistent) STREAMS_CC)
#define php_stream_filter_alloc_rel(fops, thisptr, persistent) _php_stream_filter_alloc((fops), (thisptr), (persistent) STREAMS_REL_CC)
@@ -142,14 +142,14 @@ END_EXTERN_C()
#define php_stream_is_filtered(stream) ((stream)->readfilters.head || (stream)->writefilters.head)
typedef struct _php_stream_filter_factory {
- php_stream_filter *(*create_filter)(const char *filtername, zval *filterparams, int persistent);
+ php_stream_filter *(*create_filter)(const char *filtername, zval *filterparams, uint8_t persistent);
} php_stream_filter_factory;
BEGIN_EXTERN_C()
PHPAPI int php_stream_filter_register_factory(const char *filterpattern, php_stream_filter_factory *factory);
PHPAPI int php_stream_filter_unregister_factory(const char *filterpattern);
PHPAPI int php_stream_filter_register_factory_volatile(const char *filterpattern, php_stream_filter_factory *factory);
-PHPAPI php_stream_filter *php_stream_filter_create(const char *filtername, zval *filterparams, int persistent);
+PHPAPI php_stream_filter *php_stream_filter_create(const char *filtername, zval *filterparams, uint8_t persistent);
END_EXTERN_C()
/*
diff --git a/main/streams/plain_wrapper.c b/main/streams/plain_wrapper.c
index 6bc0138f29..55b3d4278c 100644
--- a/main/streams/plain_wrapper.c
+++ b/main/streams/plain_wrapper.c
@@ -51,7 +51,7 @@
#define php_stream_fopen_from_file_int(file, mode) _php_stream_fopen_from_file_int((file), (mode) STREAMS_CC)
#define php_stream_fopen_from_file_int_rel(file, mode) _php_stream_fopen_from_file_int((file), (mode) STREAMS_REL_CC)
-#if !defined(WINDOWS) && !defined(NETWARE)
+#ifndef PHP_WIN32
extern int php_get_uid_by_name(const char *name, uid_t *uid);
extern int php_get_gid_by_name(const char *name, gid_t *gid);
#endif
@@ -1170,7 +1170,7 @@ static int php_plain_files_rename(php_stream_wrapper *wrapper, const char *url_f
zend_stat_t sb;
if (php_copy_file(url_from, url_to) == SUCCESS) {
if (VCWD_STAT(url_from, &sb) == 0) {
-# if !defined(TSRM_WIN32) && !defined(NETWARE)
+# ifndef TSRM_WIN32
if (VCWD_CHMOD(url_to, sb.st_mode)) {
if (errno == EPERM) {
php_error_docref2(NULL, url_from, url_to, E_WARNING, "%s", strerror(errno));
@@ -1331,7 +1331,7 @@ static int php_plain_files_rmdir(php_stream_wrapper *wrapper, const char *url, i
static int php_plain_files_metadata(php_stream_wrapper *wrapper, const char *url, int option, void *value, php_stream_context *context)
{
struct utimbuf *newtime;
-#if !defined(WINDOWS) && !defined(NETWARE)
+#ifndef PHP_WIN32
uid_t uid;
gid_t gid;
#endif
@@ -1370,7 +1370,7 @@ static int php_plain_files_metadata(php_stream_wrapper *wrapper, const char *url
ret = VCWD_UTIME(url, newtime);
break;
-#if !defined(WINDOWS) && !defined(NETWARE)
+#ifndef PHP_WIN32
case PHP_STREAM_META_OWNER_NAME:
case PHP_STREAM_META_OWNER:
if(option == PHP_STREAM_META_OWNER_NAME) {
diff --git a/main/streams/streams.c b/main/streams/streams.c
index 0ad72a6433..ed4b257848 100644
--- a/main/streams/streams.c
+++ b/main/streams/streams.c
@@ -1661,7 +1661,7 @@ int php_init_stream_wrappers(int module_number)
return (php_stream_xport_register("tcp", php_stream_generic_socket_factory) == SUCCESS
&&
php_stream_xport_register("udp", php_stream_generic_socket_factory) == SUCCESS
-#if defined(AF_UNIX) && !(defined(PHP_WIN32) || defined(__riscos__) || defined(NETWARE))
+#if defined(AF_UNIX) && !(defined(PHP_WIN32) || defined(__riscos__))
&&
php_stream_xport_register("unix", php_stream_generic_socket_factory) == SUCCESS
&&
diff --git a/main/streams/userspace.c b/main/streams/userspace.c
index 2b21dc9616..da39dcaf7c 100644
--- a/main/streams/userspace.c
+++ b/main/streams/userspace.c
@@ -859,15 +859,9 @@ static int statbuf_from_array(zval *array, php_stream_statbuf *ssb)
STAT_PROP_ENTRY(rdev);
#endif
STAT_PROP_ENTRY(size);
-#ifdef NETWARE
- STAT_PROP_ENTRY_EX(atime, atime.tv_sec);
- STAT_PROP_ENTRY_EX(mtime, mtime.tv_sec);
- STAT_PROP_ENTRY_EX(ctime, ctime.tv_sec);
-#else
STAT_PROP_ENTRY(atime);
STAT_PROP_ENTRY(mtime);
STAT_PROP_ENTRY(ctime);
-#endif
#ifdef HAVE_ST_BLKSIZE
STAT_PROP_ENTRY(blksize);
#endif
diff --git a/main/streams/xp_socket.c b/main/streams/xp_socket.c
index 1344e0b8b8..59ece7d27e 100644
--- a/main/streams/xp_socket.c
+++ b/main/streams/xp_socket.c
@@ -23,7 +23,7 @@
#include "streams/php_streams_int.h"
#include "php_network.h"
-#if defined(PHP_WIN32) || defined(__riscos__) || defined(NETWARE)
+#if defined(PHP_WIN32) || defined(__riscos__)
# undef AF_UNIX
#endif
diff --git a/main/strlcat.c b/main/strlcat.c
index 30dfd0f8a9..a381b1433c 100644
--- a/main/strlcat.c
+++ b/main/strlcat.c
@@ -22,7 +22,7 @@
#ifndef HAVE_STRLCAT
-/* $OpenBSD: strlcat.c,v 1.2 1999/06/17 16:28:58 millert Exp $ */
+/* $OpenBSD: strlcat.c,v 1.17 2016/10/14 18:19:04 dtucker Exp $ */
/*
* Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -52,7 +52,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char *rcsid = "$OpenBSD: strlcat.c,v 1.2 1999/06/17 16:28:58 millert Exp $";
+static char *rcsid = "$OpenBSD: strlcat.c,v 1.17 2016/10/14 18:19:04 dtucker Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
@@ -69,29 +69,34 @@ PHPAPI size_t php_strlcat(dst, src, siz)
const char *src;
size_t siz;
{
- register char *d = dst;
- register const char *s = src;
- register size_t n = siz;
+ const char *d = dst;
+ const char *s = src;
+ size_t n = siz;
size_t dlen;
/* Find the end of dst and adjust bytes left but don't go past end */
- while (*d != '\0' && n-- != 0)
- d++;
- dlen = d - dst;
+ while (n-- != 0 && *dst != '\0')
+ dst++;
+ dlen = (uintptr_t)dst - (uintptr_t)d;
n = siz - dlen;
- if (n == 0)
- return(dlen + strlen(s));
- while (*s != '\0') {
- if (n != 1) {
- *d++ = *s;
+ if (n-- == 0)
+ return(dlen + strlen(src));
+ while (*src != '\0') {
+ if (n != 0) {
+ *dst++ = *src;
n--;
}
- s++;
+ src++;
}
- *d = '\0';
+ *dst = '\0';
- return(dlen + (s - src)); /* count does not include NUL */
+ /*
+ * Cast pointers to unsigned type before calculation, to avoid signed
+ * overflow when the string ends where the MSB has changed.
+ * Return value does not include NUL.
+ */
+ return(dlen + ((uintptr_t)src - (uintptr_t)s));
}
#endif /* !HAVE_STRLCAT */
diff --git a/main/strlcpy.c b/main/strlcpy.c
index 8d7b2652ea..3e66140ef6 100644
--- a/main/strlcpy.c
+++ b/main/strlcpy.c
@@ -22,7 +22,7 @@
#ifndef HAVE_STRLCPY
-/* $OpenBSD: strlcpy.c,v 1.4 1999/05/01 18:56:41 millert Exp $ */
+/* $OpenBSD: strlcpy.c,v 1.15 2016/10/16 17:37:39 dtucker Exp $ */
/*
* Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -52,7 +52,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char *rcsid = "$OpenBSD: strlcpy.c,v 1.4 1999/05/01 18:56:41 millert Exp $";
+static char *rcsid = "$OpenBSD: strlcpy.c,v 1.15 2016/10/16 17:37:39 dtucker Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
@@ -68,27 +68,31 @@ PHPAPI size_t php_strlcpy(dst, src, siz)
const char *src;
size_t siz;
{
- register char *d = dst;
- register const char *s = src;
- register size_t n = siz;
+ const char *s = src;
+ size_t n = siz;
/* Copy as many bytes as will fit */
- if (n != 0 && --n != 0) {
- do {
- if ((*d++ = *s++) == 0)
+ if (n != 0) {
+ while (--n != 0) {
+ if ((*dst++ = *src++) == 0)
break;
- } while (--n != 0);
+ }
}
/* Not enough room in dst, add NUL and traverse rest of src */
if (n == 0) {
if (siz != 0)
- *d = '\0'; /* NUL-terminate dst */
- while (*s++)
+ *dst = '\0'; /* NUL-terminate dst */
+ while (*src++)
;
}
- return(s - src - 1); /* count does not include NUL */
+ /*
+ * Cast pointers to unsigned type before calculation, to avoid signed
+ * overflow when the string ends where the MSB has changed.
+ * Return value does not include NUL.
+ */
+ return((uintptr_t)src - (uintptr_t)s - 1);
}
#endif /* !HAVE_STRLCPY */
diff --git a/main/win95nt.h b/main/win95nt.h
deleted file mode 100644
index 3b0bbc866e..0000000000
--- a/main/win95nt.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- +----------------------------------------------------------------------+
- | PHP Version 7 |
- +----------------------------------------------------------------------+
- | Copyright (c) 1997-2017 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: |
- +----------------------------------------------------------------------+
-*/
-
-/* $Id$ */
-
-/* Defines and types for Windows 95/NT */
-#define HAVE_DECLARED_TIMEZONE
-#define WIN32_LEAN_AND_MEAN
-#include <io.h>
-#include <malloc.h>
-#include <direct.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <stdarg.h>
-#include <sys/types.h>
-#include <process.h>
-
-typedef int uid_t;
-typedef int gid_t;
-typedef char * caddr_t;
-#define lstat(x, y) php_sys_lstat(x, y)
-#define _IFIFO 0010000 /* fifo */
-#define _IFBLK 0060000 /* block special */
-#define _IFLNK 0120000 /* symbolic link */
-#define S_IFIFO _IFIFO
-#define S_IFBLK _IFBLK
-#ifndef S_IFLNK
-# define S_IFLNK _IFLNK
-#endif
-#define chdir(path) _chdir(path)
-#define mkdir(a, b) _mkdir(a)
-#define rmdir(a) _rmdir(a)
-#define getpid _getpid
-#define php_sleep(t) SleepEx(t*1000, TRUE)
-#ifndef getcwd
-# define getcwd(a, b) _getcwd(a, b)
-#endif
-#define off_t _off_t
-typedef unsigned int uint;
-typedef unsigned long ulong;
-#if !NSAPI
-typedef int pid_t;
-#endif
-
-/* missing in vc5 math.h */
-#define M_PI 3.14159265358979323846
-#define M_TWOPI (M_PI * 2.0)
-#define M_PI_2 1.57079632679489661923
-#ifndef M_PI_4
-#define M_PI_4 0.78539816339744830962
-#endif
-
-#if !defined(PHP_DEBUG)
-#ifdef inline
-#undef inline
-#endif
-#define inline __inline
-#endif
-
-/* General Windows stuff */
-#ifndef WINDOWS
-# define WINDOWS 1
-#endif
-
-
-/* Prevent use of VC5 OpenFile function */
-#define NOOPENFILE
-
-/* sendmail is built-in */
-#ifdef PHP_PROG_SENDMAIL
-#undef PHP_PROG_SENDMAIL
-#define PHP_PROG_SENDMAIL "Built in mailer"
-#endif