diff options
author | Ondřej Surý <ondrej@sury.org> | 2012-04-06 14:37:49 +0200 |
---|---|---|
committer | Ondřej Surý <ondrej@sury.org> | 2012-04-06 14:37:49 +0200 |
commit | 7b10b0041aa63c6f8990ceb3ccc190bdd9eea2b9 (patch) | |
tree | 01edb9389d7b7f6b277a57e2bce1d05f9748d609 /main | |
parent | 096b2f823b2273e3ee707b3805feb78d1e4be61d (diff) | |
download | php-7b10b0041aa63c6f8990ceb3ccc190bdd9eea2b9.tar.gz |
Imported Upstream version 5.4.1~rc1upstream/5.4.1_rc1
Diffstat (limited to 'main')
71 files changed, 257 insertions, 185 deletions
diff --git a/main/SAPI.c b/main/SAPI.c index 88c5a254e..74fdbb2c4 100644 --- a/main/SAPI.c +++ b/main/SAPI.c @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: SAPI.c 321634 2012-01-01 13:15:04Z felipe $ */ +/* $Id$ */ #include <ctype.h> #include <sys/stat.h> @@ -494,9 +494,6 @@ static void sapi_send_headers_free(TSRMLS_D) SAPI_API void sapi_deactivate(TSRMLS_D) { zend_llist_destroy(&SG(sapi_headers).headers); - if (SG(callback_func)) { - zval_ptr_dtor(&SG(callback_func)); - } if (SG(request_info).post_data) { efree(SG(request_info).post_data); } else if (SG(server_context)) { @@ -710,16 +707,26 @@ SAPI_API int sapi_header_op(sapi_header_op_enum op, void *arg TSRMLS_DC) efree(header_line); return SUCCESS; } else { - /* new line safety check */ - char *s = header_line, *e = header_line + header_line_len, *p; - while (s < e && ((p = memchr(s, '\n', (e - s))) || (p = memchr(s, '\r', (e - s))))) { - if (*(p + 1) == ' ' || *(p + 1) == '\t') { - s = p + 1; - continue; + /* new line/NUL character safety check */ + int i; + for (i = 0; i < header_line_len; i++) { + /* RFC 2616 allows new lines if followed by SP or HT */ + int illegal_break = + (header_line[i+1] != ' ' && header_line[i+1] != '\t') + && ( + header_line[i] == '\n' + || (header_line[i] == '\r' && header_line[i+1] != '\n')); + if (illegal_break) { + efree(header_line); + sapi_module.sapi_error(E_WARNING, "Header may not contain " + "more than a single header, new line detected"); + return FAILURE; + } + if (header_line[i] == '\0') { + efree(header_line); + sapi_module.sapi_error(E_WARNING, "Header may not contain NUL bytes"); + return FAILURE; } - efree(header_line); - sapi_module.sapi_error(E_WARNING, "Header may not contain more than a single header, new line detected."); - return FAILURE; } } diff --git a/main/SAPI.h b/main/SAPI.h index 838fecf57..f868f852e 100644 --- a/main/SAPI.h +++ b/main/SAPI.h @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: SAPI.h 321634 2012-01-01 13:15:04Z felipe $ */ +/* $Id$ */ #ifndef SAPI_H #define SAPI_H diff --git a/main/alloca.c b/main/alloca.c index 2fb937021..401649cee 100644 --- a/main/alloca.c +++ b/main/alloca.c @@ -21,7 +21,7 @@ allocating any. It is a good idea to use alloca(0) in your main control loop, etc. to force garbage collection. */ -/* $Id: alloca.c 242949 2007-09-26 15:44:16Z cvs2svn $ */ +/* $Id$ */ #include <php_config.h> diff --git a/main/build-defs.h.in b/main/build-defs.h.in index 9143a9c25..aa1fbf032 100644 --- a/main/build-defs.h.in +++ b/main/build-defs.h.in @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: build-defs.h.in 310307 2011-04-18 09:50:32Z bjori $ */ +/* $Id$ */ #define CONFIGURE_COMMAND "@CONFIGURE_COMMAND@" #define PHP_ADA_INCLUDE "" diff --git a/main/fopen_wrappers.c b/main/fopen_wrappers.c index ed33c77a4..9d4a8a85c 100644 --- a/main/fopen_wrappers.c +++ b/main/fopen_wrappers.c @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: fopen_wrappers.c 321634 2012-01-01 13:15:04Z felipe $ */ +/* $Id$ */ /* {{{ includes */ diff --git a/main/fopen_wrappers.h b/main/fopen_wrappers.h index 542b130b9..6dcc6e1cc 100644 --- a/main/fopen_wrappers.h +++ b/main/fopen_wrappers.h @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: fopen_wrappers.h 321634 2012-01-01 13:15:04Z felipe $ */ +/* $Id$ */ #ifndef FOPEN_WRAPPERS_H #define FOPEN_WRAPPERS_H diff --git a/main/getopt.c b/main/getopt.c index 9825622bd..7761e6ac6 100644 --- a/main/getopt.c +++ b/main/getopt.c @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: getopt.c 321634 2012-01-01 13:15:04Z felipe $ */ +/* $Id$ */ #include <stdio.h> #include <string.h> diff --git a/main/internal_functions.c.in b/main/internal_functions.c.in index b0f9ef6b8..f1e66b160 100644 --- a/main/internal_functions.c.in +++ b/main/internal_functions.c.in @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: internal_functions.c.in 265279 2008-08-22 12:59:46Z helly $ */ +/* $Id$ */ #include "php.h" #include "php_main.h" diff --git a/main/internal_functions_nw.c b/main/internal_functions_nw.c index 8f9d20e9b..d4de5e436 100644 --- a/main/internal_functions_nw.c +++ b/main/internal_functions_nw.c @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: internal_functions_nw.c 321634 2012-01-01 13:15:04Z felipe $ */ +/* $Id$ */ /* {{{ includes */ diff --git a/main/internal_functions_win32.c b/main/internal_functions_win32.c index 3295dc19a..e78922ac1 100644 --- a/main/internal_functions_win32.c +++ b/main/internal_functions_win32.c @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: internal_functions_win32.c 321634 2012-01-01 13:15:04Z felipe $ */ +/* $Id$ */ /* {{{ includes */ diff --git a/main/logos.h b/main/logos.h index 784536102..3b65cbbcf 100644 --- a/main/logos.h +++ b/main/logos.h @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: logos.h 321634 2012-01-01 13:15:04Z felipe $ */ +/* $Id$ */ #define CONTEXT_TYPE_IMAGE_GIF "Content-Type: image/gif" diff --git a/main/main.c b/main/main.c index 230146096..6a04ddbaf 100644 --- a/main/main.c +++ b/main/main.c @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: main.c 323245 2012-02-16 01:51:45Z stas $ */ +/* $Id$ */ /* {{{ includes */ @@ -552,7 +552,7 @@ PHP_INI_BEGIN() PHP_INI_ENTRY("mail.force_extra_parameters",NULL, PHP_INI_SYSTEM|PHP_INI_PERDIR, OnChangeMailForceExtra) PHP_INI_ENTRY("disable_functions", "", PHP_INI_SYSTEM, NULL) PHP_INI_ENTRY("disable_classes", "", PHP_INI_SYSTEM, NULL) - PHP_INI_ENTRY("max_file_uploads", "20", PHP_INI_SYSTEM, NULL) + PHP_INI_ENTRY("max_file_uploads", "20", PHP_INI_SYSTEM|PHP_INI_PERDIR, NULL) STD_PHP_INI_BOOLEAN("allow_url_fopen", "1", PHP_INI_SYSTEM, OnUpdateBool, allow_url_fopen, php_core_globals, core_globals) STD_PHP_INI_BOOLEAN("allow_url_include", "0", PHP_INI_SYSTEM, OnUpdateBool, allow_url_include, php_core_globals, core_globals) diff --git a/main/mergesort.c b/main/mergesort.c index fb62625d6..4555e1bc8 100644 --- a/main/mergesort.c +++ b/main/mergesort.c @@ -34,7 +34,7 @@ * SUCH DAMAGE. */ -/* $Id: mergesort.c 265279 2008-08-22 12:59:46Z helly $ */ +/* $Id$ */ #if defined(LIBC_SCCS) && !defined(lint) static char sccsid[] = "@(#)merge.c 8.2 (Berkeley) 2/14/94"; diff --git a/main/network.c b/main/network.c index 3e606f799..6c7031f98 100644 --- a/main/network.c +++ b/main/network.c @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: network.c 321634 2012-01-01 13:15:04Z felipe $ */ +/* $Id$ */ /*#define DEBUG_MAIN_NETWORK 1*/ diff --git a/main/output.c b/main/output.c index 092d2b902..138339ea9 100644 --- a/main/output.c +++ b/main/output.c @@ -19,7 +19,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: output.c 323219 2012-02-14 19:31:54Z mike $ */ +/* $Id$ */ #ifndef PHP_OUTPUT_DEBUG # define PHP_OUTPUT_DEBUG 0 diff --git a/main/php.h b/main/php.h index 577be30fc..2a93118ac 100644 --- a/main/php.h +++ b/main/php.h @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php.h 321634 2012-01-01 13:15:04Z felipe $ */ +/* $Id$ */ #ifndef PHP_H #define PHP_H @@ -61,13 +61,9 @@ # define PHPAPI # endif -#define THREAD_LS -#define PHP_DIR_SEPARATOR '/' -#if defined(__MacOSX__) -#define PHP_EOL "\r" -#else -#define PHP_EOL "\n" -#endif +# define THREAD_LS +# define PHP_DIR_SEPARATOR '/' +# define PHP_EOL "\n" #endif #ifdef NETWARE diff --git a/main/php_compat.h b/main/php_compat.h index 0121babf8..80f43d4ee 100644 --- a/main/php_compat.h +++ b/main/php_compat.h @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_compat.h 323096 2012-02-06 18:11:56Z rasmus $ */ +/* $Id$ */ #ifndef PHP_COMPAT_H #define PHP_COMPAT_H diff --git a/main/php_content_types.c b/main/php_content_types.c index 8a2d93838..cca006ad6 100644 --- a/main/php_content_types.c +++ b/main/php_content_types.c @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_content_types.c 321634 2012-01-01 13:15:04Z felipe $ */ +/* $Id$ */ #include "php.h" #include "SAPI.h" diff --git a/main/php_content_types.h b/main/php_content_types.h index 5761e3f60..d2e79f3c2 100644 --- a/main/php_content_types.h +++ b/main/php_content_types.h @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_content_types.h 321634 2012-01-01 13:15:04Z felipe $ */ +/* $Id$ */ #ifndef PHP_CONTENT_TYPES_H #define PHP_CONTENT_TYPES_H diff --git a/main/php_getopt.h b/main/php_getopt.h index c077d1005..1f514d359 100644 --- a/main/php_getopt.h +++ b/main/php_getopt.h @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_getopt.h 321634 2012-01-01 13:15:04Z felipe $ */ +/* $Id$ */ #ifndef PHP_GETOPT_H #define PHP_GETOPT_H diff --git a/main/php_globals.h b/main/php_globals.h index 4fdb19d90..514c27869 100644 --- a/main/php_globals.h +++ b/main/php_globals.h @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_globals.h 321634 2012-01-01 13:15:04Z felipe $ */ +/* $Id$ */ #ifndef PHP_GLOBALS_H #define PHP_GLOBALS_H diff --git a/main/php_ini.c b/main/php_ini.c index 14f68661c..89a3d7e46 100644 --- a/main/php_ini.c +++ b/main/php_ini.c @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_ini.c 321634 2012-01-01 13:15:04Z felipe $ */ +/* $Id$ */ #include "php.h" #include "ext/standard/info.h" diff --git a/main/php_ini.h b/main/php_ini.h index 024e6f320..9645143e2 100644 --- a/main/php_ini.h +++ b/main/php_ini.h @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_ini.h 321634 2012-01-01 13:15:04Z felipe $ */ +/* $Id$ */ #ifndef PHP_INI_H #define PHP_INI_H diff --git a/main/php_logos.c b/main/php_logos.c index 63c21c2e6..3689f71e9 100644 --- a/main/php_logos.c +++ b/main/php_logos.c @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_logos.c 321634 2012-01-01 13:15:04Z felipe $ */ +/* $Id$ */ #include "php.h" #include "logos.h" diff --git a/main/php_logos.h b/main/php_logos.h index d147f7859..b9e1144c0 100644 --- a/main/php_logos.h +++ b/main/php_logos.h @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_logos.h 321634 2012-01-01 13:15:04Z felipe $ */ +/* $Id$ */ #ifndef _PHP_LOGOS_H diff --git a/main/php_main.h b/main/php_main.h index 72fe0fb4b..124be2379 100644 --- a/main/php_main.h +++ b/main/php_main.h @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_main.h 321634 2012-01-01 13:15:04Z felipe $ */ +/* $Id$ */ #ifndef PHP_MAIN_H #define PHP_MAIN_H diff --git a/main/php_memory_streams.h b/main/php_memory_streams.h index 2514859d8..e23bea69f 100644 --- a/main/php_memory_streams.h +++ b/main/php_memory_streams.h @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_memory_streams.h 321634 2012-01-01 13:15:04Z felipe $ */ +/* $Id$ */ #ifndef PHP_MEMORY_STREAM_H #define PHP_MEMORY_STREAM_H diff --git a/main/php_network.h b/main/php_network.h index f04222ea7..607889004 100644 --- a/main/php_network.h +++ b/main/php_network.h @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_network.h 321634 2012-01-01 13:15:04Z felipe $ */ +/* $Id$ */ #ifndef _PHP_NETWORK_H #define _PHP_NETWORK_H diff --git a/main/php_open_temporary_file.c b/main/php_open_temporary_file.c index 702f67709..8d5c9e9ee 100644 --- a/main/php_open_temporary_file.c +++ b/main/php_open_temporary_file.c @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_open_temporary_file.c 321634 2012-01-01 13:15:04Z felipe $ */ +/* $Id$ */ #include "php.h" diff --git a/main/php_open_temporary_file.h b/main/php_open_temporary_file.h index 6735f5885..234adb6e9 100644 --- a/main/php_open_temporary_file.h +++ b/main/php_open_temporary_file.h @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_open_temporary_file.h 321634 2012-01-01 13:15:04Z felipe $ */ +/* $Id$ */ #ifndef PHP_OPEN_TEMPORARY_FILE_H #define PHP_OPEN_TEMPORARY_FILE_H diff --git a/main/php_output.h b/main/php_output.h index 12b92872e..e4ab0f920 100644 --- a/main/php_output.h +++ b/main/php_output.h @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_output.h 322743 2012-01-25 17:22:46Z mike $ */ +/* $Id$ */ #ifndef PHP_OUTPUT_H #define PHP_OUTPUT_H diff --git a/main/php_reentrancy.h b/main/php_reentrancy.h index e8323c357..e81d6d617 100644 --- a/main/php_reentrancy.h +++ b/main/php_reentrancy.h @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_reentrancy.h 321634 2012-01-01 13:15:04Z felipe $ */ +/* $Id$ */ #ifndef PHP_REENTRANCY_H #define PHP_REENTRANCY_H diff --git a/main/php_scandir.c b/main/php_scandir.c index 306ee0fc1..5237afb8b 100644 --- a/main/php_scandir.c +++ b/main/php_scandir.c @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_scandir.c 321634 2012-01-01 13:15:04Z felipe $ */ +/* $Id$ */ #include "php.h" #include "php_scandir.h" diff --git a/main/php_scandir.h b/main/php_scandir.h index 022b951ea..eb63a2c11 100644 --- a/main/php_scandir.h +++ b/main/php_scandir.h @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_scandir.h 321634 2012-01-01 13:15:04Z felipe $ */ +/* $Id$ */ #ifndef PHP_SCANDIR_H #define PHP_SCANDIR_H diff --git a/main/php_sprintf.c b/main/php_sprintf.c index 098ff8fd4..265fcffe4 100644 --- a/main/php_sprintf.c +++ b/main/php_sprintf.c @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_sprintf.c 321634 2012-01-01 13:15:04Z felipe $ */ +/* $Id$ */ #include <stdio.h> #include <stdarg.h> diff --git a/main/php_streams.h b/main/php_streams.h index 61b0129fe..82498d661 100755 --- a/main/php_streams.h +++ b/main/php_streams.h @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_streams.h 321634 2012-01-01 13:15:04Z felipe $ */ +/* $Id$ */ #ifndef PHP_STREAMS_H #define PHP_STREAMS_H @@ -164,8 +164,8 @@ struct _php_stream_wrapper { int is_url; /* so that PG(allow_url_fopen) can be respected */ /* support for wrappers to return (multiple) error messages to the stream opener */ - int err_count; - char **err_stack; + int err_count; /* unused */ + char **err_stack; /* unusued */ }; #define PHP_STREAM_FLAG_NO_SEEK 1 diff --git a/main/php_syslog.h b/main/php_syslog.h index 3fe6f29e2..113b0af52 100644 --- a/main/php_syslog.h +++ b/main/php_syslog.h @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_syslog.h 321634 2012-01-01 13:15:04Z felipe $ */ +/* $Id$ */ #ifndef PHP_SYSLOG_H #define PHP_SYSLOG_H diff --git a/main/php_ticks.c b/main/php_ticks.c index 0a6ffd316..c5d152ebb 100644 --- a/main/php_ticks.c +++ b/main/php_ticks.c @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_ticks.c 321634 2012-01-01 13:15:04Z felipe $ */ +/* $Id$ */ #include "php.h" #include "php_ticks.h" diff --git a/main/php_ticks.h b/main/php_ticks.h index 4f47e85b5..09bd1c53c 100644 --- a/main/php_ticks.h +++ b/main/php_ticks.h @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_ticks.h 321634 2012-01-01 13:15:04Z felipe $ */ +/* $Id$ */ #ifndef PHP_TICKS_H #define PHP_TICKS_H diff --git a/main/php_variables.c b/main/php_variables.c index 9ad7a96a4..427966170 100644 --- a/main/php_variables.c +++ b/main/php_variables.c @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_variables.c 323202 2012-02-14 08:58:52Z dmitry $ */ +/* $Id$ */ #include <stdio.h> #include "php.h" @@ -133,7 +133,7 @@ PHPAPI void php_register_variable_ex(char *var_name, zval *val, zval *track_vars if (track_vars_array) { ht = Z_ARRVAL_P(track_vars_array); - zend_hash_del(ht, var, var_len + 1); + zend_symtable_del(ht, var, var_len + 1); } zval_dtor(val); diff --git a/main/php_variables.h b/main/php_variables.h index 59b0507c3..31b8ffb9f 100644 --- a/main/php_variables.h +++ b/main/php_variables.h @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_variables.h 321634 2012-01-01 13:15:04Z felipe $ */ +/* $Id$ */ #ifndef PHP_VARIABLES_H #define PHP_VARIABLES_H diff --git a/main/php_version.h b/main/php_version.h index d3fb8f322..5825b7cf2 100644 --- a/main/php_version.h +++ b/main/php_version.h @@ -2,7 +2,7 @@ /* edit configure.in to change version number */ #define PHP_MAJOR_VERSION 5 #define PHP_MINOR_VERSION 4 -#define PHP_RELEASE_VERSION 0 -#define PHP_EXTRA_VERSION "" -#define PHP_VERSION "5.4.0" -#define PHP_VERSION_ID 50400 +#define PHP_RELEASE_VERSION 1 +#define PHP_EXTRA_VERSION "RC1" +#define PHP_VERSION "5.4.1RC1" +#define PHP_VERSION_ID 50401 diff --git a/main/reentrancy.c b/main/reentrancy.c index d67760ffa..789678173 100644 --- a/main/reentrancy.c +++ b/main/reentrancy.c @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: reentrancy.c 321634 2012-01-01 13:15:04Z felipe $ */ +/* $Id$ */ #include <sys/types.h> #include <string.h> diff --git a/main/rfc1867.c b/main/rfc1867.c index 19d643bb7..5da3a9935 100644 --- a/main/rfc1867.c +++ b/main/rfc1867.c @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: rfc1867.c 323202 2012-02-14 08:58:52Z dmitry $ */ +/* $Id$ */ /* * This product includes software developed by the Apache Group diff --git a/main/rfc1867.h b/main/rfc1867.h index 81b6ad7a6..618458be3 100644 --- a/main/rfc1867.h +++ b/main/rfc1867.h @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: rfc1867.h 321634 2012-01-01 13:15:04Z felipe $ */ +/* $Id$ */ #ifndef RFC1867_H #define RFC1867_H diff --git a/main/snprintf.c b/main/snprintf.c index 15d6e85e3..cd038d018 100644 --- a/main/snprintf.c +++ b/main/snprintf.c @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: snprintf.c 321634 2012-01-01 13:15:04Z felipe $ */ +/* $Id$ */ #define _GNU_SOURCE #include "php.h" diff --git a/main/snprintf.h b/main/snprintf.h index 32c41729b..708686933 100644 --- a/main/snprintf.h +++ b/main/snprintf.h @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: snprintf.h 321634 2012-01-01 13:15:04Z felipe $ */ +/* $Id$ */ /* diff --git a/main/spprintf.c b/main/spprintf.c index 34bbb89d4..ef51cc5f4 100644 --- a/main/spprintf.c +++ b/main/spprintf.c @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: spprintf.c 321634 2012-01-01 13:15:04Z felipe $ */ +/* $Id$ */ /* This is the spprintf implementation. * It has emerged from apache snprintf. See original header: diff --git a/main/spprintf.h b/main/spprintf.h index 30a0dea58..9028b8d29 100644 --- a/main/spprintf.h +++ b/main/spprintf.h @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: spprintf.h 321634 2012-01-01 13:15:04Z felipe $ */ +/* $Id$ */ /* diff --git a/main/streams/cast.c b/main/streams/cast.c index 01f0aa5bc..da56e8667 100644 --- a/main/streams/cast.c +++ b/main/streams/cast.c @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: cast.c 321634 2012-01-01 13:15:04Z felipe $ */ +/* $Id$ */ #define _GNU_SOURCE #include "php.h" diff --git a/main/streams/filter.c b/main/streams/filter.c index 8c4f0a03d..ea38860f8 100644 --- a/main/streams/filter.c +++ b/main/streams/filter.c @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: filter.c 321634 2012-01-01 13:15:04Z felipe $ */ +/* $Id$ */ #include "php.h" #include "php_globals.h" diff --git a/main/streams/glob_wrapper.c b/main/streams/glob_wrapper.c index 9a39355ce..7b568501e 100755 --- a/main/streams/glob_wrapper.c +++ b/main/streams/glob_wrapper.c @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: glob_wrapper.c 321634 2012-01-01 13:15:04Z felipe $ */ +/* $Id$ */ #include "php.h" #include "php_streams_int.h" diff --git a/main/streams/memory.c b/main/streams/memory.c index 41ce727ac..9e0fae6d1 100644 --- a/main/streams/memory.c +++ b/main/streams/memory.c @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: memory.c 321634 2012-01-01 13:15:04Z felipe $ */ +/* $Id$ */ #define _GNU_SOURCE #include "php.h" diff --git a/main/streams/mmap.c b/main/streams/mmap.c index 58aa06f9f..1344d62f6 100644 --- a/main/streams/mmap.c +++ b/main/streams/mmap.c @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: mmap.c 321634 2012-01-01 13:15:04Z felipe $ */ +/* $Id$ */ /* Memory Mapping interface for streams */ #include "php.h" diff --git a/main/streams/php_stream_context.h b/main/streams/php_stream_context.h index b65083b8c..5767b74d2 100644 --- a/main/streams/php_stream_context.h +++ b/main/streams/php_stream_context.h @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_stream_context.h 321634 2012-01-01 13:15:04Z felipe $ */ +/* $Id$ */ /* Stream context and status notification related definitions */ diff --git a/main/streams/php_stream_filter_api.h b/main/streams/php_stream_filter_api.h index 21bdda4b3..5895e71cd 100644 --- a/main/streams/php_stream_filter_api.h +++ b/main/streams/php_stream_filter_api.h @@ -19,7 +19,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_stream_filter_api.h 321634 2012-01-01 13:15:04Z felipe $ */ +/* $Id$ */ /* The filter API works on the principle of "Bucket-Brigades". This is * partially inspired by the Apache 2 method of doing things, although diff --git a/main/streams/php_stream_glob_wrapper.h b/main/streams/php_stream_glob_wrapper.h index 18178286b..c584ff8f8 100755 --- a/main/streams/php_stream_glob_wrapper.h +++ b/main/streams/php_stream_glob_wrapper.h @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_stream_glob_wrapper.h 321634 2012-01-01 13:15:04Z felipe $ */ +/* $Id$ */ PHPAPI extern php_stream_wrapper php_glob_stream_wrapper; PHPAPI extern php_stream_ops php_glob_stream_ops; diff --git a/main/streams/php_stream_mmap.h b/main/streams/php_stream_mmap.h index 6d9ee869a..243b776b1 100644 --- a/main/streams/php_stream_mmap.h +++ b/main/streams/php_stream_mmap.h @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_stream_mmap.h 321634 2012-01-01 13:15:04Z felipe $ */ +/* $Id$ */ /* Memory Mapping interface for streams. * The intention is to provide a uniform interface over the most common diff --git a/main/streams/php_stream_plain_wrapper.h b/main/streams/php_stream_plain_wrapper.h index 2074f5b22..a6a1ed8ad 100644 --- a/main/streams/php_stream_plain_wrapper.h +++ b/main/streams/php_stream_plain_wrapper.h @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_stream_plain_wrapper.h 321634 2012-01-01 13:15:04Z felipe $ */ +/* $Id$ */ /* definitions for the plain files wrapper */ diff --git a/main/streams/php_stream_transport.h b/main/streams/php_stream_transport.h index 6d79c97a4..41585198b 100644 --- a/main/streams/php_stream_transport.h +++ b/main/streams/php_stream_transport.h @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_stream_transport.h 321634 2012-01-01 13:15:04Z felipe $ */ +/* $Id$ */ #ifdef PHP_WIN32 #include "config.w32.h" #include <Ws2tcpip.h> diff --git a/main/streams/php_stream_userspace.h b/main/streams/php_stream_userspace.h index ff54d08db..33d2a7c83 100644 --- a/main/streams/php_stream_userspace.h +++ b/main/streams/php_stream_userspace.h @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_stream_userspace.h 321634 2012-01-01 13:15:04Z felipe $ */ +/* $Id$ */ /* for user-space streams */ diff --git a/main/streams/php_streams_int.h b/main/streams/php_streams_int.h index cd58a0701..1c1c00c4c 100644 --- a/main/streams/php_streams_int.h +++ b/main/streams/php_streams_int.h @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_streams_int.h 321634 2012-01-01 13:15:04Z felipe $ */ +/* $Id$ */ #if ZEND_DEBUG diff --git a/main/streams/plain_wrapper.c b/main/streams/plain_wrapper.c index 0bc83b2f8..77e411377 100644 --- a/main/streams/plain_wrapper.c +++ b/main/streams/plain_wrapper.c @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: plain_wrapper.c 321634 2012-01-01 13:15:04Z felipe $ */ +/* $Id$ */ #include "php.h" #include "php_globals.h" diff --git a/main/streams/streams.c b/main/streams/streams.c index 56da3072e..89fa3640f 100755 --- a/main/streams/streams.c +++ b/main/streams/streams.c @@ -19,7 +19,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: streams.c 321634 2012-01-01 13:15:04Z felipe $ */ +/* $Id$ */ #define _GNU_SOURCE #include "php.h" @@ -157,20 +157,35 @@ PHPAPI int php_stream_from_persistent_id(const char *persistent_id, php_stream * /* }}} */ +static zend_llist *php_get_wrapper_errors_list(php_stream_wrapper *wrapper TSRMLS_DC) +{ + zend_llist *list = NULL; + if (!FG(wrapper_errors)) { + return NULL; + } else { + zend_hash_find(FG(wrapper_errors), (const char*)&wrapper, + sizeof wrapper, (void**)&list); + return list; + } +} + /* {{{ wrapper error reporting */ void php_stream_display_wrapper_errors(php_stream_wrapper *wrapper, const char *path, const char *caption TSRMLS_DC) { char *tmp = estrdup(path); char *msg; int free_msg = 0; - php_stream_wrapper orig_wrapper; if (wrapper) { - if (wrapper->err_count > 0) { - int i; - size_t l; + zend_llist *err_list = php_get_wrapper_errors_list(wrapper TSRMLS_CC); + if (err_list) { + size_t l = 0; int brlen; - char *br; + int i; + int count = zend_llist_count(err_list); + const char *br; + const char **err_buf_p; + zend_llist_position pos; if (PG(html_errors)) { brlen = 7; @@ -180,17 +195,21 @@ void php_stream_display_wrapper_errors(php_stream_wrapper *wrapper, const char * br = "\n"; } - for (i = 0, l = 0; i < wrapper->err_count; i++) { - l += strlen(wrapper->err_stack[i]); - if (i < wrapper->err_count - 1) { + for (err_buf_p = zend_llist_get_first_ex(err_list, &pos), i = 0; + err_buf_p; + err_buf_p = zend_llist_get_next_ex(err_list, &pos), i++) { + l += strlen(*err_buf_p); + if (i < count - 1) { l += brlen; } } msg = emalloc(l + 1); msg[0] = '\0'; - for (i = 0; i < wrapper->err_count; i++) { - strcat(msg, wrapper->err_stack[i]); - if (i < wrapper->err_count - 1) { + for (err_buf_p = zend_llist_get_first_ex(err_list, &pos), i = 0; + err_buf_p; + err_buf_p = zend_llist_get_next_ex(err_list, &pos), i++) { + strcat(msg, *err_buf_p); + if (i < count - 1) { strcat(msg, br); } } @@ -198,7 +217,7 @@ void php_stream_display_wrapper_errors(php_stream_wrapper *wrapper, const char * free_msg = 1; } else { if (wrapper == &php_plain_files_wrapper) { - msg = strerror(errno); + msg = strerror(errno); /* TODO: not ts on linux */ } else { msg = "operation failed"; } @@ -208,16 +227,7 @@ void php_stream_display_wrapper_errors(php_stream_wrapper *wrapper, const char * } php_strip_url_passwd(tmp); - if (wrapper) { - /* see bug #52935 */ - orig_wrapper = *wrapper; - wrapper->err_stack = NULL; - wrapper->err_count = 0; - } php_error_docref1(NULL TSRMLS_CC, tmp, E_WARNING, "%s: %s", caption, msg); - if (wrapper) { - *wrapper = orig_wrapper; - } efree(tmp); if (free_msg) { efree(msg); @@ -226,21 +236,16 @@ void php_stream_display_wrapper_errors(php_stream_wrapper *wrapper, const char * void php_stream_tidy_wrapper_error_log(php_stream_wrapper *wrapper TSRMLS_DC) { - if (wrapper) { - /* tidy up the error stack */ - int i; - - for (i = 0; i < wrapper->err_count; i++) { - efree(wrapper->err_stack[i]); - } - if (wrapper->err_stack) { - efree(wrapper->err_stack); - } - wrapper->err_stack = NULL; - wrapper->err_count = 0; + if (wrapper && FG(wrapper_errors)) { + zend_hash_del(FG(wrapper_errors), (const char*)&wrapper, sizeof wrapper); } } +static void wrapper_error_dtor(void *error) +{ + efree(*(char**)error); +} + PHPAPI void php_stream_wrapper_log_error(php_stream_wrapper *wrapper, int options TSRMLS_DC, const char *fmt, ...) { va_list args; @@ -254,11 +259,25 @@ PHPAPI void php_stream_wrapper_log_error(php_stream_wrapper *wrapper, int option php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", buffer); efree(buffer); } else { - /* append to stack */ - wrapper->err_stack = erealloc(wrapper->err_stack, (wrapper->err_count + 1) * sizeof(char *)); - if (wrapper->err_stack) { - wrapper->err_stack[wrapper->err_count++] = buffer; + zend_llist *list = NULL; + if (!FG(wrapper_errors)) { + ALLOC_HASHTABLE(FG(wrapper_errors)); + zend_hash_init(FG(wrapper_errors), 8, NULL, + (dtor_func_t)zend_llist_destroy, 0); + } else { + zend_hash_find(FG(wrapper_errors), (const char*)&wrapper, + sizeof wrapper, (void**)&list); } + + if (!list) { + zend_llist new_list; + zend_llist_init(&new_list, sizeof buffer, wrapper_error_dtor, 0); + zend_hash_update(FG(wrapper_errors), (const char*)&wrapper, + sizeof wrapper, &new_list, sizeof new_list, (void**)&list); + } + + /* append to linked list */ + zend_llist_add_element(list, &buffer); } } @@ -366,7 +385,14 @@ PHPAPI int _php_stream_free(php_stream *stream, int close_options TSRMLS_DC) /* int ret = 1; int preserve_handle = close_options & PHP_STREAM_FREE_PRESERVE_HANDLE ? 1 : 0; int release_cast = 1; - php_stream_context *context = stream->context; + php_stream_context *context = NULL; + + /* 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 = stream->context; + } if (stream->flags & PHP_STREAM_FLAG_NO_CLOSE) { preserve_handle = 1; @@ -445,8 +471,8 @@ fprintf(stderr, "stream_free: %s:%p[%s] preserve_handle=%d release_cast=%d remov } /* Remove stream from any context link list */ - if (stream->context && stream->context->links) { - php_stream_context_del_link(stream->context, stream); + if (context && context->links) { + php_stream_context_del_link(context, stream); } if (close_options & PHP_STREAM_FREE_CALL_DTOR) { @@ -970,77 +996,111 @@ PHPAPI char *_php_stream_get_line(php_stream *stream, char *buf, size_t maxlen, return bufstart; } +#define STREAM_BUFFERED_AMOUNT(stream) \ + ((size_t)(((stream)->writepos) - (stream)->readpos)) + +static char *_php_stream_search_delim(php_stream *stream, + size_t maxlen, + size_t skiplen, + char *delim, /* non-empty! */ + size_t delim_len TSRMLS_DC) +{ + size_t seek_len; + + /* set the maximum number of bytes we're allowed to read from buffer */ + seek_len = MIN(STREAM_BUFFERED_AMOUNT(stream), maxlen); + if (seek_len <= skiplen) { + return NULL; + } + + if (delim_len == 1) { + return memchr(&stream->readbuf[stream->readpos + skiplen], + delim[0], seek_len - skiplen); + } else { + return php_memnstr((char*)&stream->readbuf[stream->readpos + skiplen], + delim, delim_len, + (char*)&stream->readbuf[stream->readpos + seek_len]); + } +} + PHPAPI char *php_stream_get_record(php_stream *stream, size_t maxlen, size_t *returned_len, char *delim, size_t delim_len TSRMLS_DC) { - char *e, *buf; - size_t toread, len; - int skip = 0; + char *ret_buf, /* returned buffer */ + *found_delim = NULL; + size_t buffered_len, + tent_ret_len; /* tentative returned length*/ + int has_delim = delim_len > 0 && delim[0] != '\0'; - len = stream->writepos - stream->readpos; + if (maxlen == 0) { + return NULL; + } + + if (has_delim) { + found_delim = _php_stream_search_delim( + stream, maxlen, 0, delim, delim_len TSRMLS_CC); + } - /* make sure the stream read buffer has maxlen bytes */ - while (len < maxlen) { + buffered_len = STREAM_BUFFERED_AMOUNT(stream); + /* try to read up to maxlen length bytes while we don't find the delim */ + while (!found_delim && buffered_len < maxlen) { + size_t just_read, + to_read_now; - size_t just_read; - toread = MIN(maxlen - len, stream->chunk_size); + to_read_now = MIN(maxlen - buffered_len, stream->chunk_size); - php_stream_fill_read_buffer(stream, len + toread TSRMLS_CC); + php_stream_fill_read_buffer(stream, buffered_len + to_read_now TSRMLS_CC); - just_read = (stream->writepos - stream->readpos) - len; - len += just_read; + just_read = STREAM_BUFFERED_AMOUNT(stream) - buffered_len; /* Assume the stream is temporarily or permanently out of data */ if (just_read == 0) { break; } - } - - if (delim_len == 0 || !delim) { - toread = maxlen; - } else { - size_t seek_len; - - /* set the maximum number of bytes we're allowed to read from buffer */ - seek_len = stream->writepos - stream->readpos; - if (seek_len > maxlen) { - seek_len = maxlen; - } - if (delim_len == 1) { - e = memchr(stream->readbuf + stream->readpos, *delim, seek_len); - } else { - e = php_memnstr(stream->readbuf + stream->readpos, delim, delim_len, (stream->readbuf + stream->readpos + seek_len)); - } - - if (!e) { - /* return with error if the delimiter string was not found, we - * could not completely fill the read buffer with maxlen bytes - * and we don't know we've reached end of file. Added with - * non-blocking streams in mind, where this situation is frequent */ - if (seek_len < maxlen && !stream->eof) { - return NULL; + if (has_delim) { + /* search for delimiter, but skip buffered_len (the number of bytes + * buffered before this loop iteration), as they have already been + * searched for the delimiter */ + found_delim = _php_stream_search_delim( + stream, maxlen, buffered_len, delim, delim_len TSRMLS_CC); + if (found_delim) { + break; } - toread = maxlen; - } else { - toread = e - (char *) stream->readbuf - stream->readpos; - /* we found the delimiter, so advance the read pointer past it */ - skip = 1; } + buffered_len += just_read; } - if (toread > maxlen && maxlen > 0) { - toread = maxlen; + if (has_delim && found_delim) { + tent_ret_len = found_delim - (char*)&stream->readbuf[stream->readpos]; + } else if (!has_delim && STREAM_BUFFERED_AMOUNT(stream) >= maxlen) { + tent_ret_len = maxlen; + } else { + /* return with error if the delimiter string (if any) was not found, we + * could not completely fill the read buffer with maxlen bytes and we + * don't know we've reached end of file. Added with non-blocking streams + * in mind, where this situation is frequent */ + if (STREAM_BUFFERED_AMOUNT(stream) < maxlen && !stream->eof) { + return NULL; + } else if (STREAM_BUFFERED_AMOUNT(stream) == 0 && stream->eof) { + /* refuse to return an empty string just because by accident + * we knew of EOF in a read that returned no data */ + return NULL; + } else { + tent_ret_len = MIN(STREAM_BUFFERED_AMOUNT(stream), maxlen); + } } - buf = emalloc(toread + 1); - *returned_len = php_stream_read(stream, buf, toread); + ret_buf = emalloc(tent_ret_len + 1); + /* php_stream_read will not call ops->read here because the necessary + * data is guaranteedly buffered */ + *returned_len = php_stream_read(stream, ret_buf, tent_ret_len); - if (skip) { + if (found_delim) { stream->readpos += delim_len; stream->position += delim_len; } - buf[*returned_len] = '\0'; - return buf; + ret_buf[*returned_len] = '\0'; + return ret_buf; } /* Writes a buffer directly to a stream, using multiple of the chunk size */ @@ -1563,6 +1623,12 @@ void php_shutdown_stream_hashes(TSRMLS_D) efree(FG(stream_filters)); FG(stream_filters) = NULL; } + + if (FG(wrapper_errors)) { + zend_hash_destroy(FG(wrapper_errors)); + efree(FG(wrapper_errors)); + FG(wrapper_errors) = NULL; + } } int php_init_stream_wrappers(int module_number TSRMLS_DC) diff --git a/main/streams/transports.c b/main/streams/transports.c index 9431f6a39..8de9b9b9a 100644 --- a/main/streams/transports.c +++ b/main/streams/transports.c @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: transports.c 321634 2012-01-01 13:15:04Z felipe $ */ +/* $Id$ */ #include "php.h" #include "php_streams_int.h" diff --git a/main/streams/userspace.c b/main/streams/userspace.c index 01c68bf73..96a5195ed 100644 --- a/main/streams/userspace.c +++ b/main/streams/userspace.c @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: userspace.c 321634 2012-01-01 13:15:04Z felipe $ */ +/* $Id$ */ #include "php.h" #include "php_globals.h" diff --git a/main/streams/xp_socket.c b/main/streams/xp_socket.c index ecfc05762..7c3a55310 100644 --- a/main/streams/xp_socket.c +++ b/main/streams/xp_socket.c @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: xp_socket.c 321634 2012-01-01 13:15:04Z felipe $ */ +/* $Id$ */ #include "php.h" #include "ext/standard/file.h" @@ -510,6 +510,9 @@ static inline int parse_unix_address(php_stream_xport_param *xparam, struct sock * BUT, to get into this branch of code, the name is too long, * so we don't care. */ xparam->inputs.namelen = sizeof(unix_addr->sun_path) - 1; + php_error_docref(NULL TSRMLS_CC, E_NOTICE, + "socket path exceeded the maximum allowed length of %lu bytes " + "and was truncated", (unsigned long)sizeof(unix_addr->sun_path)); } memcpy(unix_addr->sun_path, xparam->inputs.name, xparam->inputs.namelen); diff --git a/main/strlcat.c b/main/strlcat.c index 5ea31a627..db8f26c4a 100644 --- a/main/strlcat.c +++ b/main/strlcat.c @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: strlcat.c 321634 2012-01-01 13:15:04Z felipe $ */ +/* $Id$ */ #include "php.h" diff --git a/main/strlcpy.c b/main/strlcpy.c index 40fdf2ed2..1e40df046 100644 --- a/main/strlcpy.c +++ b/main/strlcpy.c @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: strlcpy.c 321634 2012-01-01 13:15:04Z felipe $ */ +/* $Id$ */ #include "php.h" diff --git a/main/win32_internal_function_disabled.h b/main/win32_internal_function_disabled.h index f10c0eaab..822c68871 100644 --- a/main/win32_internal_function_disabled.h +++ b/main/win32_internal_function_disabled.h @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: win32_internal_function_disabled.h 321634 2012-01-01 13:15:04Z felipe $ */ +/* $Id$ */ /* 5 means the min version is 5 (XP/2000), 6 (2k8/vista), etc. */ diff --git a/main/win95nt.h b/main/win95nt.h index 13b3358c9..c98fd0f22 100644 --- a/main/win95nt.h +++ b/main/win95nt.h @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: win95nt.h 321634 2012-01-01 13:15:04Z felipe $ */ +/* $Id$ */ /* Defines and types for Windows 95/NT */ #define HAVE_DECLARED_TIMEZONE |