diff options
Diffstat (limited to 'main')
| -rw-r--r-- | main/SAPI.c | 2 | ||||
| -rw-r--r-- | main/SAPI.h | 3 | ||||
| -rw-r--r-- | main/main.c | 46 | ||||
| -rw-r--r-- | main/output.c | 14 | ||||
| -rw-r--r-- | main/php.h | 1 | ||||
| -rw-r--r-- | main/php_globals.h | 4 | ||||
| -rw-r--r-- | main/php_ini.c | 106 | ||||
| -rw-r--r-- | main/php_streams.h | 1 | ||||
| -rw-r--r-- | main/php_variables.c | 2 | ||||
| -rw-r--r-- | main/php_variables.h | 2 | ||||
| -rw-r--r-- | main/streams/php_stream_transport.h | 35 | ||||
| -rw-r--r-- | main/streams/plain_wrapper.c | 12 | ||||
| -rw-r--r-- | main/streams/streams.c | 61 | ||||
| -rw-r--r-- | main/streams/xp_socket.c | 3 |
14 files changed, 197 insertions, 95 deletions
diff --git a/main/SAPI.c b/main/SAPI.c index 9cacbd4b4b..4cab4e54ea 100644 --- a/main/SAPI.c +++ b/main/SAPI.c @@ -715,7 +715,7 @@ SAPI_API int sapi_header_op(sapi_header_op_enum op, void *arg TSRMLS_DC) header_line = estrndup(header_line, header_line_len); - /* cut of trailing spaces, linefeeds and carriage-returns */ + /* cut off trailing spaces, linefeeds and carriage-returns */ if (header_line_len && isspace(header_line[header_line_len-1])) { do { header_line_len--; diff --git a/main/SAPI.h b/main/SAPI.h index c1b30fed74..ac3db56bad 100644 --- a/main/SAPI.h +++ b/main/SAPI.h @@ -21,6 +21,7 @@ #ifndef SAPI_H #define SAPI_H +#include "php.h" #include "zend.h" #include "zend_API.h" #include "zend_llist.h" @@ -291,7 +292,7 @@ struct _sapi_post_entry { #define SAPI_HEADER_SEND_FAILED 3 #define SAPI_DEFAULT_MIMETYPE "text/html" -#define SAPI_DEFAULT_CHARSET "" +#define SAPI_DEFAULT_CHARSET PHP_DEFAULT_CHARSET #define SAPI_PHP_VERSION_HEADER "X-Powered-By: PHP/" PHP_VERSION #define SAPI_POST_READER_FUNC(post_reader) void post_reader(TSRMLS_D) diff --git a/main/main.c b/main/main.c index 9333560fc1..ebe0655d3a 100644 --- a/main/main.c +++ b/main/main.c @@ -417,6 +417,45 @@ static PHP_INI_DISP(display_errors_mode) /* {{{ PHP_INI_MH */ +static PHP_INI_MH(OnUpdateInternalEncoding) +{ + if (new_value) { + OnUpdateString(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC); + } else { + OnUpdateString(entry, SG(default_charset), strlen(SG(default_charset))+1, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC); + } + return SUCCESS; +} +/* }}} */ + +/* {{{ PHP_INI_MH + */ +static PHP_INI_MH(OnUpdateInputEncoding) +{ + if (new_value) { + OnUpdateString(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC); + } else { + OnUpdateString(entry, SG(default_charset), strlen(SG(default_charset))+1, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC); + } + return SUCCESS; +} +/* }}} */ + +/* {{{ PHP_INI_MH + */ +static PHP_INI_MH(OnUpdateOutputEncoding) +{ + if (new_value) { + OnUpdateString(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC); + } else { + OnUpdateString(entry, SG(default_charset), strlen(SG(default_charset))+1, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC); + } + return SUCCESS; +} +/* }}} */ + +/* {{{ PHP_INI_MH + */ static PHP_INI_MH(OnUpdateErrorLog) { /* Only do the safemode/open_basedir check at runtime */ @@ -522,8 +561,11 @@ PHP_INI_BEGIN() STD_PHP_INI_ENTRY("auto_append_file", NULL, PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateString, auto_append_file, php_core_globals, core_globals) STD_PHP_INI_ENTRY("auto_prepend_file", NULL, PHP_INI_SYSTEM|PHP_INI_PERDIR, OnUpdateString, auto_prepend_file, php_core_globals, core_globals) STD_PHP_INI_ENTRY("doc_root", NULL, PHP_INI_SYSTEM, OnUpdateStringUnempty, doc_root, php_core_globals, core_globals) - STD_PHP_INI_ENTRY("default_charset", SAPI_DEFAULT_CHARSET, PHP_INI_ALL, OnUpdateString, default_charset, sapi_globals_struct,sapi_globals) - STD_PHP_INI_ENTRY("default_mimetype", SAPI_DEFAULT_MIMETYPE, PHP_INI_ALL, OnUpdateString, default_mimetype, sapi_globals_struct,sapi_globals) + STD_PHP_INI_ENTRY("default_charset", PHP_DEFAULT_CHARSET, PHP_INI_ALL, OnUpdateString, default_charset, sapi_globals_struct, sapi_globals) + STD_PHP_INI_ENTRY("default_mimetype", SAPI_DEFAULT_MIMETYPE, PHP_INI_ALL, OnUpdateString, default_mimetype, sapi_globals_struct, sapi_globals) + STD_PHP_INI_ENTRY("internal_encoding", NULL, PHP_INI_ALL, OnUpdateInternalEncoding, internal_encoding, php_core_globals, core_globals) + STD_PHP_INI_ENTRY("input_encoding", NULL, PHP_INI_ALL, OnUpdateInputEncoding, input_encoding, php_core_globals, core_globals) + STD_PHP_INI_ENTRY("output_encoding", NULL, PHP_INI_ALL, OnUpdateOutputEncoding, output_encoding, php_core_globals, core_globals) STD_PHP_INI_ENTRY("error_log", NULL, PHP_INI_ALL, OnUpdateErrorLog, error_log, php_core_globals, core_globals) STD_PHP_INI_ENTRY("extension_dir", PHP_EXTENSION_DIR, PHP_INI_SYSTEM, OnUpdateStringUnempty, extension_dir, php_core_globals, core_globals) STD_PHP_INI_ENTRY("sys_temp_dir", NULL, PHP_INI_SYSTEM, OnUpdateStringUnempty, sys_temp_dir, php_core_globals, core_globals) diff --git a/main/output.c b/main/output.c index cbf1fed9f0..83225107e0 100644 --- a/main/output.c +++ b/main/output.c @@ -240,6 +240,13 @@ PHPAPI int php_output_get_status(TSRMLS_D) * Unbuffered write */ PHPAPI int php_output_write_unbuffered(const char *str, size_t len TSRMLS_DC) { +#if PHP_DEBUG + if (len > UINT_MAX) { + php_error(E_WARNING, "Attempt to output more than UINT_MAX bytes at once; " + "output will be truncated %lu => %lu", + (unsigned long) len, (unsigned long) (len % UINT_MAX)); + } +#endif if (OG(flags) & PHP_OUTPUT_DISABLED) { return 0; } @@ -254,6 +261,13 @@ PHPAPI int php_output_write_unbuffered(const char *str, size_t len TSRMLS_DC) * Buffered write */ PHPAPI int php_output_write(const char *str, size_t len TSRMLS_DC) { +#if PHP_DEBUG + if (len > UINT_MAX) { + php_error(E_WARNING, "Attempt to output more than UINT_MAX bytes at once; " + "output will be truncated %lu => %lu", + (unsigned long) len, (unsigned long) (len % UINT_MAX)); + } +#endif if (OG(flags) & PHP_OUTPUT_DISABLED) { return 0; } diff --git a/main/php.h b/main/php.h index c2d0d936ca..f9cfd2d7f2 100644 --- a/main/php.h +++ b/main/php.h @@ -29,6 +29,7 @@ #define PHP_API_VERSION 20131218 #define PHP_HAVE_STREAMS #define YYDEBUG 0 +#define PHP_DEFAULT_CHARSET "UTF-8" #include "php_version.h" #include "zend.h" diff --git a/main/php_globals.h b/main/php_globals.h index 4bf80d34d6..9baabf757c 100644 --- a/main/php_globals.h +++ b/main/php_globals.h @@ -96,6 +96,10 @@ struct _php_core_globals { char *auto_prepend_file; char *auto_append_file; + char *input_encoding; + char *internal_encoding; + char *output_encoding; + arg_separators arg_separator; char *variables_order; diff --git a/main/php_ini.c b/main/php_ini.c index ed7da808f7..2b62e80554 100644 --- a/main/php_ini.c +++ b/main/php_ini.c @@ -620,63 +620,81 @@ int php_init_config(TSRMLS_D) zend_llist scanned_ini_list; zend_llist_element *element; int l, total_l = 0; + char *bufpath, *debpath, *endpath; + int lenpath; - if ((ndir = php_scandir(php_ini_scanned_path, &namelist, 0, php_alphasort)) > 0) { - zend_llist_init(&scanned_ini_list, sizeof(char *), (llist_dtor_func_t) free_estring, 1); - memset(&fh2, 0, sizeof(fh2)); + zend_llist_init(&scanned_ini_list, sizeof(char *), (llist_dtor_func_t) free_estring, 1); + memset(&fh2, 0, sizeof(fh2)); - for (i = 0; i < ndir; i++) { + bufpath = estrdup(php_ini_scanned_path); + for (debpath = bufpath ; debpath ; debpath=endpath) { + endpath = strchr(debpath, DEFAULT_DIR_SEPARATOR); + if (endpath) { + *(endpath++) = 0; + } + if (!debpath[0]) { + /* empty string means default builtin value + to allow "/foo/phd.d:" or ":/foo/php.d" */ + debpath = PHP_CONFIG_FILE_SCAN_DIR; + } + lenpath = strlen(debpath); - /* check for any file with .ini extension */ - if (!(p = strrchr(namelist[i]->d_name, '.')) || (p && strcmp(p, ".ini"))) { - free(namelist[i]); - continue; - } - /* Reset active ini section */ - RESET_ACTIVE_INI_HASH(); + if (lenpath > 0 && (ndir = php_scandir(debpath, &namelist, 0, php_alphasort)) > 0) { - 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 ((fh2.handle.fp = VCWD_FOPEN(ini_file, "r"))) { - fh2.filename = ini_file; - fh2.type = ZEND_HANDLE_FP; - - if (zend_parse_ini_file(&fh2, 1, ZEND_INI_SCANNER_NORMAL, (zend_ini_parser_cb_t) php_ini_parser_cb, &configuration_hash TSRMLS_CC) == SUCCESS) { - /* Here, add it to the list of ini files read */ - l = strlen(ini_file); - total_l += l + 2; - p = estrndup(ini_file, l); - zend_llist_add_element(&scanned_ini_list, &p); + for (i = 0; i < ndir; i++) { + + /* check for any file with .ini extension */ + if (!(p = strrchr(namelist[i]->d_name, '.')) || (p && strcmp(p, ".ini"))) { + free(namelist[i]); + continue; + } + /* Reset active ini section */ + RESET_ACTIVE_INI_HASH(); + + if (IS_SLASH(debpath[lenpath - 1])) { + snprintf(ini_file, MAXPATHLEN, "%s%s", debpath, namelist[i]->d_name); + } else { + snprintf(ini_file, MAXPATHLEN, "%s%c%s", debpath, DEFAULT_SLASH, namelist[i]->d_name); + } + if (VCWD_STAT(ini_file, &sb) == 0) { + if (S_ISREG(sb.st_mode)) { + if ((fh2.handle.fp = VCWD_FOPEN(ini_file, "r"))) { + fh2.filename = ini_file; + fh2.type = ZEND_HANDLE_FP; + + if (zend_parse_ini_file(&fh2, 1, ZEND_INI_SCANNER_NORMAL, (zend_ini_parser_cb_t) php_ini_parser_cb, &configuration_hash TSRMLS_CC) == SUCCESS) { + /* Here, add it to the list of ini files read */ + l = strlen(ini_file); + total_l += l + 2; + p = estrndup(ini_file, l); + zend_llist_add_element(&scanned_ini_list, &p); + } } } } + free(namelist[i]); } - free(namelist[i]); + free(namelist); } - free(namelist); + } + efree(bufpath); - if (total_l) { - int php_ini_scanned_files_len = (php_ini_scanned_files) ? strlen(php_ini_scanned_files) + 1 : 0; - php_ini_scanned_files = (char *) realloc(php_ini_scanned_files, php_ini_scanned_files_len + total_l + 1); - if (!php_ini_scanned_files_len) { - *php_ini_scanned_files = '\0'; - } - total_l += php_ini_scanned_files_len; - for (element = scanned_ini_list.head; element; element = element->next) { - if (php_ini_scanned_files_len) { - strlcat(php_ini_scanned_files, ",\n", total_l); - } - strlcat(php_ini_scanned_files, *(char **)element->data, total_l); - strlcat(php_ini_scanned_files, element->next ? ",\n" : "\n", total_l); + if (total_l) { + int php_ini_scanned_files_len = (php_ini_scanned_files) ? strlen(php_ini_scanned_files) + 1 : 0; + php_ini_scanned_files = (char *) realloc(php_ini_scanned_files, php_ini_scanned_files_len + total_l + 1); + if (!php_ini_scanned_files_len) { + *php_ini_scanned_files = '\0'; + } + total_l += php_ini_scanned_files_len; + for (element = scanned_ini_list.head; element; element = element->next) { + if (php_ini_scanned_files_len) { + strlcat(php_ini_scanned_files, ",\n", total_l); } + strlcat(php_ini_scanned_files, *(char **)element->data, total_l); + strlcat(php_ini_scanned_files, element->next ? ",\n" : "\n", total_l); } - zend_llist_destroy(&scanned_ini_list); } + zend_llist_destroy(&scanned_ini_list); } else { /* Make sure an empty php_ini_scanned_path ends up as NULL */ php_ini_scanned_path = NULL; diff --git a/main/php_streams.h b/main/php_streams.h index a0550a2356..2a142b99c2 100644 --- a/main/php_streams.h +++ b/main/php_streams.h @@ -373,6 +373,7 @@ END_EXTERN_C() /* Flags for url_stat method in wrapper ops */ #define PHP_STREAM_URL_STAT_LINK 1 #define PHP_STREAM_URL_STAT_QUIET 2 +#define PHP_STREAM_URL_STAT_NOCACHE 4 /* change the blocking mode of stream: value == 1 => blocking, value == 0 => non-blocking. */ #define PHP_STREAM_OPTION_BLOCKING 1 diff --git a/main/php_variables.c b/main/php_variables.c index 4202db5aa2..547dbd5582 100644 --- a/main/php_variables.c +++ b/main/php_variables.c @@ -658,7 +658,7 @@ static void php_autoglobal_merge(HashTable *dest, HashTable *src TSRMLS_DC) /* {{{ php_hash_environment */ -int php_hash_environment(TSRMLS_D) +PHPAPI int php_hash_environment(TSRMLS_D) { memset(PG(http_globals), 0, sizeof(PG(http_globals))); zend_activate_auto_globals(TSRMLS_C); diff --git a/main/php_variables.h b/main/php_variables.h index 37b2cf2a04..2331c582e6 100644 --- a/main/php_variables.h +++ b/main/php_variables.h @@ -41,7 +41,7 @@ PHPAPI void php_register_variable(char *var, char *val, zval *track_vars_array T PHPAPI void php_register_variable_safe(char *var, char *val, int val_len, zval *track_vars_array TSRMLS_DC); PHPAPI void php_register_variable_ex(char *var, zval *val, zval *track_vars_array TSRMLS_DC); -int php_hash_environment(TSRMLS_D); +PHPAPI int php_hash_environment(TSRMLS_D); END_EXTERN_C() #define NUM_TRACK_VARS 6 diff --git a/main/streams/php_stream_transport.h b/main/streams/php_stream_transport.h index c599a65d0f..dc10eb4e92 100644 --- a/main/streams/php_stream_transport.h +++ b/main/streams/php_stream_transport.h @@ -163,23 +163,30 @@ typedef struct _php_stream_xport_param { } outputs; } php_stream_xport_param; - -/* These functions provide crypto support on the underlying transport */ +/* Because both client and server streams use the same mechanisms + for encryption we use the LSB to denote clients. +*/ typedef enum { - STREAM_CRYPTO_METHOD_SSLv2_CLIENT, - STREAM_CRYPTO_METHOD_SSLv3_CLIENT, - STREAM_CRYPTO_METHOD_SSLv23_CLIENT, - STREAM_CRYPTO_METHOD_TLS_CLIENT, - STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT, - STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT, - STREAM_CRYPTO_METHOD_SSLv2_SERVER, - STREAM_CRYPTO_METHOD_SSLv3_SERVER, - STREAM_CRYPTO_METHOD_SSLv23_SERVER, - STREAM_CRYPTO_METHOD_TLS_SERVER, - STREAM_CRYPTO_METHOD_TLSv1_1_SERVER, - STREAM_CRYPTO_METHOD_TLSv1_2_SERVER + STREAM_CRYPTO_METHOD_SSLv2_CLIENT = (1 << 1 | 1), + STREAM_CRYPTO_METHOD_SSLv3_CLIENT = (1 << 2 | 1), + STREAM_CRYPTO_METHOD_SSLv23_CLIENT = ((1 << 1) | (1 << 2) | 1), + STREAM_CRYPTO_METHOD_TLSv1_0_CLIENT = (1 << 3 | 1), + STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT = (1 << 4 | 1), + STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT = (1 << 5 | 1), + STREAM_CRYPTO_METHOD_TLS_CLIENT = ((1 << 3) | (1 << 4) | (1 << 5) | 1), + STREAM_CRYPTO_METHOD_ANY_CLIENT = ((1 << 1) | (1 << 2) | (1 << 3) | (1 << 4) | (1 << 5) | 1), + STREAM_CRYPTO_METHOD_SSLv2_SERVER = (1 << 1), + STREAM_CRYPTO_METHOD_SSLv3_SERVER = (1 << 2), + STREAM_CRYPTO_METHOD_SSLv23_SERVER = ((1 << 1) | (1 << 2)), + STREAM_CRYPTO_METHOD_TLSv1_0_SERVER = (1 << 3), + STREAM_CRYPTO_METHOD_TLSv1_1_SERVER = (1 << 4), + STREAM_CRYPTO_METHOD_TLSv1_2_SERVER = (1 << 5), + STREAM_CRYPTO_METHOD_TLS_SERVER = ((1 << 3) | (1 << 4) | (1 << 5)), + STREAM_CRYPTO_METHOD_ANY_SERVER = ((1 << 1) | (1 << 2) | (1 << 3) | (1 << 4) | (1 << 5)) } php_stream_xport_crypt_method_t; +/* These functions provide crypto support on the underlying transport */ + BEGIN_EXTERN_C() PHPAPI int php_stream_xport_crypto_setup(php_stream *stream, php_stream_xport_crypt_method_t crypto_method, php_stream *session_stream TSRMLS_DC); PHPAPI int php_stream_xport_crypto_enable(php_stream *stream, int activate TSRMLS_DC); diff --git a/main/streams/plain_wrapper.c b/main/streams/plain_wrapper.c index 6ddfc74a11..5e9e5c7ace 100644 --- a/main/streams/plain_wrapper.c +++ b/main/streams/plain_wrapper.c @@ -482,7 +482,7 @@ static int php_stdiop_seek(php_stream *stream, off_t offset, int whence, off_t * static int php_stdiop_cast(php_stream *stream, int castas, void **ret TSRMLS_DC) { - int fd; + php_socket_t fd; php_stdio_stream_data *data = (php_stdio_stream_data*) stream->abstract; assert(data != NULL); @@ -506,31 +506,31 @@ static int php_stdiop_cast(php_stream *stream, int castas, void **ret TSRMLS_DC) } *(FILE**)ret = data->file; - data->fd = -1; + data->fd = SOCK_ERR; } return SUCCESS; case PHP_STREAM_AS_FD_FOR_SELECT: PHP_STDIOP_GET_FD(fd, data); - if (fd < 0) { + if (SOCK_ERR == fd) { return FAILURE; } if (ret) { - *(int*)ret = fd; + *(php_socket_t *)ret = fd; } return SUCCESS; case PHP_STREAM_AS_FD: PHP_STDIOP_GET_FD(fd, data); - if (fd < 0) { + if (SOCK_ERR == fd) { return FAILURE; } if (data->file) { fflush(data->file); } if (ret) { - *(int*)ret = fd; + *(php_socket_t *)ret = fd; } return SUCCESS; default: diff --git a/main/streams/streams.c b/main/streams/streams.c index 7ab74c7c08..0889bd57a7 100644 --- a/main/streams/streams.c +++ b/main/streams/streams.c @@ -728,6 +728,10 @@ PHPAPI size_t _php_stream_read(php_stream *stream, char *buf, size_t size TSRMLS if (!stream->readfilters.head && (stream->flags & PHP_STREAM_FLAG_NO_BUFFER || stream->chunk_size == 1)) { toread = stream->ops->read(stream, buf, size TSRMLS_CC); + if (toread == (size_t) -1) { + /* e.g. underlying read(2) returned -1 */ + break; + } } else { php_stream_fill_read_buffer(stream, size TSRMLS_CC); @@ -1393,11 +1397,16 @@ PHPAPI size_t _php_stream_passthru(php_stream * stream STREAMS_DC TSRMLS_DC) p = php_stream_mmap_range(stream, php_stream_tell(stream), PHP_STREAM_MMAP_ALL, PHP_STREAM_MAP_MODE_SHARED_READONLY, &mapped); if (p) { - PHPWRITE(p, mapped); + do { + /* output functions return int, so pass in int max */ + if (0 < (b = PHPWRITE(p, MIN(mapped - bcount, INT_MAX)))) { + bcount += b; + } + } while (b > 0 && mapped > bcount); php_stream_mmap_unmap_ex(stream, mapped); - return mapped; + return bcount; } } @@ -1912,16 +1921,18 @@ PHPAPI int _php_stream_stat_path(const char *path, int flags, php_stream_statbuf const char *path_to_open = path; int ret; - /* Try to hit the cache first */ - if (flags & PHP_STREAM_URL_STAT_LINK) { - if (BG(CurrentLStatFile) && strcmp(path, BG(CurrentLStatFile)) == 0) { - memcpy(ssb, &BG(lssb), sizeof(php_stream_statbuf)); - return 0; - } - } else { - if (BG(CurrentStatFile) && strcmp(path, BG(CurrentStatFile)) == 0) { - memcpy(ssb, &BG(ssb), sizeof(php_stream_statbuf)); - return 0; + if (!(flags & PHP_STREAM_URL_STAT_NOCACHE)) { + /* Try to hit the cache first */ + if (flags & PHP_STREAM_URL_STAT_LINK) { + if (BG(CurrentLStatFile) && strcmp(path, BG(CurrentLStatFile)) == 0) { + memcpy(ssb, &BG(lssb), sizeof(php_stream_statbuf)); + return 0; + } + } else { + if (BG(CurrentStatFile) && strcmp(path, BG(CurrentStatFile)) == 0) { + memcpy(ssb, &BG(ssb), sizeof(php_stream_statbuf)); + return 0; + } } } @@ -1929,19 +1940,21 @@ PHPAPI int _php_stream_stat_path(const char *path, int flags, php_stream_statbuf if (wrapper && wrapper->wops->url_stat) { ret = wrapper->wops->url_stat(wrapper, path_to_open, flags, ssb, context TSRMLS_CC); if (ret == 0) { - /* Drop into cache */ - if (flags & PHP_STREAM_URL_STAT_LINK) { - if (BG(CurrentLStatFile)) { - efree(BG(CurrentLStatFile)); - } - BG(CurrentLStatFile) = estrdup(path); - memcpy(&BG(lssb), ssb, sizeof(php_stream_statbuf)); - } else { - if (BG(CurrentStatFile)) { - efree(BG(CurrentStatFile)); + if (!(flags & PHP_STREAM_URL_STAT_NOCACHE)) { + /* Drop into cache */ + if (flags & PHP_STREAM_URL_STAT_LINK) { + if (BG(CurrentLStatFile)) { + efree(BG(CurrentLStatFile)); + } + BG(CurrentLStatFile) = estrdup(path); + memcpy(&BG(lssb), ssb, sizeof(php_stream_statbuf)); + } else { + if (BG(CurrentStatFile)) { + efree(BG(CurrentStatFile)); + } + BG(CurrentStatFile) = estrdup(path); + memcpy(&BG(ssb), ssb, sizeof(php_stream_statbuf)); } - BG(CurrentStatFile) = estrdup(path); - memcpy(&BG(ssb), ssb, sizeof(php_stream_statbuf)); } } return ret; diff --git a/main/streams/xp_socket.c b/main/streams/xp_socket.c index 0f2e530aa7..9e1521b537 100644 --- a/main/streams/xp_socket.c +++ b/main/streams/xp_socket.c @@ -588,7 +588,8 @@ static inline int php_tcp_sockop_bind(php_stream *stream, php_netstream_data_t * parse_unix_address(xparam, &unix_addr TSRMLS_CC); - return bind(sock->socket, (struct sockaddr *)&unix_addr, sizeof(unix_addr)); + return bind(sock->socket, (const struct sockaddr *)&unix_addr, + (socklen_t) XtOffsetOf(struct sockaddr_un, sun_path) + xparam->inputs.namelen); } #endif |
