diff options
Diffstat (limited to 'main')
67 files changed, 435 insertions, 261 deletions
diff --git a/main/SAPI.c b/main/SAPI.c index 4ce21e64f..8e65fac08 100644 --- a/main/SAPI.c +++ b/main/SAPI.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2008 The PHP Group | + | Copyright (c) 1997-2009 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: SAPI.c,v 1.202.2.7.2.18 2008/01/28 16:12:55 scottmac Exp $ */ +/* $Id: SAPI.c,v 1.202.2.7.2.19 2008/12/31 11:17:47 sebastian Exp $ */ #include <ctype.h> #include <sys/stat.h> diff --git a/main/SAPI.h b/main/SAPI.h index a00027268..6d4976630 100644 --- a/main/SAPI.h +++ b/main/SAPI.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2008 The PHP Group | + | Copyright (c) 1997-2009 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: SAPI.h,v 1.114.2.1.2.4 2007/12/31 07:20:14 sebastian Exp $ */ +/* $Id: SAPI.h,v 1.114.2.1.2.5 2008/12/31 11:17:47 sebastian Exp $ */ #ifndef SAPI_H #define SAPI_H diff --git a/main/fopen_wrappers.c b/main/fopen_wrappers.c index 69e78dfc7..d2bc9a422 100644 --- a/main/fopen_wrappers.c +++ b/main/fopen_wrappers.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2008 The PHP Group | + | Copyright (c) 1997-2009 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: fopen_wrappers.c,v 1.175.2.3.2.19 2008/01/29 14:23:19 dmitry Exp $ */ +/* $Id: fopen_wrappers.c,v 1.175.2.3.2.23 2009/02/10 16:14:27 iliaa Exp $ */ /* {{{ includes */ @@ -528,7 +528,9 @@ PHPAPI FILE *php_fopen_with_path(const char *filename, const char *mode, const c *end = '\0'; end++; } - snprintf(trypath, MAXPATHLEN, "%s/%s", ptr, filename); + if (snprintf(trypath, MAXPATHLEN, "%s/%s", ptr, filename) >= MAXPATHLEN) { + php_error_docref(NULL TSRMLS_CC, E_NOTICE, "%s/%s path was truncated to %d", ptr, filename, MAXPATHLEN); + } if (PG(safe_mode)) { if (VCWD_STAT(trypath, &sb) == 0) { /* file exists ... check permission */ @@ -601,6 +603,14 @@ PHPAPI char *php_strip_url_passwd(char *url) */ PHPAPI char *expand_filepath(const char *filepath, char *real_path TSRMLS_DC) { + return expand_filepath_ex(filepath, real_path, NULL, 0 TSRMLS_CC); +} +/* }}} */ + +/* {{{ expand_filepath_ex + */ +PHPAPI char *expand_filepath_ex(const char *filepath, char *real_path, const char *relative_to, size_t relative_to_len TSRMLS_DC) +{ cwd_state new_state; char cwd[MAXPATHLEN]; int copy_len; @@ -611,7 +621,16 @@ PHPAPI char *expand_filepath(const char *filepath, char *real_path TSRMLS_DC) cwd[0] = '\0'; } else { const char *iam = SG(request_info).path_translated; - char *result = VCWD_GETCWD(cwd, MAXPATHLEN); + const char *result; + if (relative_to) { + if (relative_to_len > MAXPATHLEN-1U) { + return NULL; + } + result = relative_to; + memcpy(cwd, relative_to, relative_to_len+1U); + } else { + result = VCWD_GETCWD(cwd, MAXPATHLEN); + } if (!result && (iam != filepath)) { int fdtest = -1; diff --git a/main/fopen_wrappers.h b/main/fopen_wrappers.h index 0a0dee6aa..42aa96a84 100644 --- a/main/fopen_wrappers.h +++ b/main/fopen_wrappers.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2008 The PHP Group | + | Copyright (c) 1997-2009 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: fopen_wrappers.h,v 1.44.2.1.2.4 2007/12/31 07:20:14 sebastian Exp $ */ +/* $Id: fopen_wrappers.h,v 1.44.2.1.2.6 2008/12/31 11:17:47 sebastian Exp $ */ #ifndef FOPEN_WRAPPERS_H #define FOPEN_WRAPPERS_H @@ -26,6 +26,7 @@ BEGIN_EXTERN_C() PHPAPI int php_fopen_primary_script(zend_file_handle *file_handle TSRMLS_DC); PHPAPI char *expand_filepath(const char *filepath, char *real_path TSRMLS_DC); +PHPAPI char *expand_filepath_ex(const char *filepath, char *real_path, const char *relative_to, size_t relative_to_len TSRMLS_DC); PHPAPI int php_check_open_basedir(const char *path TSRMLS_DC); PHPAPI int php_check_open_basedir_ex(const char *path, int warn TSRMLS_DC); diff --git a/main/internal_functions_nw.c b/main/internal_functions_nw.c index 9a84b6cde..467615f66 100644 --- a/main/internal_functions_nw.c +++ b/main/internal_functions_nw.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2008 The PHP Group | + | Copyright (c) 1997-2009 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: internal_functions_nw.c,v 1.9.2.1.2.3 2007/12/31 07:20:14 sebastian Exp $ */ +/* $Id: internal_functions_nw.c,v 1.9.2.1.2.4 2008/12/31 11:17:47 sebastian Exp $ */ /* {{{ includes */ diff --git a/main/internal_functions_win32.c b/main/internal_functions_win32.c index 8cf65cad9..4eeb142d3 100644 --- a/main/internal_functions_win32.c +++ b/main/internal_functions_win32.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2008 The PHP Group | + | Copyright (c) 1997-2009 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: internal_functions_win32.c,v 1.87.2.1.2.4 2007/12/31 07:20:14 sebastian Exp $ */ +/* $Id: internal_functions_win32.c,v 1.87.2.1.2.5 2008/12/31 11:17:47 sebastian Exp $ */ /* {{{ includes */ diff --git a/main/logos.h b/main/logos.h index 559b2e110..2a16d0ce9 100644 --- a/main/logos.h +++ b/main/logos.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2008 The PHP Group | + | Copyright (c) 1997-2009 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: logos.h,v 1.14.2.3.2.3 2007/12/31 07:20:14 sebastian Exp $ */ +/* $Id: logos.h,v 1.14.2.3.2.4 2008/12/31 11:17:47 sebastian Exp $ */ #define CONTEXT_TYPE_IMAGE_GIF "Content-Type: image/gif" diff --git a/main/main.c b/main/main.c index 0c3c523a4..2a5ff25a2 100644 --- a/main/main.c +++ b/main/main.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2008 The PHP Group | + | Copyright (c) 1997-2009 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: main.c,v 1.640.2.23.2.62 2008/03/05 20:58:08 pajoye Exp $ */ +/* $Id: main.c,v 1.640.2.23.2.68 2008/12/31 11:17:47 sebastian Exp $ */ /* {{{ includes */ @@ -352,12 +352,15 @@ static PHP_INI_MH(OnChangeMailForceExtra) # define PHP_SAFE_MODE_EXEC_DIR "" #endif -/* Windows and Netware use the internal mail */ + /* Windows and Netware use the internal mail */ #if defined(PHP_WIN32) || defined(NETWARE) -# define DEFAULT_SENDMAIL_PATH NULL +# define DEFAULT_SENDMAIL_PATH NULL +#elif defined(PHP_PROG_SENDMAIL) +# define DEFAULT_SENDMAIL_PATH PHP_PROG_SENDMAIL " -t -i " #else -# define DEFAULT_SENDMAIL_PATH "/usr/sbin/sendmail -t -i" +# define DEFAULT_SENDMAIL_PATH "/usr/sbin/sendmail -t -i" #endif + /* {{{ PHP_INI */ PHP_INI_BEGIN() @@ -565,8 +568,8 @@ PHPAPI void php_verror(const char *docref, const char *params, int type, const c char *docref_target = "", *docref_root = ""; char *p; int buffer_len = 0; - char *space; - char *class_name = get_active_class_name(&space TSRMLS_CC); + char *space = ""; + char *class_name = ""; char *function; int origin_len; char *origin; @@ -622,6 +625,7 @@ PHPAPI void php_verror(const char *docref, const char *params, int type, const c function = "Unknown"; } else { is_function = 1; + class_name = get_active_class_name(&space TSRMLS_CC); } } @@ -1435,6 +1439,8 @@ void php_request_shutdown(void *dummy) EG(opline_ptr) = NULL; EG(active_op_array) = NULL; + php_deactivate_ticks(TSRMLS_C); + /* 1. Call all possible shutdown functions registered with register_shutdown_function() */ if (PG(modules_activated)) zend_try { php_call_shutdown_functions(TSRMLS_C); @@ -1775,7 +1781,19 @@ int php_module_startup(sapi_module_struct *sf, zend_module_entry *additional_mod zend_set_utility_values(&zuv); php_startup_sapi_content_types(TSRMLS_C); + /* Register constants */ REGISTER_MAIN_STRINGL_CONSTANT("PHP_VERSION", PHP_VERSION, sizeof(PHP_VERSION)-1, CONST_PERSISTENT | CONST_CS); + REGISTER_MAIN_LONG_CONSTANT("PHP_MAJOR_VERSION", PHP_MAJOR_VERSION, CONST_PERSISTENT | CONST_CS); + REGISTER_MAIN_LONG_CONSTANT("PHP_MINOR_VERSION", PHP_MINOR_VERSION, CONST_PERSISTENT | CONST_CS); + REGISTER_MAIN_LONG_CONSTANT("PHP_RELEASE_VERSION", PHP_RELEASE_VERSION, CONST_PERSISTENT | CONST_CS); + REGISTER_MAIN_STRINGL_CONSTANT("PHP_EXTRA_VERSION", PHP_EXTRA_VERSION, sizeof(PHP_EXTRA_VERSION) - 1, CONST_PERSISTENT | CONST_CS); + REGISTER_MAIN_LONG_CONSTANT("PHP_VERSION_ID", PHP_VERSION_ID, CONST_PERSISTENT | CONST_CS); +#ifdef ZTS + REGISTER_MAIN_LONG_CONSTANT("PHP_ZTS", 1, CONST_PERSISTENT | CONST_CS); +#else + REGISTER_MAIN_LONG_CONSTANT("PHP_ZTS", 0, CONST_PERSISTENT | CONST_CS); +#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_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); diff --git a/main/network.c b/main/network.c index 1a95275ad..2ae5af3b7 100644 --- a/main/network.c +++ b/main/network.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2008 The PHP Group | + | Copyright (c) 1997-2009 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: network.c,v 1.118.2.2.2.9 2008/03/11 10:27:23 tony2001 Exp $ */ +/* $Id: network.c,v 1.118.2.2.2.16 2009/01/03 00:06:59 felipe Exp $ */ /*#define DEBUG_MAIN_NETWORK 1*/ @@ -162,7 +162,9 @@ static int php_network_getaddresses(const char *host, int socktype, struct socka struct sockaddr **sap; int n; #if HAVE_GETADDRINFO +# if HAVE_IPV6 static int ipv6_borked = -1; /* the way this is used *is* thread safe */ +# endif struct addrinfo hints, *res, *sai; #else struct hostent *host_info; @@ -639,6 +641,7 @@ PHPAPI int php_network_get_peer_name(php_socket_t sock, { php_sockaddr_storage sa; socklen_t sl = sizeof(sa); + memset(&sa, 0, sizeof(sa)); if (getpeername(sock, (struct sockaddr*)&sa, &sl) == 0) { php_network_populate_name_from_sockaddr((struct sockaddr*)&sa, sl, @@ -658,6 +661,7 @@ PHPAPI int php_network_get_sock_name(php_socket_t sock, { php_sockaddr_storage sa; socklen_t sl = sizeof(sa); + memset(&sa, 0, sizeof(sa)); if (getsockname(sock, (struct sockaddr*)&sa, &sl) == 0) { php_network_populate_name_from_sockaddr((struct sockaddr*)&sa, sl, @@ -1049,7 +1053,11 @@ PHPAPI int php_set_sock_blocking(int socketd, int block TSRMLS_DC) /* with ioctlsocket, a non-zero sets nonblocking, a zero sets blocking */ flags = !block; if (ioctlsocket(socketd, FIONBIO, &flags) == SOCKET_ERROR) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", WSAGetLastError()); + char *error_string; + + error_string = php_socket_strerror(WSAGetLastError(), NULL, 0); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", error_string); + efree(error_string); ret = FAILURE; } #else @@ -1133,6 +1141,12 @@ PHPAPI int php_poll2(php_pollfd *ufds, unsigned int nfds, int timeout) tv.tv_sec = timeout / 1000; tv.tv_usec = (timeout - (tv.tv_sec * 1000)) * 1000; } +/* Reseting/initializing */ +#ifdef PHP_WIN32 + WSASetLastError(0); +#else + errno = 0; +#endif n = select(max_fd + 1, &rset, &wset, &eset, timeout >= 0 ? &tv : NULL); if (n >= 0) { diff --git a/main/output.c b/main/output.c index 15c6ebe32..67368e9c9 100644 --- a/main/output.c +++ b/main/output.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2008 The PHP Group | + | Copyright (c) 1997-2009 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: output.c,v 1.167.2.3.2.5 2007/12/31 07:20:15 sebastian Exp $ */ +/* $Id: output.c,v 1.167.2.3.2.8 2008/12/31 11:17:47 sebastian Exp $ */ #include "php.h" #include "ext/standard/head.h" diff --git a/main/php.h b/main/php.h index 1645c38dc..dd47c5fbf 100644 --- a/main/php.h +++ b/main/php.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2008 The PHP Group | + | Copyright (c) 1997-2009 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php.h,v 1.221.2.4.2.9 2007/12/31 07:20:15 sebastian Exp $ */ +/* $Id: php.h,v 1.221.2.4.2.10 2008/12/31 11:17:47 sebastian Exp $ */ #ifndef PHP_H #define PHP_H diff --git a/main/php3_compat.h b/main/php3_compat.h index b24656d28..56bf5654a 100644 --- a/main/php3_compat.h +++ b/main/php3_compat.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2008 The PHP Group | + | Copyright (c) 1997-2009 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php3_compat.h,v 1.20.2.1.2.2 2007/12/31 07:20:15 sebastian Exp $ */ +/* $Id: php3_compat.h,v 1.20.2.1.2.3 2008/12/31 11:17:47 sebastian Exp $ */ #ifndef PHP3_COMPAT_H #define PHP3_COMPAT_H diff --git a/main/php_compat.h b/main/php_compat.h index 53d068b6d..346a60a82 100644 --- a/main/php_compat.h +++ b/main/php_compat.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2008 The PHP Group | + | Copyright (c) 1997-2009 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_compat.h,v 1.25.2.3.2.5 2007/12/31 07:20:15 sebastian Exp $ */ +/* $Id: php_compat.h,v 1.25.2.3.2.7 2008/12/31 11:17:47 sebastian Exp $ */ #ifndef PHP_COMPAT_H #define PHP_COMPAT_H @@ -28,36 +28,34 @@ #endif #if defined(HAVE_BUNDLED_PCRE) || !defined(PHP_VERSION) -#define pcre_compile php_pcre_compile -#define pcre_compile2 php_pcre_compile2 +#define pcre_compile php_pcre_compile +#define pcre_compile2 php_pcre_compile2 #define pcre_copy_substring php_pcre_copy_substring -#define pcre_exec php_pcre_exec +#define pcre_exec php_pcre_exec #define pcre_get_substring php_pcre_get_substring -#define pcre_get_substring_list php_pcre_get_substring_list -#define pcre_info php_pcre_info +#define pcre_get_substring_list php_pcre_get_substring_list +#define pcre_info php_pcre_info #define pcre_maketables php_pcre_maketables -#define pcre_study php_pcre_study +#define pcre_study php_pcre_study #define pcre_version php_pcre_version #define pcre_fullinfo php_pcre_fullinfo -#define pcre_free php_pcre_free -#define pcre_malloc php_pcre_malloc -#define pcre_config php_pcre_config -#define pcre_copy_named_substring php_pcre_copy_named_substring -#define pcre_free_substring php_pcre_free_substring -#define pcre_free_substring_list php_pcre_free_substring_list -#define pcre_get_named_substring php_pcre_get_named_substring -#define pcre_get_stringnumber php_pcre_get_stringnumber -#define pcre_refcount php_pcre_refcount -#define _pcre_ord2utf8 php__pcre_ord2utf8 -#define _pcre_try_flipped php__pcre_try_flipped -#define _pcre_ucp_findprop php__pcre_ucp_findprop -#define _pcre_ucp_othercase php__pcre_ucp_othercase -#define _pcre_valid_utf8 php__pcre_valid_utf8 -#define _pcre_xclass php__pcre_xclass +#define pcre_free php_pcre_free +#define pcre_malloc php_pcre_malloc +#define pcre_config php_pcre_config +#define pcre_copy_named_substring php_pcre_copy_named_substring +#define pcre_free_substring php_pcre_free_substring +#define pcre_free_substring_list php_pcre_free_substring_list +#define pcre_get_named_substring php_pcre_get_named_substring +#define pcre_get_stringnumber php_pcre_get_stringnumber +#define pcre_refcount php_pcre_refcount +#define _pcre_ord2utf8 php__pcre_ord2utf8 +#define _pcre_try_flipped php__pcre_try_flipped +#define _pcre_valid_utf8 php__pcre_valid_utf8 +#define _pcre_xclass php__pcre_xclass #define pcre_callout php_pcre_callout #define _pcre_OP_lengths php__pcre_OP_lengths -/* this one doesn't work because pcre.h isn't included from the pcre_chartables.c file -#define _pcre_default_tables php__pcre_default_tables */ +#define _pcre_utt_names php__pcre_utt_names +#define _pcre_default_tables php__pcre_default_tables #define pcre_get_stringtable_entries php_pcre_get_stringtable_entries #define _pcre_is_newline php__pcre_is_newline #define pcre_stack_free php_pcre_stack_free @@ -70,6 +68,10 @@ #define _pcre_utt php__pcre_utt #define _pcre_utt_size php__pcre_utt_size #define _pcre_was_newline php__pcre_was_newline +#define _pcre_ucd_records php__pcre_ucd_records +#define _pcre_ucd_stage1 php__pcre_ucd_stage1 +#define _pcre_ucd_stage2 php__pcre_ucd_stage2 +#define _pcre_ucp_gentype php__pcre_ucp_gentype #endif #define lookup php_lookup diff --git a/main/php_config.h.in b/main/php_config.h.in index 5bf46a8f6..dd7b15e95 100644 --- a/main/php_config.h.in +++ b/main/php_config.h.in @@ -4,7 +4,7 @@ +----------------------------------------------------------------------+ | Zend Engine | +----------------------------------------------------------------------+ - | Copyright (c) 1998-2008 Zend Technologies Ltd. (http://www.zend.com) | + | Copyright (c) 1998-2009 Zend Technologies Ltd. (http://www.zend.com) | +----------------------------------------------------------------------+ | This source file is subject to version 2.00 of the Zend license, | | that is bundled with this package in the file LICENSE, and is | @@ -19,7 +19,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: acconfig.h,v 1.40.2.1.2.2 2007/12/31 07:20:02 sebastian Exp $ */ +/* $Id: acconfig.h,v 1.40.2.1.2.3 2008/12/31 11:17:32 sebastian Exp $ */ #define ZEND_API #define ZEND_DLEXPORT @@ -521,6 +521,9 @@ /* Define if you have the strlcpy function. */ #undef HAVE_STRLCPY +/* Define if you have the strnlen function. */ +#undef HAVE_STRNLEN + /* Define if you have the strpbrk function. */ #undef HAVE_STRPBRK @@ -653,6 +656,9 @@ /* Define if you have the <netinet/tcp.h> header file. */ #undef HAVE_NETINET_TCP_H +/* Define if you have the <openssl/crypto.h> header file. */ +#undef HAVE_OPENSSL_CRYPTO_H + /* Define if you have the <pwd.h> header file. */ #undef HAVE_PWD_H @@ -1746,6 +1752,9 @@ #undef HAVE_IMAP_AUTH_GSS /* */ +#undef HAVE_RFC822_OUTPUT_ADDRESS_LIST + +/* */ #undef HAVE_IBASE /* Whether to build interbase as dynamic module */ @@ -2402,6 +2411,9 @@ /* Whether you have a working ttyname_r */ #undef HAVE_TTYNAME_R +/* Wether struct utsname has domainname */ +#undef HAVE_UTSNAME_DOMAINNAME + /* Whether to build pspell as dynamic module */ #undef COMPILE_DL_PSPELL diff --git a/main/php_content_types.c b/main/php_content_types.c index eed43b37b..1c3bd5b56 100644 --- a/main/php_content_types.c +++ b/main/php_content_types.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2008 The PHP Group | + | Copyright (c) 1997-2009 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_content_types.c,v 1.32.2.1.2.5 2007/12/31 07:20:15 sebastian Exp $ */ +/* $Id: php_content_types.c,v 1.32.2.1.2.6 2008/12/31 11:17:47 sebastian Exp $ */ #include "php.h" #include "SAPI.h" diff --git a/main/php_content_types.h b/main/php_content_types.h index 594348fb9..a433a2c11 100644 --- a/main/php_content_types.h +++ b/main/php_content_types.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2008 The PHP Group | + | Copyright (c) 1997-2009 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_content_types.h,v 1.12.2.1.2.2 2007/12/31 07:20:15 sebastian Exp $ */ +/* $Id: php_content_types.h,v 1.12.2.1.2.3 2008/12/31 11:17:47 sebastian Exp $ */ #ifndef PHP_CONTENT_TYPES_H #define PHP_CONTENT_TYPES_H diff --git a/main/php_globals.h b/main/php_globals.h index 84fc35b7b..98763064b 100644 --- a/main/php_globals.h +++ b/main/php_globals.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2008 The PHP Group | + | Copyright (c) 1997-2009 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_globals.h,v 1.98.2.1.2.8 2007/12/31 07:20:15 sebastian Exp $ */ +/* $Id: php_globals.h,v 1.98.2.1.2.9 2008/12/31 11:17:47 sebastian Exp $ */ #ifndef PHP_GLOBALS_H #define PHP_GLOBALS_H diff --git a/main/php_ini.c b/main/php_ini.c index e70e03b65..cfa850353 100644 --- a/main/php_ini.c +++ b/main/php_ini.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2008 The PHP Group | + | Copyright (c) 1997-2009 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_ini.c,v 1.136.2.4.2.16 2007/12/31 07:20:15 sebastian Exp $ */ +/* $Id: php_ini.c,v 1.136.2.4.2.19 2008/12/31 11:17:47 sebastian Exp $ */ #include "php.h" #include "ext/standard/info.h" @@ -50,6 +50,7 @@ typedef struct _php_extension_lists { static HashTable configuration_hash; PHPAPI char *php_ini_opened_path=NULL; static php_extension_lists extension_lists; +PHPAPI char *php_ini_scanned_path=NULL; PHPAPI char *php_ini_scanned_files=NULL; /* {{{ php_ini_displayer_cb @@ -260,6 +261,7 @@ int php_init_config(TSRMLS_D) { char *php_ini_file_name = NULL; char *php_ini_search_path = NULL; + int php_ini_scanned_path_len; int safe_mode_state; char *open_basedir; int free_ini_search_path = 0; @@ -448,9 +450,18 @@ int php_init_config(TSRMLS_D) PG(safe_mode) = 0; PG(open_basedir) = NULL; + /* + * Find and open actual ini file + */ + memset(&fh, 0, sizeof(fh)); - /* Check if php_ini_path_override is a file */ - if (!sapi_module.php_ini_ignore) { + + /* If SAPI does not want to ignore all ini files OR an overriding file/path is given. + * This allows disabling scanning for ini files in the PHP_CONFIG_FILE_SCAN_DIR but still + * load an optional ini file. */ + if (!sapi_module.php_ini_ignore || sapi_module.php_ini_path_override) { + + /* Check if php_ini_file_name is a file and can be opened */ if (php_ini_file_name && php_ini_file_name[0]) { struct stat statbuf; @@ -463,7 +474,8 @@ int php_init_config(TSRMLS_D) } } } - /* Search php-%sapi-module-name%.ini file in search path */ + + /* Otherwise search for php-%sapi-module-name%.ini file in search path */ if (!fh.handle.fp) { const char *fmt = "php-%s.ini"; char *ini_fname; @@ -474,7 +486,8 @@ int php_init_config(TSRMLS_D) fh.filename = php_ini_opened_path; } } - /* Search php.ini file in search path */ + + /* If still no ini file found, search for php.ini file in search path */ if (!fh.handle.fp) { fh.handle.fp = php_fopen_with_path("php.ini", "r", php_ini_search_path, &php_ini_opened_path TSRMLS_CC); if (fh.handle.fp) { @@ -509,20 +522,31 @@ int php_init_config(TSRMLS_D) } } - /* If the config_file_scan_dir is set at compile-time, go and scan this directory and - * parse any .ini files found in this directory. */ - if (!sapi_module.php_ini_ignore && strlen(PHP_CONFIG_FILE_SCAN_DIR)) { + /* Check for PHP_INI_SCAN_DIR environment variable to override/set config file scan directory */ + php_ini_scanned_path = getenv("PHP_INI_SCAN_DIR"); + if (!php_ini_scanned_path) { + /* Or fall back using possible --with-config-file-scan-dir setting (defaults to empty string!) */ + php_ini_scanned_path = PHP_CONFIG_FILE_SCAN_DIR; + } + php_ini_scanned_path_len = strlen(php_ini_scanned_path); + + /* Scan and parse any .ini files found in scan path if path not empty. */ + if (!sapi_module.php_ini_ignore && php_ini_scanned_path_len) { struct dirent **namelist; int ndir, i; - if ((ndir = php_scandir(PHP_CONFIG_FILE_SCAN_DIR, &namelist, 0, php_alphasort)) > 0) { + if ((ndir = php_scandir(php_ini_scanned_path, &namelist, 0, php_alphasort)) > 0) { for (i = 0; i < ndir; i++) { /* check for a .ini extension */ if (!(p = strrchr(namelist[i]->d_name, '.')) || (p && strcmp(p, ".ini"))) { free(namelist[i]); continue; } - snprintf(ini_file, MAXPATHLEN, "%s%c%s", PHP_CONFIG_FILE_SCAN_DIR, DEFAULT_SLASH, namelist[i]->d_name); + if (IS_SLASH(php_ini_scanned_path[php_ini_scanned_path_len - 1])) { + snprintf(ini_file, MAXPATHLEN, "%s%s", php_ini_scanned_path, namelist[i]->d_name); + } else { + snprintf(ini_file, MAXPATHLEN, "%s%c%s", php_ini_scanned_path, DEFAULT_SLASH, namelist[i]->d_name); + } if (VCWD_STAT(ini_file, &sb) == 0) { if (S_ISREG(sb.st_mode)) { if ((fh.handle.fp = VCWD_FOPEN(ini_file, "r"))) { @@ -555,6 +579,9 @@ int php_init_config(TSRMLS_D) } zend_llist_destroy(&scanned_ini_list); } + } else { + /* Make sure an empty php_ini_scanned_path ends up as NULL */ + php_ini_scanned_path = NULL; } if (sapi_module.ini_entries) { diff --git a/main/php_ini.h b/main/php_ini.h index 04c4a6518..0ac34646c 100644 --- a/main/php_ini.h +++ b/main/php_ini.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2008 The PHP Group | + | Copyright (c) 1997-2009 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_ini.h,v 1.45.2.3.2.4 2007/12/31 07:20:15 sebastian Exp $ */ +/* $Id: php_ini.h,v 1.45.2.3.2.5 2008/12/31 11:17:47 sebastian Exp $ */ #ifndef PHP_INI_H #define PHP_INI_H diff --git a/main/php_logos.c b/main/php_logos.c index 8e6c7b87d..02cde0676 100644 --- a/main/php_logos.c +++ b/main/php_logos.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2008 The PHP Group | + | Copyright (c) 1997-2009 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_logos.c,v 1.19.2.1.2.6 2007/12/31 07:20:15 sebastian Exp $ */ +/* $Id: php_logos.c,v 1.19.2.1.2.7 2008/12/31 11:17:47 sebastian Exp $ */ #include "php.h" #include "logos.h" diff --git a/main/php_logos.h b/main/php_logos.h index 83df6886e..b64c1d122 100644 --- a/main/php_logos.h +++ b/main/php_logos.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2008 The PHP Group | + | Copyright (c) 1997-2009 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_logos.h,v 1.9.2.1.2.4 2007/12/31 07:20:15 sebastian Exp $ */ +/* $Id: php_logos.h,v 1.9.2.1.2.5 2008/12/31 11:17:47 sebastian Exp $ */ #ifndef _PHP_LOGOS_H diff --git a/main/php_main.h b/main/php_main.h index 2443fd779..86a144bfb 100644 --- a/main/php_main.h +++ b/main/php_main.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2008 The PHP Group | + | Copyright (c) 1997-2009 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_main.h,v 1.34.2.1.2.3 2007/12/31 07:20:15 sebastian Exp $ */ +/* $Id: php_main.h,v 1.34.2.1.2.4 2008/12/31 11:17:47 sebastian Exp $ */ #ifndef PHP_MAIN_H #define PHP_MAIN_H diff --git a/main/php_memory_streams.h b/main/php_memory_streams.h index e40d3a176..ddd6aa74c 100644 --- a/main/php_memory_streams.h +++ b/main/php_memory_streams.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2008 The PHP Group | + | Copyright (c) 1997-2009 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_memory_streams.h,v 1.13.2.1.2.4 2007/12/31 07:20:15 sebastian Exp $ */ +/* $Id: php_memory_streams.h,v 1.13.2.1.2.5 2008/12/31 11:17:47 sebastian Exp $ */ #ifndef PHP_MEMORY_STREAM_H #define PHP_MEMORY_STREAM_H diff --git a/main/php_network.h b/main/php_network.h index 0d49d7dbb..dca01b64b 100644 --- a/main/php_network.h +++ b/main/php_network.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2008 The PHP Group | + | Copyright (c) 1997-2009 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_network.h,v 1.56.2.1.2.2 2007/12/31 07:20:15 sebastian Exp $ */ +/* $Id: php_network.h,v 1.56.2.1.2.4 2009/01/07 20:41:47 felipe Exp $ */ #ifndef _PHP_NETWORK_H #define _PHP_NETWORK_H @@ -53,6 +53,10 @@ # define ftruncate(a, b) chsize(a, b) #endif /* defined(PHP_WIN32) */ +#ifndef EWOULDBLOCK +# define EWOULDBLOCK EAGAIN +#endif + #ifdef PHP_WIN32 #define php_socket_errno() WSAGetLastError() #else diff --git a/main/php_open_temporary_file.c b/main/php_open_temporary_file.c index cde0c32f1..91a472d0c 100644 --- a/main/php_open_temporary_file.c +++ b/main/php_open_temporary_file.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2008 The PHP Group | + | Copyright (c) 1997-2009 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_open_temporary_file.c,v 1.34.2.1.2.11 2007/12/31 07:20:15 sebastian Exp $ */ +/* $Id: php_open_temporary_file.c,v 1.34.2.1.2.12 2008/12/31 11:17:47 sebastian Exp $ */ #include "php.h" diff --git a/main/php_open_temporary_file.h b/main/php_open_temporary_file.h index 72625d0de..b75646907 100644 --- a/main/php_open_temporary_file.h +++ b/main/php_open_temporary_file.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2008 The PHP Group | + | Copyright (c) 1997-2009 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_open_temporary_file.h,v 1.13.2.1.2.5 2007/12/31 07:20:15 sebastian Exp $ */ +/* $Id: php_open_temporary_file.h,v 1.13.2.1.2.6 2008/12/31 11:17:47 sebastian Exp $ */ #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 9468905f5..8aab62030 100644 --- a/main/php_output.h +++ b/main/php_output.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2008 The PHP Group | + | Copyright (c) 1997-2009 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_output.h,v 1.53.2.1.2.2 2007/12/31 07:20:15 sebastian Exp $ */ +/* $Id: php_output.h,v 1.53.2.1.2.3 2008/12/31 11:17:47 sebastian Exp $ */ #ifndef PHP_OUTPUT_H #define PHP_OUTPUT_H diff --git a/main/php_reentrancy.h b/main/php_reentrancy.h index a5d824475..2c15621c6 100644 --- a/main/php_reentrancy.h +++ b/main/php_reentrancy.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2008 The PHP Group | + | Copyright (c) 1997-2009 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_reentrancy.h,v 1.23.2.1.2.2 2007/12/31 07:20:15 sebastian Exp $ */ +/* $Id: php_reentrancy.h,v 1.23.2.1.2.3 2008/12/31 11:17:47 sebastian Exp $ */ #ifndef PHP_REENTRANCY_H #define PHP_REENTRANCY_H diff --git a/main/php_regex.h b/main/php_regex.h index aa3278a09..b00b101a7 100644 --- a/main/php_regex.h +++ b/main/php_regex.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2008 The PHP Group | + | Copyright (c) 1997-2009 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_regex.h,v 1.16.2.1.2.2 2007/12/31 07:20:15 sebastian Exp $ */ +/* $Id: php_regex.h,v 1.16.2.1.2.3 2008/12/31 11:17:47 sebastian Exp $ */ #ifndef PHP_REGEX_H #define PHP_REGEX_H diff --git a/main/php_scandir.c b/main/php_scandir.c index 233dfbee2..e832fa8fb 100644 --- a/main/php_scandir.c +++ b/main/php_scandir.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2008 The PHP Group | + | Copyright (c) 1997-2009 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_scandir.c,v 1.12.2.1.2.6 2007/12/31 07:20:15 sebastian Exp $ */ +/* $Id: php_scandir.c,v 1.12.2.1.2.8 2008/12/31 11:17:47 sebastian Exp $ */ #include "php.h" #include "php_scandir.h" @@ -50,14 +50,14 @@ #include <string.h> #endif -int php_alphasort(const struct dirent **a, const struct dirent **b) +PHPAPI int php_alphasort(const struct dirent **a, const struct dirent **b) { return strcoll((*a)->d_name,(*b)->d_name); } #endif /* HAVE_ALPHASORT */ #ifndef HAVE_SCANDIR -int php_scandir(const char *dirname, struct dirent **namelist[], int (*selector) (const struct dirent *entry), int (*compare) (const struct dirent **a, const struct dirent **b)) +PHPAPI int php_scandir(const char *dirname, struct dirent **namelist[], int (*selector) (const struct dirent *entry), int (*compare) (const struct dirent **a, const struct dirent **b)) { DIR *dirp = NULL; struct dirent **vector = NULL; diff --git a/main/php_scandir.h b/main/php_scandir.h index c7f5f2dee..eb097d1e6 100644 --- a/main/php_scandir.h +++ b/main/php_scandir.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2008 The PHP Group | + | Copyright (c) 1997-2009 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_scandir.h,v 1.12.2.1.2.2 2007/12/31 07:20:15 sebastian Exp $ */ +/* $Id: php_scandir.h,v 1.12.2.1.2.4 2008/12/31 11:17:47 sebastian Exp $ */ #ifndef PHP_SCANDIR_H #define PHP_SCANDIR_H @@ -42,13 +42,13 @@ #ifdef HAVE_SCANDIR #define php_scandir scandir #else -int php_scandir(const char *dirname, struct dirent **namelist[], int (*selector) (const struct dirent *entry), int (*compare) (const struct dirent **a, const struct dirent **b)); +PHPAPI int php_scandir(const char *dirname, struct dirent **namelist[], int (*selector) (const struct dirent *entry), int (*compare) (const struct dirent **a, const struct dirent **b)); #endif #ifdef HAVE_ALPHASORT #define php_alphasort alphasort #else -int php_alphasort(const struct dirent **a, const struct dirent **b); +PHPAPI int php_alphasort(const struct dirent **a, const struct dirent **b); #endif #endif /* PHP_SCANDIR_H */ diff --git a/main/php_sprintf.c b/main/php_sprintf.c index 8b083b976..d269d5dfc 100644 --- a/main/php_sprintf.c +++ b/main/php_sprintf.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2008 The PHP Group | + | Copyright (c) 1997-2009 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_sprintf.c,v 1.23.2.1.2.2 2007/12/31 07:20:15 sebastian Exp $ */ +/* $Id: php_sprintf.c,v 1.23.2.1.2.3 2008/12/31 11:17:47 sebastian Exp $ */ #include <stdio.h> #include <stdarg.h> diff --git a/main/php_streams.h b/main/php_streams.h index 009c786f7..d1a49e031 100755 --- a/main/php_streams.h +++ b/main/php_streams.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2008 The PHP Group | + | Copyright (c) 1997-2009 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_streams.h,v 1.103.2.1.2.5 2007/12/31 07:20:15 sebastian Exp $ */ +/* $Id: php_streams.h,v 1.103.2.1.2.9 2008/12/31 11:17:47 sebastian Exp $ */ #ifndef PHP_STREAMS_H #define PHP_STREAMS_H @@ -181,6 +181,10 @@ struct _php_stream_wrapper { #define PHP_STREAM_FLAG_NO_CLOSE 32 +#define PHP_STREAM_FLAG_IS_DIR 64 + +#define PHP_STREAM_FLAG_NO_FCLOSE 128 + struct _php_stream { php_stream_ops *ops; void *abstract; /* convenience pointer for abstraction */ diff --git a/main/php_syslog.h b/main/php_syslog.h index 832c610be..48933add4 100644 --- a/main/php_syslog.h +++ b/main/php_syslog.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2008 The PHP Group | + | Copyright (c) 1997-2009 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_syslog.h,v 1.12.2.1.2.2 2007/12/31 07:20:15 sebastian Exp $ */ +/* $Id: php_syslog.h,v 1.12.2.1.2.3 2008/12/31 11:17:47 sebastian Exp $ */ #ifndef PHP_SYSLOG_H #define PHP_SYSLOG_H diff --git a/main/php_ticks.c b/main/php_ticks.c index 3d8ed8655..21d10f2f0 100644 --- a/main/php_ticks.c +++ b/main/php_ticks.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2008 The PHP Group | + | Copyright (c) 1997-2009 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_ticks.c,v 1.20.2.1.2.2 2007/12/31 07:20:15 sebastian Exp $ */ +/* $Id: php_ticks.c,v 1.20.2.1.2.4 2008/12/31 11:17:47 sebastian Exp $ */ #include "php.h" #include "php_ticks.h" @@ -27,6 +27,11 @@ int php_startup_ticks(TSRMLS_D) return SUCCESS; } +void php_deactivate_ticks(TSRMLS_D) +{ + zend_llist_clean(&PG(tick_functions)); +} + void php_shutdown_ticks(TSRMLS_D) { zend_llist_destroy(&PG(tick_functions)); diff --git a/main/php_ticks.h b/main/php_ticks.h index caad0495d..a51e6d9ad 100644 --- a/main/php_ticks.h +++ b/main/php_ticks.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2008 The PHP Group | + | Copyright (c) 1997-2009 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 | @@ -16,12 +16,13 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_ticks.h,v 1.14.2.1.2.2 2007/12/31 07:20:15 sebastian Exp $ */ +/* $Id: php_ticks.h,v 1.14.2.1.2.4 2008/12/31 11:17:47 sebastian Exp $ */ #ifndef PHP_TICKS_H #define PHP_TICKS_H int php_startup_ticks(TSRMLS_D); +void php_deactivate_ticks(TSRMLS_D); void php_shutdown_ticks(TSRMLS_D); void php_run_ticks(int count); diff --git a/main/php_variables.c b/main/php_variables.c index 1064951d9..2f3098c8b 100644 --- a/main/php_variables.c +++ b/main/php_variables.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2008 The PHP Group | + | Copyright (c) 1997-2009 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_variables.c,v 1.104.2.10.2.12 2007/12/31 07:20:15 sebastian Exp $ */ +/* $Id: php_variables.c,v 1.104.2.10.2.15 2008/12/31 11:17:47 sebastian Exp $ */ #include <stdio.h> #include "php.h" @@ -57,17 +57,18 @@ PHPAPI void php_register_variable_safe(char *var, char *strval, int str_len, zva php_register_variable_ex(var, &new_entry, track_vars_array TSRMLS_CC); } -PHPAPI void php_register_variable_ex(char *var, zval *val, zval *track_vars_array TSRMLS_DC) +PHPAPI void php_register_variable_ex(char *var_name, zval *val, zval *track_vars_array TSRMLS_DC) { char *p = NULL; char *ip; /* index pointer */ char *index, *escaped_index = NULL; + char *var, *var_orig; int var_len, index_len; zval *gpc_element, **gpc_element_p; zend_bool is_array = 0; HashTable *symtable1 = NULL; - assert(var != NULL); + assert(var_name != NULL); if (track_vars_array) { symtable1 = Z_ARRVAL_P(track_vars_array); @@ -84,6 +85,8 @@ PHPAPI void php_register_variable_ex(char *var, zval *val, zval *track_vars_arra * Prepare variable name */ + var_orig = estrdup(var_name); + var = var_orig; /* ignore leading spaces in the variable name */ while (*var && *var==' ') { var++; @@ -104,6 +107,7 @@ PHPAPI void php_register_variable_ex(char *var, zval *val, zval *track_vars_arra if (var_len==0) { /* empty variable name, or variable name with a space in it */ zval_dtor(val); + efree(var_orig); return; } @@ -112,6 +116,7 @@ PHPAPI void php_register_variable_ex(char *var, zval *val, zval *track_vars_arra var_len == sizeof("GLOBALS")-1 && !memcmp(var, "GLOBALS", sizeof("GLOBALS")-1)) { zval_dtor(val); + efree(var_orig); return; } @@ -142,6 +147,7 @@ PHPAPI void php_register_variable_ex(char *var, zval *val, zval *track_vars_arra if (!PG(display_errors)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Input variable nesting level exceeded %ld. To increase the limit change max_input_nesting_level in php.ini.", PG(max_input_nesting_level)); } + efree(var_orig); return; } @@ -233,6 +239,7 @@ plain_var: } } } + efree(var_orig); } SAPI_API SAPI_POST_HANDLER_FUNC(php_std_post_handler) diff --git a/main/php_variables.h b/main/php_variables.h index e3525fa6a..6b160281b 100644 --- a/main/php_variables.h +++ b/main/php_variables.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2008 The PHP Group | + | Copyright (c) 1997-2009 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_variables.h,v 1.22.2.3.2.3 2007/12/31 07:20:15 sebastian Exp $ */ +/* $Id: php_variables.h,v 1.22.2.3.2.4 2008/12/31 11:17:47 sebastian Exp $ */ #ifndef PHP_VARIABLES_H #define PHP_VARIABLES_H diff --git a/main/php_version.h b/main/php_version.h index aa8b8c237..dfb0a4efa 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 2 -#define PHP_RELEASE_VERSION 6 +#define PHP_RELEASE_VERSION 9 #define PHP_EXTRA_VERSION "" -#define PHP_VERSION "5.2.6" -#define PHP_VERSION_ID 50206 +#define PHP_VERSION "5.2.9" +#define PHP_VERSION_ID 50209 diff --git a/main/reentrancy.c b/main/reentrancy.c index b4dee499f..b514b5112 100644 --- a/main/reentrancy.c +++ b/main/reentrancy.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2008 The PHP Group | + | Copyright (c) 1997-2009 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: reentrancy.c,v 1.43.2.1.2.3 2007/12/31 07:20:15 sebastian Exp $ */ +/* $Id: reentrancy.c,v 1.43.2.1.2.4 2008/12/31 11:17:47 sebastian Exp $ */ #include <sys/types.h> #include <string.h> diff --git a/main/rfc1867.c b/main/rfc1867.c index 0fa20246e..1305f8929 100644 --- a/main/rfc1867.c +++ b/main/rfc1867.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2008 The PHP Group | + | Copyright (c) 1997-2009 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: rfc1867.c,v 1.173.2.1.2.11 2008/03/26 12:59:42 tony2001 Exp $ */ +/* $Id: rfc1867.c,v 1.173.2.1.2.15 2008/12/31 11:17:47 sebastian Exp $ */ /* * This product includes software developed by the Apache Group @@ -788,7 +788,6 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler) int str_len = 0, num_vars = 0, num_vars_max = 2*10, *len_list = NULL; char **val_list = NULL; #endif - zend_bool magic_quotes_gpc; multipart_buffer *mbuff; zval *array_ptr = (zval *) arg; int fd=-1; @@ -925,7 +924,7 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler) if (sapi_module.input_filter(PARSE_POST, param, &value, value_len, &new_val_len TSRMLS_CC)) { if (php_rfc1867_callback != NULL) { multipart_event_formdata event_formdata; - size_t newlength = 0; + size_t newlength = new_val_len; event_formdata.post_bytes_processed = SG(read_post_bytes); event_formdata.name = param; @@ -1077,12 +1076,12 @@ SAPI_API SAPI_POST_HANDLER_FUNC(rfc1867_post_handler) } - if (PG(upload_max_filesize) > 0 && total_bytes > PG(upload_max_filesize)) { + if (PG(upload_max_filesize) > 0 && (total_bytes+blen) > PG(upload_max_filesize)) { #if DEBUG_FILE_UPLOAD sapi_module.sapi_error(E_NOTICE, "upload_max_filesize of %ld bytes exceeded - file [%s=%s] not saved", PG(upload_max_filesize), param, filename); #endif cancel_upload = UPLOAD_ERROR_A; - } else if (max_file_size && (total_bytes > max_file_size)) { + } else if (max_file_size && ((total_bytes+blen) > max_file_size)) { #if DEBUG_FILE_UPLOAD sapi_module.sapi_error(E_NOTICE, "MAX_FILE_SIZE of %ld bytes exceeded - file [%s=%s] not saved", max_file_size, param, filename); #endif @@ -1279,26 +1278,30 @@ filedone: } s = ""; - /* Initialize variables */ - add_protected_variable(param TSRMLS_CC); + { + /* store temp_filename as-is (without magic_quotes_gpc-ing it, in case upload_tmp_dir + * contains escapeable characters. escape only the variable name.) */ + zval zfilename; - magic_quotes_gpc = PG(magic_quotes_gpc); - PG(magic_quotes_gpc) = 0; - /* if param is of form xxx[.*] this will cut it to xxx */ - if (!is_anonymous) { - safe_php_register_variable(param, temp_filename, strlen(temp_filename), NULL, 1 TSRMLS_CC); - } - - /* Add $foo[tmp_name] */ - if (is_arr_upload) { - snprintf(lbuf, llen, "%s[tmp_name][%s]", abuf, array_index); - } else { - snprintf(lbuf, llen, "%s[tmp_name]", param); - } - add_protected_variable(lbuf TSRMLS_CC); - register_http_post_files_variable(lbuf, temp_filename, http_post_files, 1 TSRMLS_CC); + /* Initialize variables */ + add_protected_variable(param TSRMLS_CC); - PG(magic_quotes_gpc) = magic_quotes_gpc; + /* if param is of form xxx[.*] this will cut it to xxx */ + if (!is_anonymous) { + ZVAL_STRING(&zfilename, temp_filename, 1); + safe_php_register_variable_ex(param, &zfilename, NULL, 1 TSRMLS_CC); + } + + /* Add $foo[tmp_name] */ + if (is_arr_upload) { + snprintf(lbuf, llen, "%s[tmp_name][%s]", abuf, array_index); + } else { + snprintf(lbuf, llen, "%s[tmp_name]", param); + } + add_protected_variable(lbuf TSRMLS_CC); + ZVAL_STRING(&zfilename, temp_filename, 1); + register_http_post_files_variable_ex(lbuf, &zfilename, http_post_files, 1 TSRMLS_CC); + } { zval file_size, error_type; diff --git a/main/rfc1867.h b/main/rfc1867.h index 55a0f8319..e32f5160d 100644 --- a/main/rfc1867.h +++ b/main/rfc1867.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2008 The PHP Group | + | Copyright (c) 1997-2009 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: rfc1867.h,v 1.13.2.1.2.4 2007/12/31 07:20:15 sebastian Exp $ */ +/* $Id: rfc1867.h,v 1.13.2.1.2.5 2008/12/31 11:17:48 sebastian Exp $ */ #ifndef RFC1867_H #define RFC1867_H diff --git a/main/safe_mode.c b/main/safe_mode.c index 74188a895..4928399ae 100644 --- a/main/safe_mode.c +++ b/main/safe_mode.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2008 The PHP Group | + | Copyright (c) 1997-2009 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: safe_mode.c,v 1.62.2.1.2.15 2007/12/31 07:20:15 sebastian Exp $ */ +/* $Id: safe_mode.c,v 1.62.2.1.2.18 2008/12/31 11:17:48 sebastian Exp $ */ #include "php.h" @@ -52,7 +52,6 @@ PHPAPI int php_checkuid_ex(const char *filename, const char *fopen_mode, int mod long uid=0L, gid=0L, duid=0L, dgid=0L; char path[MAXPATHLEN]; char *s, filenamecopy[MAXPATHLEN]; - php_stream_wrapper *wrapper = NULL; TSRMLS_FETCH(); path[0] = '\0'; @@ -73,14 +72,6 @@ PHPAPI int php_checkuid_ex(const char *filename, const char *fopen_mode, int mod mode = CHECKUID_CHECK_FILE_AND_DIR; } } - - /* - * If given filepath is a URL, allow - safe mode stuff - * related to URL's is checked in individual functions - */ - wrapper = php_stream_locate_url_wrapper(filename, NULL, STREAM_LOCATE_WRAPPERS_ONLY TSRMLS_CC); - if (wrapper != NULL) - return 1; /* First we see if the file is owned by the same user... * If that fails, passthrough and check directory... diff --git a/main/safe_mode.h b/main/safe_mode.h index 497fc2ecf..02f1b836f 100644 --- a/main/safe_mode.h +++ b/main/safe_mode.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2008 The PHP Group | + | Copyright (c) 1997-2009 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: safe_mode.h,v 1.13.2.1.2.3 2007/12/31 07:20:15 sebastian Exp $ */ +/* $Id: safe_mode.h,v 1.13.2.1.2.4 2008/12/31 11:17:48 sebastian Exp $ */ #ifndef SAFE_MODE_H #define SAFE_MODE_H diff --git a/main/snprintf.c b/main/snprintf.c index 67ecd3a28..f9150caf5 100644 --- a/main/snprintf.c +++ b/main/snprintf.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2008 The PHP Group | + | Copyright (c) 1997-2009 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: snprintf.c,v 1.37.2.4.2.16 2007/12/31 07:20:15 sebastian Exp $ */ +/* $Id: snprintf.c,v 1.37.2.4.2.18 2008/12/31 11:17:48 sebastian Exp $ */ #include "php.h" @@ -155,10 +155,7 @@ PHPAPI char *php_gcvt(double value, int ndigit, char dec_point, char exponent, c *dst++ = '-'; } - for (i = 0; i < ndigit && digits[i] != '\0'; i++); - - if ((decpt >= 0 && decpt - i > 4) - || (decpt < 0 && decpt < -3)) { /* use E-style */ + if ((decpt >= 0 && decpt > ndigit) || decpt < -3) { /* use E-style */ /* exponential format (e.g. 1.2345e+13) */ if (--decpt < 0) { sign = 1; diff --git a/main/snprintf.h b/main/snprintf.h index 30833d195..35b09a8b9 100644 --- a/main/snprintf.h +++ b/main/snprintf.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2008 The PHP Group | + | Copyright (c) 1997-2009 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: snprintf.h,v 1.32.2.3.2.6 2007/12/31 07:20:15 sebastian Exp $ */ +/* $Id: snprintf.h,v 1.32.2.3.2.7 2008/12/31 11:17:48 sebastian Exp $ */ /* diff --git a/main/spprintf.c b/main/spprintf.c index bba3dab3a..3c4235f4f 100644 --- a/main/spprintf.c +++ b/main/spprintf.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2008 The PHP Group | + | Copyright (c) 1997-2009 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: spprintf.c,v 1.25.2.2.2.12 2007/12/31 07:20:15 sebastian Exp $ */ +/* $Id: spprintf.c,v 1.25.2.2.2.15 2009/02/04 15:03:12 iliaa Exp $ */ /* This is the spprintf implementation. * It has emerged from apache snprintf. See original header: @@ -180,6 +180,13 @@ /* }}} */ +#if !HAVE_STRNLEN +static size_t strnlen(const char *s, size_t maxlen) { + char *r = memchr(s, '\0', maxlen); + return r ? r-s : maxlen; +} +#endif + /* * Do format conversion placing the output in buffer */ @@ -547,9 +554,11 @@ static void xbuf_format_converter(smart_str *xbuf, const char *fmt, va_list ap) case 'v': s = va_arg(ap, char *); if (s != NULL) { - s_len = strlen(s); - if (adjust_precision && precision < s_len) - s_len = precision; + if (!adjust_precision) { + s_len = strlen(s); + } else { + s_len = strnlen(s, precision); + } } else { s = S_NULL; s_len = S_NULL_LEN; diff --git a/main/spprintf.h b/main/spprintf.h index af8dcbce9..d63816e00 100644 --- a/main/spprintf.h +++ b/main/spprintf.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2008 The PHP Group | + | Copyright (c) 1997-2009 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: spprintf.h,v 1.11.2.1.2.2 2007/12/31 07:20:15 sebastian Exp $ */ +/* $Id: spprintf.h,v 1.11.2.1.2.3 2008/12/31 11:17:48 sebastian Exp $ */ /* diff --git a/main/streams/cast.c b/main/streams/cast.c index e2c65d8a0..5694300b4 100644 --- a/main/streams/cast.c +++ b/main/streams/cast.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2008 The PHP Group | + | Copyright (c) 1997-2009 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: cast.c,v 1.12.2.1.2.2 2007/12/31 07:20:15 sebastian Exp $ */ +/* $Id: cast.c,v 1.12.2.1.2.3 2008/12/31 11:17:48 sebastian Exp $ */ #define _GNU_SOURCE #include "php.h" diff --git a/main/streams/filter.c b/main/streams/filter.c index 334fd81d8..b74d2def0 100644 --- a/main/streams/filter.c +++ b/main/streams/filter.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2008 The PHP Group | + | Copyright (c) 1997-2009 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: filter.c,v 1.17.2.3.2.11 2007/12/31 07:20:15 sebastian Exp $ */ +/* $Id: filter.c,v 1.17.2.3.2.14 2009/01/08 17:03:42 lbarnaud Exp $ */ #include "php.h" #include "php_globals.h" @@ -313,7 +313,7 @@ PHPAPI void php_stream_filter_free(php_stream_filter *filter TSRMLS_DC) pefree(filter, filter->is_persistent); } -PHPAPI void _php_stream_filter_prepend(php_stream_filter_chain *chain, php_stream_filter *filter TSRMLS_DC) +PHPAPI int php_stream_filter_prepend_ex(php_stream_filter_chain *chain, php_stream_filter *filter TSRMLS_DC) { filter->next = chain->head; filter->prev = NULL; @@ -325,9 +325,16 @@ PHPAPI void _php_stream_filter_prepend(php_stream_filter_chain *chain, php_strea } chain->head = filter; filter->chain = chain; + + return SUCCESS; } -PHPAPI void _php_stream_filter_append(php_stream_filter_chain *chain, php_stream_filter *filter TSRMLS_DC) +PHPAPI void _php_stream_filter_prepend(php_stream_filter_chain *chain, php_stream_filter *filter TSRMLS_DC) +{ + php_stream_filter_prepend_ex(chain, filter TSRMLS_CC); +} + +PHPAPI int php_stream_filter_append_ex(php_stream_filter_chain *chain, php_stream_filter *filter TSRMLS_DC) { php_stream *stream = chain->stream; @@ -349,7 +356,7 @@ PHPAPI void _php_stream_filter_append(php_stream_filter_chain *chain, php_stream php_stream_bucket *bucket; size_t consumed = 0; - bucket = php_stream_bucket_new(stream, stream->readbuf + stream->readpos, stream->writepos - stream->readpos, 0, 0 TSRMLS_CC); + bucket = php_stream_bucket_new(stream, (char*) stream->readbuf + stream->readpos, stream->writepos - stream->readpos, 0, 0 TSRMLS_CC); php_stream_bucket_append(brig_inp, bucket TSRMLS_CC); status = filter->fops->filter(stream, filter, brig_inp, brig_outp, &consumed, PSFS_FLAG_NORMAL TSRMLS_CC); @@ -360,19 +367,18 @@ PHPAPI void _php_stream_filter_append(php_stream_filter_chain *chain, php_stream switch (status) { case PSFS_ERR_FATAL: - /* If this first cycle simply fails then there's something wrong with the filter. - Pull the filter off the chain and leave the read buffer alone. */ - if (chain->head == filter) { - chain->head = NULL; - chain->tail = NULL; - } else { - filter->prev->next = NULL; - chain->tail = filter->prev; + while (brig_in.head) { + bucket = brig_in.head; + php_stream_bucket_unlink(bucket TSRMLS_CC); + php_stream_bucket_delref(bucket TSRMLS_CC); } - php_stream_bucket_unlink(bucket TSRMLS_CC); - php_stream_bucket_delref(bucket TSRMLS_CC); - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Filter failed to process pre-buffered data. Not adding to filterchain."); - break; + while (brig_out.head) { + bucket = brig_out.head; + php_stream_bucket_unlink(bucket TSRMLS_CC); + php_stream_bucket_delref(bucket TSRMLS_CC); + } + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Filter failed to process pre-buffered data"); + return FAILURE; case PSFS_FEED_ME: /* We don't actually need data yet, leave this filter in a feed me state until data is needed. @@ -381,15 +387,12 @@ PHPAPI void _php_stream_filter_append(php_stream_filter_chain *chain, php_stream stream->writepos = 0; break; case PSFS_PASS_ON: - /* Put any filtered data onto the readbuffer stack. - Previously read data has been at least partially consumed. */ - stream->readpos += consumed; - - if (stream->writepos == stream->readpos) { - /* Entirely consumed */ - stream->writepos = 0; - stream->readpos = 0; - } + /* If any data is consumed, we cannot rely upon the existing read buffer, + as the filtered data must replace the existing data, so invalidate the cache */ + /* note that changes here should be reflected in + main/streams/streams.c::php_stream_fill_read_buffer */ + stream->writepos = 0; + stream->readpos = 0; while (brig_outp->head) { bucket = brig_outp->head; @@ -409,6 +412,20 @@ PHPAPI void _php_stream_filter_append(php_stream_filter_chain *chain, php_stream } } + return SUCCESS; +} + +PHPAPI void _php_stream_filter_append(php_stream_filter_chain *chain, php_stream_filter *filter TSRMLS_DC) +{ + if (php_stream_filter_append_ex(chain, filter TSRMLS_CC) != SUCCESS) { + if (chain->head == filter) { + chain->head = NULL; + chain->tail = NULL; + } else { + filter->prev->next = NULL; + chain->tail = filter->prev; + } + } } PHPAPI int _php_stream_filter_flush(php_stream_filter *filter, int finish TSRMLS_DC) diff --git a/main/streams/memory.c b/main/streams/memory.c index bbd900734..0c1e34bbf 100644 --- a/main/streams/memory.c +++ b/main/streams/memory.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2008 The PHP Group | + | Copyright (c) 1997-2009 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: memory.c,v 1.8.2.6.2.19 2008/03/15 10:28:53 felipe Exp $ */ +/* $Id: memory.c,v 1.8.2.6.2.20 2008/12/31 11:17:48 sebastian Exp $ */ #define _GNU_SOURCE #include "php.h" diff --git a/main/streams/mmap.c b/main/streams/mmap.c index 7f7a88ec4..a70bf5805 100644 --- a/main/streams/mmap.c +++ b/main/streams/mmap.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2008 The PHP Group | + | Copyright (c) 1997-2009 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: mmap.c,v 1.8.2.1.2.2 2007/12/31 07:20:15 sebastian Exp $ */ +/* $Id: mmap.c,v 1.8.2.1.2.3 2008/12/31 11:17:48 sebastian Exp $ */ /* 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 f1619a6ae..995d4156c 100644 --- a/main/streams/php_stream_context.h +++ b/main/streams/php_stream_context.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2008 The PHP Group | + | Copyright (c) 1997-2009 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_stream_context.h,v 1.11.2.1.2.2 2007/12/31 07:20:15 sebastian Exp $ */ +/* $Id: php_stream_context.h,v 1.11.2.1.2.3 2008/12/31 11:17:48 sebastian Exp $ */ /* 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 0870e64c2..d4030d62e 100644 --- a/main/streams/php_stream_filter_api.h +++ b/main/streams/php_stream_filter_api.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2008 The PHP Group | + | Copyright (c) 1997-2009 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 | @@ -19,7 +19,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_stream_filter_api.h,v 1.13.2.1.2.3 2007/12/31 07:20:15 sebastian Exp $ */ +/* $Id: php_stream_filter_api.h,v 1.13.2.1.2.5 2009/01/08 17:03:42 lbarnaud Exp $ */ /* The filter API works on the principle of "Bucket-Brigades". This is * partially inspired by the Apache 2 method of doing things, although @@ -125,7 +125,9 @@ struct _php_stream_filter { /* stack filter onto a stream */ BEGIN_EXTERN_C() PHPAPI void _php_stream_filter_prepend(php_stream_filter_chain *chain, php_stream_filter *filter TSRMLS_DC); +PHPAPI int php_stream_filter_prepend_ex(php_stream_filter_chain *chain, php_stream_filter *filter TSRMLS_DC); PHPAPI void _php_stream_filter_append(php_stream_filter_chain *chain, php_stream_filter *filter TSRMLS_DC); +PHPAPI int php_stream_filter_append_ex(php_stream_filter_chain *chain, php_stream_filter *filter TSRMLS_DC); PHPAPI int _php_stream_filter_flush(php_stream_filter *filter, int finish TSRMLS_DC); PHPAPI php_stream_filter *php_stream_filter_remove(php_stream_filter *filter, int call_dtor TSRMLS_DC); PHPAPI void php_stream_filter_free(php_stream_filter *filter TSRMLS_DC); diff --git a/main/streams/php_stream_mmap.h b/main/streams/php_stream_mmap.h index 50f3bd815..1b3ad6d6b 100644 --- a/main/streams/php_stream_mmap.h +++ b/main/streams/php_stream_mmap.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2008 The PHP Group | + | Copyright (c) 1997-2009 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_stream_mmap.h,v 1.5.2.1.2.2 2007/12/31 07:20:15 sebastian Exp $ */ +/* $Id: php_stream_mmap.h,v 1.5.2.1.2.3 2008/12/31 11:17:48 sebastian Exp $ */ /* 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 eb7da457f..262f3f5d0 100644 --- a/main/streams/php_stream_plain_wrapper.h +++ b/main/streams/php_stream_plain_wrapper.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2008 The PHP Group | + | Copyright (c) 1997-2009 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_stream_plain_wrapper.h,v 1.7.2.2.2.2 2007/12/31 07:20:15 sebastian Exp $ */ +/* $Id: php_stream_plain_wrapper.h,v 1.7.2.2.2.3 2008/12/31 11:17:48 sebastian Exp $ */ /* definitions for the plain files wrapper */ diff --git a/main/streams/php_stream_transport.h b/main/streams/php_stream_transport.h index 12300ad72..7bafbbd26 100644 --- a/main/streams/php_stream_transport.h +++ b/main/streams/php_stream_transport.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2008 The PHP Group | + | Copyright (c) 1997-2009 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_stream_transport.h,v 1.10.2.1.2.5 2007/12/31 07:20:15 sebastian Exp $ */ +/* $Id: php_stream_transport.h,v 1.10.2.1.2.6 2008/12/31 11:17:48 sebastian Exp $ */ #if HAVE_SYS_SOCKET_H # include <sys/socket.h> diff --git a/main/streams/php_stream_userspace.h b/main/streams/php_stream_userspace.h index 9277529f5..3016c154d 100644 --- a/main/streams/php_stream_userspace.h +++ b/main/streams/php_stream_userspace.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2008 The PHP Group | + | Copyright (c) 1997-2009 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_stream_userspace.h,v 1.5.2.1.2.2 2007/12/31 07:20:15 sebastian Exp $ */ +/* $Id: php_stream_userspace.h,v 1.5.2.1.2.3 2008/12/31 11:17:48 sebastian Exp $ */ /* for user-space streams */ diff --git a/main/streams/php_streams_int.h b/main/streams/php_streams_int.h index b24555bb8..4b9826818 100644 --- a/main/streams/php_streams_int.h +++ b/main/streams/php_streams_int.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2008 The PHP Group | + | Copyright (c) 1997-2009 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_streams_int.h,v 1.7.2.2.2.3 2007/12/31 07:20:15 sebastian Exp $ */ +/* $Id: php_streams_int.h,v 1.7.2.2.2.4 2008/12/31 11:17:48 sebastian Exp $ */ #if ZEND_DEBUG diff --git a/main/streams/plain_wrapper.c b/main/streams/plain_wrapper.c index af665b716..d70f5f98b 100644 --- a/main/streams/plain_wrapper.c +++ b/main/streams/plain_wrapper.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2008 The PHP Group | + | Copyright (c) 1997-2009 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: plain_wrapper.c,v 1.52.2.6.2.27 2007/12/31 07:20:15 sebastian Exp $ */ +/* $Id: plain_wrapper.c,v 1.52.2.6.2.32 2009/02/10 16:14:27 iliaa Exp $ */ #include "php.h" #include "php_globals.h" @@ -242,6 +242,7 @@ PHPAPI php_stream *_php_stream_fopen_from_fd(int fd, const char *mode, const cha #ifdef ESPIPE if (stream->position == (off_t)-1 && errno == ESPIPE) { stream->position = 0; + stream->flags |= PHP_STREAM_FLAG_NO_SEEK; self->is_pipe = 1; } #endif @@ -1323,7 +1324,9 @@ not_relative_path: /* getcwd() will return always return [DRIVE_LETTER]:/) on windows. */ *(cwd+3) = '\0'; - snprintf(trypath, MAXPATHLEN, "%s%s", cwd, filename); + if (snprintf(trypath, MAXPATHLEN, "%s%s", cwd, filename) >= MAXPATHLEN) { + php_error_docref(NULL TSRMLS_CC, E_NOTICE, "%s/%s path was truncated to %d", cwd, filename, MAXPATHLEN); + } free(cwd); @@ -1384,7 +1387,9 @@ not_relative_path: if (*ptr == '\0') { goto stream_skip; } - snprintf(trypath, MAXPATHLEN, "%s/%s", ptr, filename); + if (snprintf(trypath, MAXPATHLEN, "%s/%s", ptr, filename) >= MAXPATHLEN) { + php_error_docref(NULL TSRMLS_CC, E_NOTICE, "%s/%s path was truncated to %d", ptr, filename, MAXPATHLEN); + } if (((options & STREAM_DISABLE_OPEN_BASEDIR) == 0) && php_check_open_basedir_ex(trypath, 0 TSRMLS_CC)) { goto stream_skip; diff --git a/main/streams/streams.c b/main/streams/streams.c index 2352bfbcc..ddd7a2c7e 100755 --- a/main/streams/streams.c +++ b/main/streams/streams.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2008 The PHP Group | + | Copyright (c) 1997-2009 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 | @@ -19,7 +19,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: streams.c,v 1.82.2.6.2.22 2008/03/24 16:28:56 tony2001 Exp $ */ +/* $Id: streams.c,v 1.82.2.6.2.33 2009/01/08 19:21:25 felipe Exp $ */ #define _GNU_SOURCE #include "php.h" @@ -164,7 +164,11 @@ void php_stream_display_wrapper_errors(php_stream_wrapper *wrapper, const char * free_msg = 1; } else { - msg = strerror(errno); + if (wrapper == &php_plain_files_wrapper) { + msg = strerror(errno); + } else { + msg = "operation failed"; + } } } else { msg = "no suitable wrapper could be found"; @@ -434,6 +438,10 @@ static void php_stream_fill_read_buffer(php_stream *stream, size_t size TSRMLS_D php_stream_bucket_brigade brig_in = { NULL, NULL }, brig_out = { NULL, NULL }; php_stream_bucket_brigade *brig_inp = &brig_in, *brig_outp = &brig_out, *brig_swap; + /* Invalidate the existing cache, otherwise reads can fail, see note in + main/streams/filter.c::_php_stream_filter_append */ + stream->writepos = stream->readpos = 0; + /* allocate a buffer for reading chunks */ chunk_buf = emalloc(stream->chunk_size); @@ -523,16 +531,16 @@ static void php_stream_fill_read_buffer(php_stream *stream, size_t size TSRMLS_D efree(chunk_buf); } else { + /* reduce buffer memory consumption if possible, to avoid a realloc */ + if (stream->readbuf && stream->readbuflen - stream->writepos < stream->chunk_size) { + memmove(stream->readbuf, stream->readbuf + stream->readpos, stream->readbuflen - stream->readpos); + stream->writepos -= stream->readpos; + stream->readpos = 0; + } /* is there enough data in the buffer ? */ - if (stream->writepos - stream->readpos < (off_t)size) { + while (stream->writepos - stream->readpos < (off_t)size) { size_t justread = 0; - - /* reduce buffer memory consumption if possible, to avoid a realloc */ - if (stream->readbuf && stream->readbuflen - stream->writepos < stream->chunk_size) { - memmove(stream->readbuf, stream->readbuf + stream->readpos, stream->readbuflen - stream->readpos); - stream->writepos -= stream->readpos; - stream->readpos = 0; - } + size_t toread; /* grow the buffer if required * TODO: this can fail for persistent streams */ @@ -542,13 +550,17 @@ static void php_stream_fill_read_buffer(php_stream *stream, size_t size TSRMLS_D stream->is_persistent); } + toread = stream->readbuflen - stream->writepos; justread = stream->ops->read(stream, stream->readbuf + stream->writepos, - stream->readbuflen - stream->writepos + toread TSRMLS_CC); if (justread != (size_t)-1) { stream->writepos += justread; } + if (stream->eof || justread != toread) { + break; + } } } } @@ -869,6 +881,9 @@ PHPAPI char *php_stream_get_record(php_stream *stream, size_t maxlen, size_t *re } if (!e) { + if (seek_len < maxlen && !stream->eof) { + return NULL; + } toread = maxlen; } else { toread = e - (char *) stream->readbuf - stream->readpos; @@ -1219,7 +1234,7 @@ PHPAPI size_t _php_stream_copy_to_mem(php_stream *src, char **buf, size_t maxlen if (maxlen > 0) { ptr = *buf = pemalloc_rel_orig(maxlen + 1, persistent); - while ((len < maxlen) & !php_stream_eof(src)) { + while ((len < maxlen) && !php_stream_eof(src)) { ret = php_stream_read(src, ptr, maxlen - len); len += ret; ptr += ret; @@ -1503,7 +1518,7 @@ PHPAPI php_stream_wrapper *php_stream_locate_url_wrapper(const char *path, char n++; } - if ((*p == ':') && (n > 1) && (!strncmp("//", p+1, 2) || !memcmp("data", path, 4))) { + if ((*p == ':') && (n > 1) && (!strncmp("//", p+1, 2) || (n == 4 && !memcmp("data:", path, 5)))) { protocol = path; } else if (n == 5 && strncasecmp(path, "zlib:", 5) == 0) { /* BC with older php scripts and zlib wrapper */ @@ -1706,7 +1721,7 @@ PHPAPI php_stream *_php_stream_opendir(char *path, int options, if (stream) { stream->wrapper = wrapper; - stream->flags |= PHP_STREAM_FLAG_NO_BUFFER; + stream->flags |= PHP_STREAM_FLAG_NO_BUFFER | PHP_STREAM_FLAG_IS_DIR; } } else if (wrapper) { php_stream_wrapper_log_error(wrapper, options ^ REPORT_ERRORS TSRMLS_CC, "not implemented"); @@ -1748,6 +1763,7 @@ PHPAPI php_stream *_php_stream_open_wrapper_ex(char *path, char *mode, int optio } if (!path || !*path) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Filename cannot be empty"); return NULL; } diff --git a/main/streams/transports.c b/main/streams/transports.c index 9c6aa00d9..fb337a2c5 100644 --- a/main/streams/transports.c +++ b/main/streams/transports.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2008 The PHP Group | + | Copyright (c) 1997-2009 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: transports.c,v 1.16.2.1.2.5 2007/12/31 07:20:15 sebastian Exp $ */ +/* $Id: transports.c,v 1.16.2.1.2.6 2008/12/31 11:17:48 sebastian Exp $ */ #include "php.h" #include "php_streams_int.h" diff --git a/main/streams/userspace.c b/main/streams/userspace.c index ae18d05b0..16d433c68 100644 --- a/main/streams/userspace.c +++ b/main/streams/userspace.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2008 The PHP Group | + | Copyright (c) 1997-2009 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -17,11 +17,15 @@ +----------------------------------------------------------------------+ */ -/* $Id: userspace.c,v 1.31.2.3.2.8 2007/12/31 07:20:15 sebastian Exp $ */ +/* $Id: userspace.c,v 1.31.2.3.2.10 2008/12/31 11:17:48 sebastian Exp $ */ #include "php.h" #include "php_globals.h" #include "ext/standard/file.h" +#include "ext/standard/flock_compat.h" +#ifdef HAVE_SYS_FILE_H +#include <sys/file.h> +#endif static int le_protocols; @@ -908,7 +912,23 @@ static int php_userstreamop_set_option(php_stream *stream, int option, int value case PHP_STREAM_OPTION_LOCKING: MAKE_STD_ZVAL(zvalue); - ZVAL_LONG(zvalue, value); + ZVAL_LONG(zvalue, 0); + + if (value & LOCK_NB) { + Z_LVAL_P(zvalue) |= PHP_LOCK_NB; + } + switch(value & ~LOCK_NB) { + case LOCK_SH: + Z_LVAL_P(zvalue) |= PHP_LOCK_SH; + break; + case LOCK_EX: + Z_LVAL_P(zvalue) |= PHP_LOCK_EX; + break; + case LOCK_UN: + Z_LVAL_P(zvalue) |= PHP_LOCK_UN; + break; + } + args[0] = &zvalue; /* TODO wouldblock */ diff --git a/main/streams/xp_socket.c b/main/streams/xp_socket.c index 0f6842aa8..5e7e41ada 100644 --- a/main/streams/xp_socket.c +++ b/main/streams/xp_socket.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2008 The PHP Group | + | Copyright (c) 1997-2009 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: xp_socket.c,v 1.33.2.2.2.9 2008/03/10 20:09:22 andrey Exp $ */ +/* $Id: xp_socket.c,v 1.33.2.2.2.15 2009/02/08 16:54:43 iliaa Exp $ */ #include "php.h" #include "ext/standard/file.h" @@ -281,7 +281,7 @@ static int php_sockop_set_option(php_stream *stream, int option, int value, void if (sock->socket == -1) { alive = 0; } else if (php_pollfd_for(sock->socket, PHP_POLLREADABLE|POLLPRI, &tv) > 0) { - if (0 == recv(sock->socket, &buf, sizeof(buf), MSG_PEEK) && php_socket_errno() != EAGAIN) { + if (0 >= recv(sock->socket, &buf, sizeof(buf), MSG_PEEK) && php_socket_errno() != EWOULDBLOCK) { alive = 0; } } @@ -621,7 +621,7 @@ static inline int php_tcp_sockop_connect(php_stream *stream, php_netstream_data_ parse_unix_address(xparam, &unix_addr TSRMLS_CC); ret = php_network_connect_socket(sock->socket, - (const struct sockaddr *)&unix_addr, (socklen_t)sizeof(unix_addr), + (const struct sockaddr *)&unix_addr, (socklen_t) XtOffsetOf(struct sockaddr_un, sun_path) + xparam->inputs.namelen, xparam->op == STREAM_XPORT_OP_CONNECT_ASYNC, xparam->inputs.timeout, xparam->want_errortext ? &xparam->outputs.error_text : NULL, &err); diff --git a/main/strlcat.c b/main/strlcat.c index 9a72e3637..b43191560 100644 --- a/main/strlcat.c +++ b/main/strlcat.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2008 The PHP Group | + | Copyright (c) 1997-2009 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: strlcat.c,v 1.13.2.1.2.2 2007/12/31 07:20:15 sebastian Exp $ */ +/* $Id: strlcat.c,v 1.13.2.1.2.3 2008/12/31 11:17:48 sebastian Exp $ */ #include "php.h" diff --git a/main/strlcpy.c b/main/strlcpy.c index 8ca4c20a6..61d5537e2 100644 --- a/main/strlcpy.c +++ b/main/strlcpy.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2008 The PHP Group | + | Copyright (c) 1997-2009 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: strlcpy.c,v 1.13.2.1.2.2 2007/12/31 07:20:15 sebastian Exp $ */ +/* $Id: strlcpy.c,v 1.13.2.1.2.3 2008/12/31 11:17:48 sebastian Exp $ */ #include "php.h" diff --git a/main/win95nt.h b/main/win95nt.h index c9706adc4..cd2337004 100644 --- a/main/win95nt.h +++ b/main/win95nt.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2008 The PHP Group | + | Copyright (c) 1997-2009 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: win95nt.h,v 1.20.2.2.2.3 2007/12/31 07:20:15 sebastian Exp $ */ +/* $Id: win95nt.h,v 1.20.2.2.2.4 2008/12/31 11:17:48 sebastian Exp $ */ /* Defines and types for Windows 95/NT */ #define HAVE_DECLARED_TIMEZONE |
