diff options
Diffstat (limited to 'main')
| -rw-r--r-- | main/internal_functions_win32.c | 4 | ||||
| -rw-r--r-- | main/main.c | 4 | ||||
| -rw-r--r-- | main/output.c | 1 | ||||
| -rw-r--r-- | main/php_ini.c | 6 | ||||
| -rw-r--r-- | main/php_ini.h | 6 | ||||
| -rw-r--r-- | main/snprintf.c | 17 | ||||
| -rw-r--r-- | main/spprintf.c | 17 | ||||
| -rw-r--r-- | main/streams/memory.c | 20 | ||||
| -rw-r--r-- | main/streams/plain_wrapper.c | 50 |
9 files changed, 72 insertions, 53 deletions
diff --git a/main/internal_functions_win32.c b/main/internal_functions_win32.c index 355013f501..b4718c379f 100644 --- a/main/internal_functions_win32.c +++ b/main/internal_functions_win32.c @@ -29,10 +29,6 @@ #include <stdlib.h> #include <stdio.h> -#ifndef ZEND_ENGINE_2 -#error HEAD does not work with ZendEngine1 anymore -#endif - #include "ext/standard/dl.h" #include "ext/standard/file.h" #include "ext/standard/fsock.h" diff --git a/main/main.c b/main/main.c index 41e84a79f7..b58a643e84 100644 --- a/main/main.c +++ b/main/main.c @@ -1121,8 +1121,8 @@ static void php_error_cb(int type, const char *error_filename, const uint error_ if (!module_initialized || PG(log_errors)) { char *log_buffer; #ifdef PHP_WIN32 - if ((type == E_CORE_ERROR || type == E_CORE_WARNING) && PG(display_startup_errors)) { - MessageBox(NULL, buffer, error_type_str, MB_OK|ZEND_SERVICE_MB_STYLE); + if (type == E_CORE_ERROR || type == E_CORE_WARNING) { + syslog(LOG_ALERT, "PHP %s: %s (%s)", error_type_str, buffer, GetCommandLine()); } #endif spprintf(&log_buffer, 0, "PHP %s: %s in %s on line %d", error_type_str, buffer, error_filename, error_lineno); diff --git a/main/output.c b/main/output.c index a1530b63fc..c8b41ba1eb 100644 --- a/main/output.c +++ b/main/output.c @@ -961,6 +961,7 @@ static inline php_output_handler_status_t php_output_handler_op(php_output_handl ZVAL_STRINGL(&ob_data, handler->buffer.data, handler->buffer.used); ZVAL_LONG(&ob_mode, (zend_long) context->op); zend_fcall_info_argn(&handler->func.user->fci TSRMLS_CC, 2, &ob_data, &ob_mode); + zval_ptr_dtor(&ob_data); #define PHP_OUTPUT_USER_SUCCESS(retval) ((Z_TYPE(retval) != IS_UNDEF) && !(Z_TYPE(retval) == IS_FALSE)) if (SUCCESS == zend_fcall_info_call(&handler->func.user->fci, &handler->func.user->fcc, &retval, NULL TSRMLS_CC) && PHP_OUTPUT_USER_SUCCESS(retval)) { diff --git a/main/php_ini.c b/main/php_ini.c index a6c325b0fb..5303bf77ec 100644 --- a/main/php_ini.c +++ b/main/php_ini.c @@ -802,7 +802,7 @@ PHPAPI int php_ini_has_per_dir_config(void) /* {{{ php_ini_activate_per_dir_config */ -PHPAPI void php_ini_activate_per_dir_config(char *path, uint path_len TSRMLS_DC) +PHPAPI void php_ini_activate_per_dir_config(char *path, size_t path_len TSRMLS_DC) { zval *tmp2; char *ptr; @@ -853,7 +853,7 @@ PHPAPI int php_ini_has_per_host_config(void) /* {{{ php_ini_activate_per_host_config */ -PHPAPI void php_ini_activate_per_host_config(const char *host, uint host_len TSRMLS_DC) +PHPAPI void php_ini_activate_per_host_config(const char *host, size_t host_len TSRMLS_DC) { zval *tmp; @@ -876,7 +876,7 @@ PHPAPI zval *cfg_get_entry_ex(zend_string *name) /* {{{ cfg_get_entry */ -PHPAPI zval *cfg_get_entry(const char *name, uint name_length) +PHPAPI zval *cfg_get_entry(const char *name, size_t name_length) { return zend_hash_str_find(&configuration_hash, name, name_length); } diff --git a/main/php_ini.h b/main/php_ini.h index 99f6a07a07..7022507f51 100644 --- a/main/php_ini.h +++ b/main/php_ini.h @@ -29,7 +29,7 @@ int php_init_config(TSRMLS_D); int php_shutdown_config(void); void php_ini_register_extensions(TSRMLS_D); PHPAPI zval *cfg_get_entry_ex(zend_string *name); -PHPAPI zval *cfg_get_entry(const char *name, uint name_length); +PHPAPI zval *cfg_get_entry(const char *name, size_t name_length); PHPAPI int cfg_get_long(const char *varname, zend_long *result); PHPAPI int cfg_get_double(const char *varname, double *result); PHPAPI int cfg_get_string(const char *varname, char **result); @@ -37,8 +37,8 @@ PHPAPI int php_parse_user_ini_file(const char *dirname, char *ini_filename, Hash PHPAPI void php_ini_activate_config(HashTable *source_hash, int modify_type, int stage TSRMLS_DC); PHPAPI int php_ini_has_per_dir_config(void); PHPAPI int php_ini_has_per_host_config(void); -PHPAPI void php_ini_activate_per_dir_config(char *path, uint path_len TSRMLS_DC); -PHPAPI void php_ini_activate_per_host_config(const char *host, uint host_len TSRMLS_DC); +PHPAPI void php_ini_activate_per_dir_config(char *path, size_t path_len TSRMLS_DC); +PHPAPI void php_ini_activate_per_host_config(const char *host, size_t host_len TSRMLS_DC); PHPAPI HashTable* php_ini_get_configuration_hash(void); END_EXTERN_C() diff --git a/main/snprintf.c b/main/snprintf.c index 0b9182b614..7e4d8a11ab 100644 --- a/main/snprintf.c +++ b/main/snprintf.c @@ -38,7 +38,12 @@ #ifdef HAVE_LOCALE_H #include <locale.h> +#ifdef ZTS +#include "ext/standard/php_string.h" +#define LCONV_DECIMAL_POINT (*lconv.decimal_point) +#else #define LCONV_DECIMAL_POINT (*lconv->decimal_point) +#endif #else #define LCONV_DECIMAL_POINT '.' #endif @@ -607,8 +612,12 @@ static int format_converter(register buffy * odp, const char *fmt, va_list ap) / char char_buf[2]; /* for printing %% and %<unknown> */ #ifdef HAVE_LOCALE_H +#ifdef ZTS + struct lconv lconv; +#else struct lconv *lconv = NULL; #endif +#endif /* * Flag variables @@ -1017,10 +1026,14 @@ static int format_converter(register buffy * odp, const char *fmt, va_list ap) / s_len = 3; } else { #ifdef HAVE_LOCALE_H +#ifdef ZTS + localeconv_r(&lconv); +#else if (!lconv) { lconv = localeconv(); } #endif +#endif s = php_conv_fp((*fmt == 'f')?'F':*fmt, fp_num, alternate_form, (adjust_precision == NO) ? FLOAT_DIGITS : precision, (*fmt == 'f')?LCONV_DECIMAL_POINT:'.', @@ -1074,10 +1087,14 @@ static int format_converter(register buffy * odp, const char *fmt, va_list ap) / * * We use &num_buf[ 1 ], so that we have room for the sign */ #ifdef HAVE_LOCALE_H +#ifdef ZTS + localeconv_r(&lconv); +#else if (!lconv) { lconv = localeconv(); } #endif +#endif s = php_gcvt(fp_num, precision, (*fmt=='H' || *fmt == 'k') ? '.' : LCONV_DECIMAL_POINT, (*fmt == 'G' || *fmt == 'H')?'E':'e', &num_buf[1]); if (*s == '-') { prefix_char = *s++; diff --git a/main/spprintf.c b/main/spprintf.c index 1fcce9df18..ee73d4f4e5 100644 --- a/main/spprintf.c +++ b/main/spprintf.c @@ -93,7 +93,12 @@ #ifdef HAVE_LOCALE_H #include <locale.h> +#ifdef ZTS +#include "ext/standard/php_string.h" +#define LCONV_DECIMAL_POINT (*lconv.decimal_point) +#else #define LCONV_DECIMAL_POINT (*lconv->decimal_point) +#endif #else #define LCONV_DECIMAL_POINT '.' #endif @@ -218,8 +223,12 @@ static void xbuf_format_converter(void *xbuf, zend_bool is_char, const char *fmt char char_buf[2]; /* for printing %% and %<unknown> */ #ifdef HAVE_LOCALE_H +#ifdef ZTS + struct lconv lconv; +#else struct lconv *lconv = NULL; #endif +#endif /* * Flag variables @@ -633,10 +642,14 @@ static void xbuf_format_converter(void *xbuf, zend_bool is_char, const char *fmt s_len = 3; } else { #ifdef HAVE_LOCALE_H +#ifdef ZTS + localeconv_r(&lconv); +#else if (!lconv) { lconv = localeconv(); } #endif +#endif s = php_conv_fp((*fmt == 'f')?'F':*fmt, fp_num, alternate_form, (adjust_precision == NO) ? FLOAT_DIGITS : precision, (*fmt == 'f')?LCONV_DECIMAL_POINT:'.', @@ -689,10 +702,14 @@ static void xbuf_format_converter(void *xbuf, zend_bool is_char, const char *fmt * * We use &num_buf[ 1 ], so that we have room for the sign */ #ifdef HAVE_LOCALE_H +#ifdef ZTS + localeconv_r(&lconv); +#else if (!lconv) { lconv = localeconv(); } #endif +#endif s = php_gcvt(fp_num, precision, (*fmt=='H' || *fmt == 'k') ? '.' : LCONV_DECIMAL_POINT, (*fmt == 'G' || *fmt == 'H')?'E':'e', &num_buf[1]); if (*s == '-') prefix_char = *s++; diff --git a/main/streams/memory.c b/main/streams/memory.c index 6b1b2312a9..28274d7fcd 100644 --- a/main/streams/memory.c +++ b/main/streams/memory.c @@ -87,15 +87,19 @@ static size_t php_stream_memory_read(php_stream *stream, char *buf, size_t count php_stream_memory_data *ms = (php_stream_memory_data*)stream->abstract; assert(ms != NULL); - if (ms->fpos + count >= ms->fsize) { - count = ms->fsize - ms->fpos; + if (ms->fpos == ms->fsize) { stream->eof = 1; - } - if (count) { - assert(ms->data!= NULL); - assert(buf!= NULL); - memcpy(buf, ms->data+ms->fpos, count); - ms->fpos += count; + count = 0; + } else { + if (ms->fpos + count >= ms->fsize) { + count = ms->fsize - ms->fpos; + } + if (count) { + assert(ms->data!= NULL); + assert(buf!= NULL); + memcpy(buf, ms->data+ms->fpos, count); + ms->fpos += count; + } } return count; } diff --git a/main/streams/plain_wrapper.c b/main/streams/plain_wrapper.c index 8590647818..8fad2aa4f1 100644 --- a/main/streams/plain_wrapper.c +++ b/main/streams/plain_wrapper.c @@ -1036,12 +1036,8 @@ static php_stream *php_plain_files_stream_opener(php_stream_wrapper *wrapper, co static int php_plain_files_url_stater(php_stream_wrapper *wrapper, const char *url, int flags, php_stream_statbuf *ssb, php_stream_context *context TSRMLS_DC) { - char *p; - - if ((p = strstr(url, "://")) != NULL) { - if (p < strchr(url, '/')) { - url = p + 3; - } + if (strncasecmp(url, "file://", sizeof("file://") - 1) == 0) { + url += sizeof("file://") - 1; } if (php_check_open_basedir_ex(url, (flags & PHP_STREAM_URL_STAT_QUIET) ? 0 : 1 TSRMLS_CC)) { @@ -1066,13 +1062,10 @@ static int php_plain_files_url_stater(php_stream_wrapper *wrapper, const char *u static int php_plain_files_unlink(php_stream_wrapper *wrapper, const char *url, int options, php_stream_context *context TSRMLS_DC) { - char *p; int ret; - if ((p = strstr(url, "://")) != NULL) { - if (p < strchr(url, '/')) { - url = p + 3; - } + if (strncasecmp(url, "file://", sizeof("file://") - 1) == 0) { + url += sizeof("file://") - 1; } if (php_check_open_basedir(url TSRMLS_CC)) { @@ -1095,7 +1088,6 @@ static int php_plain_files_unlink(php_stream_wrapper *wrapper, const char *url, static int php_plain_files_rename(php_stream_wrapper *wrapper, const char *url_from, const char *url_to, int options, php_stream_context *context TSRMLS_DC) { - char *p; int ret; if (!url_from || !url_to) { @@ -1113,16 +1105,12 @@ static int php_plain_files_rename(php_stream_wrapper *wrapper, const char *url_f } #endif - if ((p = strstr(url_from, "://")) != NULL) { - if (p < strchr(url_from, '/')) { - url_from = p + 3; - } + if (strncasecmp(url_from, "file://", sizeof("file://") - 1) == 0) { + url_from += sizeof("file://") - 1; } - if ((p = strstr(url_to, "://")) != NULL) { - if (p < strchr(url_to, '/')) { - url_to = p + 3; - } + if (strncasecmp(url_to, "file://", sizeof("file://") - 1) == 0) { + url_to += sizeof("file://") - 1; } if (php_check_open_basedir(url_from TSRMLS_CC) || php_check_open_basedir(url_to TSRMLS_CC)) { @@ -1187,10 +1175,8 @@ static int php_plain_files_mkdir(php_stream_wrapper *wrapper, const char *dir, i int ret, recursive = options & PHP_STREAM_MKDIR_RECURSIVE; char *p; - if ((p = strstr(dir, "://")) != NULL) { - if (p < strchr(dir, '/')) { - dir = p + 3; - } + if (strncasecmp(dir, "file://", sizeof("file://") - 1) == 0) { + dir += sizeof("file://") - 1; } if (!recursive) { @@ -1272,15 +1258,16 @@ static int php_plain_files_mkdir(php_stream_wrapper *wrapper, const char *dir, i static int php_plain_files_rmdir(php_stream_wrapper *wrapper, const char *url, int options, php_stream_context *context TSRMLS_DC) { -#if PHP_WIN32 - int url_len = (int)strlen(url); -#endif + if (strncasecmp(url, "file://", sizeof("file://") - 1) == 0) { + url += sizeof("file://") - 1; + } + if (php_check_open_basedir(url TSRMLS_CC)) { return 0; } #if PHP_WIN32 - if (!php_win32_check_trailing_space(url, url_len)) { + if (!php_win32_check_trailing_space(url, (int)strlen(url))) { php_error_docref1(NULL TSRMLS_CC, url, E_WARNING, "%s", strerror(ENOENT)); return 0; } @@ -1300,7 +1287,6 @@ 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 TSRMLS_DC) { struct utimbuf *newtime; - char *p; #if !defined(WINDOWS) && !defined(NETWARE) uid_t uid; gid_t gid; @@ -1318,10 +1304,8 @@ static int php_plain_files_metadata(php_stream_wrapper *wrapper, const char *url } #endif - if ((p = strstr(url, "://")) != NULL) { - if (p < strchr(url, '/')) { - url = p + 3; - } + if (strncasecmp(url, "file://", sizeof("file://") - 1) == 0) { + url += sizeof("file://") - 1; } if (php_check_open_basedir(url TSRMLS_CC)) { |
