diff options
| author | Ondřej Surý <ondrej@sury.org> | 2011-08-19 10:22:38 +0200 |
|---|---|---|
| committer | Ondřej Surý <ondrej@sury.org> | 2011-08-19 10:22:38 +0200 |
| commit | f452a2b3e4e4279b27594a8ddb66525442d59227 (patch) | |
| tree | d05cb62c5515ada33076d3cc3e49b664733a478c /main | |
| parent | 038ba12e8724d537040e88ec794354b0c063f0a6 (diff) | |
| download | php-upstream/5.3.7.tar.gz | |
Imported Upstream version 5.3.7upstream/5.3.7
Diffstat (limited to 'main')
| -rw-r--r-- | main/build-defs.h.in | 3 | ||||
| -rw-r--r-- | main/fopen_wrappers.c | 7 | ||||
| -rw-r--r-- | main/main.c | 20 | ||||
| -rw-r--r-- | main/network.c | 6 | ||||
| -rw-r--r-- | main/php.h | 3 | ||||
| -rw-r--r-- | main/php_config.h.in | 17 | ||||
| -rw-r--r-- | main/php_ini.c | 6 | ||||
| -rw-r--r-- | main/php_open_temporary_file.c | 12 | ||||
| -rw-r--r-- | main/php_version.h | 6 | ||||
| -rw-r--r-- | main/reentrancy.c | 6 | ||||
| -rw-r--r-- | main/rfc1867.c | 6 | ||||
| -rw-r--r-- | main/snprintf.c | 10 | ||||
| -rw-r--r-- | main/spprintf.c | 10 | ||||
| -rw-r--r-- | main/streams/filter.c | 4 | ||||
| -rw-r--r-- | main/streams/php_stream_context.h | 4 | ||||
| -rw-r--r-- | main/streams/php_stream_filter_api.h | 4 | ||||
| -rwxr-xr-x | main/streams/streams.c | 51 |
17 files changed, 127 insertions, 48 deletions
diff --git a/main/build-defs.h.in b/main/build-defs.h.in index 121536e78..9143a9c25 100644 --- a/main/build-defs.h.in +++ b/main/build-defs.h.in @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: build-defs.h.in 292156 2009-12-15 11:17:47Z jani $ */ +/* $Id: build-defs.h.in 310307 2011-04-18 09:50:32Z bjori $ */ #define CONFIGURE_COMMAND "@CONFIGURE_COMMAND@" #define PHP_ADA_INCLUDE "" @@ -81,6 +81,7 @@ #define PHP_PREFIX "@prefix@" #define PHP_BINDIR "@EXPANDED_BINDIR@" #define PHP_SBINDIR "@EXPANDED_SBINDIR@" +#define PHP_MANDIR "@EXPANDED_MANDIR@" #define PHP_LIBDIR "@EXPANDED_LIBDIR@" #define PHP_DATADIR "@EXPANDED_DATADIR@" #define PHP_SYSCONFDIR "@EXPANDED_SYSCONFDIR@" diff --git a/main/fopen_wrappers.c b/main/fopen_wrappers.c index 6bbb6487e..b7abb8333 100644 --- a/main/fopen_wrappers.c +++ b/main/fopen_wrappers.c @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: fopen_wrappers.c 307563 2011-01-18 22:20:09Z pajoye $ */ +/* $Id: fopen_wrappers.c 314645 2011-08-09 13:04:35Z laruence $ */ /* {{{ includes */ @@ -463,7 +463,8 @@ PHPAPI int php_fopen_primary_script(zend_file_handle *file_handle TSRMLS_DC) #endif if (PG(doc_root) && path_info && (length = strlen(PG(doc_root))) && IS_ABSOLUTE_PATH(PG(doc_root), length)) { - filename = emalloc(length + strlen(path_info) + 2); + int path_len = strlen(path_info); + filename = emalloc(length + path_len + 2); if (filename) { memcpy(filename, PG(doc_root), length); if (!IS_SLASH(filename[length - 1])) { /* length is never 0 */ @@ -472,7 +473,7 @@ PHPAPI int php_fopen_primary_script(zend_file_handle *file_handle TSRMLS_DC) if (IS_SLASH(path_info[0])) { length--; } - strcpy(filename + length, path_info); + strncpy(filename + length, path_info, path_len + 1); } } else { filename = SG(request_info).path_translated; diff --git a/main/main.c b/main/main.c index cc76f8003..3ea3048d2 100644 --- a/main/main.c +++ b/main/main.c @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: main.c 308150 2011-02-08 21:40:51Z cataphract $ */ +/* $Id: main.c 312201 2011-06-16 01:31:10Z pajoye $ */ /* {{{ includes */ @@ -32,6 +32,7 @@ #include "win32/time.h" #include "win32/signal.h" #include "win32/php_win32_globals.h" +#include "win32/winutil.h" #include <process.h> #elif defined(NETWARE) #include <sys/timeval.h> @@ -399,6 +400,8 @@ static PHP_INI_MH(OnChangeMailForceExtra) } /* }}} */ +/* defined in browscap.c */ +PHP_INI_MH(OnChangeBrowscap); /* Need to convert to strings and make use of: * PHP_SAFE_MODE @@ -510,7 +513,7 @@ PHP_INI_BEGIN() PHP_INI_ENTRY("smtp_port", "25", PHP_INI_ALL, NULL) STD_PHP_INI_BOOLEAN("mail.add_x_header", "0", PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateBool, mail_x_header, php_core_globals, core_globals) STD_PHP_INI_ENTRY("mail.log", NULL, PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateMailLog, mail_log, php_core_globals, core_globals) - PHP_INI_ENTRY("browscap", NULL, PHP_INI_SYSTEM, NULL) + PHP_INI_ENTRY("browscap", NULL, PHP_INI_SYSTEM, OnChangeBrowscap) PHP_INI_ENTRY("memory_limit", "128M", PHP_INI_ALL, OnChangeMemoryLimit) PHP_INI_ENTRY("precision", "14", PHP_INI_ALL, OnSetPrecision) PHP_INI_ENTRY("sendmail_from", NULL, PHP_INI_ALL, NULL) @@ -908,9 +911,11 @@ static void php_error_cb(int type, const char *error_filename, const uint error_ if (display) { if (PG(last_error_message)) { free(PG(last_error_message)); + PG(last_error_message) = NULL; } if (PG(last_error_file)) { free(PG(last_error_file)); + PG(last_error_file) = NULL; } if (!error_filename) { error_filename = "Unknown"; @@ -1825,6 +1830,10 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod tsrm_ls = ts_resource(0); #endif +#ifdef PHP_WIN32 + php_win32_init_rng_lock(); +#endif + module_shutdown = 0; module_startup = 1; sapi_initialize_empty_request(TSRMLS_C); @@ -1936,6 +1945,9 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod REGISTER_MAIN_STRINGL_CONSTANT("PHP_EXTENSION_DIR", PHP_EXTENSION_DIR, sizeof(PHP_EXTENSION_DIR)-1, CONST_PERSISTENT | CONST_CS); REGISTER_MAIN_STRINGL_CONSTANT("PHP_PREFIX", PHP_PREFIX, sizeof(PHP_PREFIX)-1, CONST_PERSISTENT | CONST_CS); REGISTER_MAIN_STRINGL_CONSTANT("PHP_BINDIR", PHP_BINDIR, sizeof(PHP_BINDIR)-1, CONST_PERSISTENT | CONST_CS); +#ifndef PHP_WIN32 + REGISTER_MAIN_STRINGL_CONSTANT("PHP_MANDIR", PHP_MANDIR, sizeof(PHP_MANDIR)-1, CONST_PERSISTENT | CONST_CS); +#endif REGISTER_MAIN_STRINGL_CONSTANT("PHP_LIBDIR", PHP_LIBDIR, sizeof(PHP_LIBDIR)-1, CONST_PERSISTENT | CONST_CS); REGISTER_MAIN_STRINGL_CONSTANT("PHP_DATADIR", PHP_DATADIR, sizeof(PHP_DATADIR)-1, CONST_PERSISTENT | CONST_CS); REGISTER_MAIN_STRINGL_CONSTANT("PHP_SYSCONFDIR", PHP_SYSCONFDIR, sizeof(PHP_SYSCONFDIR)-1, CONST_PERSISTENT | CONST_CS); @@ -2141,6 +2153,10 @@ void php_module_shutdown(TSRMLS_D) WSACleanup(); #endif +#ifdef PHP_WIN32 + php_win32_free_rng_lock(); +#endif + sapi_flush(TSRMLS_C); zend_shutdown(TSRMLS_C); diff --git a/main/network.c b/main/network.c index cf464748f..2aa9e49e3 100644 --- a/main/network.c +++ b/main/network.c @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: network.c 307922 2011-02-01 18:10:35Z cataphract $ */ +/* $Id: network.c 309579 2011-03-23 00:51:22Z cataphract $ */ /*#define DEBUG_MAIN_NETWORK 1*/ @@ -1095,7 +1095,9 @@ PHPAPI int php_set_sock_blocking(int socketd, int block TSRMLS_DC) } else { flags &= ~myflag; } - fcntl(socketd, F_SETFL, flags); + if (fcntl(socketd, F_SETFL, flags) == -1) { + ret = FAILURE; + } #endif return ret; } diff --git a/main/php.h b/main/php.h index e19c16bab..8f22ccc22 100644 --- a/main/php.h +++ b/main/php.h @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php.h 306939 2011-01-01 02:19:59Z felipe $ */ +/* $Id: php.h 313662 2011-07-25 11:30:53Z felipe $ */ #ifndef PHP_H #define PHP_H @@ -351,6 +351,7 @@ END_EXTERN_C() #define PHP_MALIAS ZEND_MALIAS #define PHP_ABSTRACT_ME ZEND_ABSTRACT_ME #define PHP_ME_MAPPING ZEND_ME_MAPPING +#define PHP_FE_END ZEND_FE_END #define PHP_MODULE_STARTUP_N ZEND_MODULE_STARTUP_N #define PHP_MODULE_SHUTDOWN_N ZEND_MODULE_SHUTDOWN_N diff --git a/main/php_config.h.in b/main/php_config.h.in index 68d3290ce..9445fcf35 100644 --- a/main/php_config.h.in +++ b/main/php_config.h.in @@ -983,6 +983,12 @@ /* do we have SO_LISTENQxxx? */ #undef HAVE_LQ_SO_LISTENQ +/* do we have sysconf? */ +#undef HAVE_SYSCONF + +/* do we have times? */ +#undef HAVE_TIMES + /* fpm user name */ #undef PHP_FPM_USER @@ -1292,6 +1298,9 @@ /* OpenSSL 0.9.7 or later */ #undef HAVE_DSA_DEFAULT_METHOD +/* OpenSSL 0.9.7 or later */ +#undef HAVE_DSA_DEFAULT_METHOD + /* */ #undef HAVE_OPENSSL_EXT @@ -2804,15 +2813,15 @@ /* Whether to build zip as dynamic module */ #undef COMPILE_DL_ZIP -/* Whether to build mysqlnd as dynamic module */ -#undef COMPILE_DL_MYSQLND - /* Enable compressed protocol support */ -#undef MYSQLND_COMPRESSION_ENABLED +#undef MYSQLND_COMPRESSION_WANTED /* Enable SSL support */ #undef MYSQLND_SSL_SUPPORTED +/* Whether to build mysqlnd as dynamic module */ +#undef COMPILE_DL_MYSQLND + /* Define if int32_t type is present. */ #undef HAVE_INT32_T diff --git a/main/php_ini.c b/main/php_ini.c index c975b9dd8..cd47ea549 100644 --- a/main/php_ini.c +++ b/main/php_ini.c @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_ini.c 307587 2011-01-19 14:21:46Z pajoye $ */ +/* $Id: php_ini.c 314383 2011-08-06 21:10:29Z rasmus $ */ #include "php.h" #include "ext/standard/info.h" @@ -486,7 +486,7 @@ int php_init_config(TSRMLS_D) if ((envpath = getenv("PATH")) != NULL) { char *search_dir, search_path[MAXPATHLEN]; - char *last; + char *last = NULL; path = estrdup(envpath); search_dir = php_strtok_r(path, ":", &last); @@ -832,7 +832,7 @@ PHPAPI void php_ini_activate_per_dir_config(char *path, uint path_len TSRMLS_DC) #if PHP_WIN32 memcpy(path_bak, path, path_len); - path_bak[path_len - 1] = 0; + path_bak[path_len] = 0; TRANSLATE_SLASHES_LOWER(path_bak); path = path_bak; #endif diff --git a/main/php_open_temporary_file.c b/main/php_open_temporary_file.c index 27959b381..0882e5e15 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 307375 2011-01-11 12:57:19Z iliaa $ */ +/* $Id: php_open_temporary_file.c 309792 2011-03-28 16:43:49Z pajoye $ */ #include "php.h" @@ -204,9 +204,13 @@ PHPAPI const char* php_get_temporary_directory(void) */ { char sTemp[MAX_PATH]; - DWORD n = GetTempPath(sizeof(sTemp),sTemp); - assert(0 < n); /* should *never* fail! */ - temporary_directory = strdup(sTemp); + DWORD len = GetTempPath(sizeof(sTemp),sTemp); + assert(0 < len); /* should *never* fail! */ + if (sTemp[len - 1] == DEFAULT_SLASH) { + temporary_directory = zend_strndup(sTemp, len - 1); + } else { + temporary_directory = zend_strndup(sTemp, len); + } return temporary_directory; } #else diff --git a/main/php_version.h b/main/php_version.h index 00bd6fad2..65ae37fde 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 3 -#define PHP_RELEASE_VERSION 6 +#define PHP_RELEASE_VERSION 7 #define PHP_EXTRA_VERSION "" -#define PHP_VERSION "5.3.6" -#define PHP_VERSION_ID 50306 +#define PHP_VERSION "5.3.7" +#define PHP_VERSION_ID 50307 diff --git a/main/reentrancy.c b/main/reentrancy.c index 4710f13d9..afa51be6b 100644 --- a/main/reentrancy.c +++ b/main/reentrancy.c @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: reentrancy.c 306939 2011-01-01 02:19:59Z felipe $ */ +/* $Id: reentrancy.c 313144 2011-07-11 17:01:23Z iliaa $ */ #include <sys/types.h> #include <string.h> @@ -60,14 +60,14 @@ static MUTEX_T reentrant_locks[NUMBER_OF_LOCKS]; PHPAPI char *php_ctime_r(const time_t *clock, char *buf) { - if (ctime_r(clock, buf, 26) == buf) + if (ctime_r(clock, buf) == buf) return (buf); return (NULL); } PHPAPI char *php_asctime_r(const struct tm *tm, char *buf) { - if (asctime_r(tm, buf, 26) == buf) + if (asctime_r(tm, buf) == buf) return (buf); return (NULL); } diff --git a/main/rfc1867.c b/main/rfc1867.c index 3e1161b41..a63028d9f 100644 --- a/main/rfc1867.c +++ b/main/rfc1867.c @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: rfc1867.c 307583 2011-01-19 13:09:05Z iliaa $ */ +/* $Id: rfc1867.c 312103 2011-06-12 15:14:18Z felipe $ */ /* * This product includes software developed by the Apache Group @@ -1223,7 +1223,7 @@ filedone: #endif if (!is_anonymous) { - if (s && s > filename) { + if (s && s >= filename) { safe_php_register_variable(lbuf, s+1, strlen(s+1), NULL, 0 TSRMLS_CC); } else { safe_php_register_variable(lbuf, filename, strlen(filename), NULL, 0 TSRMLS_CC); @@ -1236,7 +1236,7 @@ filedone: } else { snprintf(lbuf, llen, "%s[name]", param); } - if (s && s > filename) { + if (s && s >= filename) { register_http_post_files_variable(lbuf, s+1, http_post_files, 0 TSRMLS_CC); } else { register_http_post_files_variable(lbuf, filename, http_post_files, 0 TSRMLS_CC); diff --git a/main/snprintf.c b/main/snprintf.c index 47d12155c..bd5dc939c 100644 --- a/main/snprintf.c +++ b/main/snprintf.c @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: snprintf.c 308525 2011-02-21 06:53:24Z cataphract $ */ +/* $Id: snprintf.c 314582 2011-08-09 02:42:25Z pierrick $ */ #include "php.h" @@ -497,8 +497,11 @@ char * ap_php_conv_p2(register u_wide_int num, register int nbits, char format, * NUM_BUF_SIZE is the size of the buffer used for arithmetic conversions * * XXX: this is a magic number; do not decrease it + * Emax = 1023 + * NDIG = 320 + * NUM_BUF_SIZE >= strlen("-") + Emax + strlrn(".") + NDIG + strlen("E+1023") + 1; */ -#define NUM_BUF_SIZE 512 +#define NUM_BUF_SIZE 2048 /* @@ -584,7 +587,6 @@ static int format_converter(register buffy * odp, const char *fmt, va_list ap) / int i; char *s = NULL; - char *q; int s_len, free_zcopy; zval *zvp, zcopy; @@ -1068,7 +1070,7 @@ static int format_converter(register buffy * odp, const char *fmt, va_list ap) / s_len = strlen(s); - if (alternate_form && (q = strchr(s, '.')) == NULL) { + if (alternate_form && (strchr(s, '.')) == NULL) { s[s_len++] = '.'; } break; diff --git a/main/spprintf.c b/main/spprintf.c index 6b15216aa..fef5b63f2 100644 --- a/main/spprintf.c +++ b/main/spprintf.c @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: spprintf.c 308525 2011-02-21 06:53:24Z cataphract $ */ +/* $Id: spprintf.c 314581 2011-08-09 02:37:02Z pierrick $ */ /* This is the spprintf implementation. * It has emerged from apache snprintf. See original header: @@ -119,8 +119,11 @@ * NUM_BUF_SIZE is the size of the buffer used for arithmetic conversions * * XXX: this is a magic number; do not decrease it + * Emax = 1023 + * NDIG = 320 + * NUM_BUF_SIZE >= strlen("-") + Emax + strlrn(".") + NDIG + strlen("E+1023") + 1; */ -#define NUM_BUF_SIZE 512 +#define NUM_BUF_SIZE 2048 /* * The INS_CHAR macro inserts a character in the buffer. @@ -195,7 +198,6 @@ static size_t strnlen(const char *s, size_t maxlen) { static void xbuf_format_converter(smart_str *xbuf, const char *fmt, va_list ap) /* {{{ */ { char *s = NULL; - char *q; int s_len, free_zcopy; zval *zvp, zcopy; @@ -676,7 +678,7 @@ static void xbuf_format_converter(smart_str *xbuf, const char *fmt, va_list ap) s_len = strlen(s); - if (alternate_form && (q = strchr(s, '.')) == NULL) + if (alternate_form && (strchr(s, '.')) == NULL) s[s_len++] = '.'; break; diff --git a/main/streams/filter.c b/main/streams/filter.c index f2760119d..90cebf659 100644 --- a/main/streams/filter.c +++ b/main/streams/filter.c @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: filter.c 307922 2011-02-01 18:10:35Z cataphract $ */ +/* $Id: filter.c 314641 2011-08-09 12:16:58Z laruence $ */ #include "php.h" #include "php_globals.h" @@ -270,7 +270,7 @@ PHPAPI php_stream_filter *php_stream_filter_create(const char *filtername, zval period = wildname + (period - filtername); while (period && !filter) { *period = '\0'; - strcat(wildname, ".*"); + strncat(wildname, ".*", 2); if (SUCCESS == zend_hash_find(filter_hash, wildname, strlen(wildname) + 1, (void**)&factory)) { filter = factory->create_filter(filtername, filterparams, persistent TSRMLS_CC); } diff --git a/main/streams/php_stream_context.h b/main/streams/php_stream_context.h index b98436051..10f5a7906 100644 --- a/main/streams/php_stream_context.h +++ b/main/streams/php_stream_context.h @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_stream_context.h 306939 2011-01-01 02:19:59Z felipe $ */ +/* $Id: php_stream_context.h 309927 2011-04-03 21:46:52Z pierrick $ */ /* Stream context and status notification related definitions */ @@ -31,7 +31,7 @@ typedef void (*php_stream_notification_func)(php_stream_context *context, /* Attempt to fetch context from the zval passed, If no context was passed, use the default context - The the default context has not yet been created, do it now. */ + The default context has not yet been created, do it now. */ #define php_stream_context_from_zval(zcontext, nocontext) ( \ (zcontext) ? zend_fetch_resource(&(zcontext) TSRMLS_CC, -1, "Stream-Context", NULL, 1, php_le_stream_context()) : \ (nocontext) ? NULL : \ diff --git a/main/streams/php_stream_filter_api.h b/main/streams/php_stream_filter_api.h index d56fb067c..ef3e73ee3 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 306939 2011-01-01 02:19:59Z felipe $ */ +/* $Id: php_stream_filter_api.h 309927 2011-04-03 21:46:52Z pierrick $ */ /* The filter API works on the principle of "Bucket-Brigades". This is * partially inspired by the Apache 2 method of doing things, although @@ -27,7 +27,7 @@ * * Each stream can have a chain of filters for reading and another for writing. * - * When data is written to the stream, is is placed into a bucket and placed at + * When data is written to the stream, it is placed into a bucket and placed at * the start of the input brigade. * * The first filter in the chain is invoked on the brigade and (depending on diff --git a/main/streams/streams.c b/main/streams/streams.c index a88400c83..be2745cb8 100755 --- a/main/streams/streams.c +++ b/main/streams/streams.c @@ -19,7 +19,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: streams.c 307922 2011-02-01 18:10:35Z cataphract $ */ +/* $Id: streams.c 312937 2011-07-05 16:09:06Z cataphract $ */ #define _GNU_SOURCE #include "php.h" @@ -112,9 +112,32 @@ PHPAPI int php_stream_from_persistent_id(const char *persistent_id, php_stream * if (zend_hash_find(&EG(persistent_list), (char*)persistent_id, strlen(persistent_id)+1, (void*) &le) == SUCCESS) { if (Z_TYPE_P(le) == le_pstream) { if (stream) { + HashPosition pos; + zend_rsrc_list_entry *regentry; + ulong index = -1; /* intentional */ + + /* see if this persistent resource already has been loaded to the + * regular list; allowing the same resource in several entries in the + * regular list causes trouble (see bug #54623) */ + zend_hash_internal_pointer_reset_ex(&EG(regular_list), &pos); + while (zend_hash_get_current_data_ex(&EG(regular_list), + (void **)®entry, &pos) == SUCCESS) { + if (regentry->ptr == le->ptr) { + zend_hash_get_current_key_ex(&EG(regular_list), NULL, NULL, + &index, 0, &pos); + break; + } + zend_hash_move_forward_ex(&EG(regular_list), &pos); + } + *stream = (php_stream*)le->ptr; - le->refcount++; - (*stream)->rsrc_id = ZEND_REGISTER_RESOURCE(NULL, *stream, le_pstream); + if (index == -1) { /* not found in regular list */ + le->refcount++; + (*stream)->rsrc_id = ZEND_REGISTER_RESOURCE(NULL, *stream, le_pstream); + } else { + regentry->refcount++; + (*stream)->rsrc_id = index; + } } return PHP_STREAM_PERSISTENT_SUCCESS; } @@ -131,6 +154,7 @@ void php_stream_display_wrapper_errors(php_stream_wrapper *wrapper, const char * char *tmp = estrdup(path); char *msg; int free_msg = 0; + php_stream_wrapper orig_wrapper; if (wrapper) { if (wrapper->err_count > 0) { @@ -175,7 +199,16 @@ 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); @@ -332,7 +365,12 @@ fprintf(stderr, "stream_free: %s:%p[%s] preserve_handle=%d release_cast=%d remov /* If not called from the resource dtor, remove the stream from the resource list. */ if ((close_options & PHP_STREAM_FREE_RSRC_DTOR) == 0 && remove_rsrc) { - zend_list_delete(stream->rsrc_id); + /* zend_list_delete actually only decreases the refcount; if we're + * releasing the stream, we want to actually delete the resource from + * the resource list, otherwise the resource will point to invalid memory. + * In any case, let's always completely delete it from the resource list, + * not only when PHP_STREAM_FREE_RELEASE_STREAM is set */ + while (zend_list_delete(stream->rsrc_id) == SUCCESS) {} } /* Remove stream from any context link list */ @@ -1156,7 +1194,7 @@ PHPAPI int _php_stream_seek(php_stream *stream, off_t offset, int whence TSRMLS_ } /* emulate forward moving seeks with reads */ - if (whence == SEEK_CUR && offset > 0) { + if (whence == SEEK_CUR && offset >= 0) { char tmp[1024]; size_t didread; while(offset > 0) { @@ -1263,6 +1301,9 @@ PHPAPI size_t _php_stream_copy_to_mem(php_stream *src, char **buf, size_t maxlen ptr = *buf = pemalloc_rel_orig(maxlen + 1, persistent); while ((len < maxlen) && !php_stream_eof(src)) { ret = php_stream_read(src, ptr, maxlen - len); + if (!ret) { + break; + } len += ret; ptr += ret; } |
