diff options
Diffstat (limited to 'main/streams')
-rw-r--r-- | main/streams/filter.c | 4 | ||||
-rw-r--r-- | main/streams/glob_wrapper.c | 1 | ||||
-rw-r--r-- | main/streams/memory.c | 7 | ||||
-rw-r--r-- | main/streams/plain_wrapper.c | 12 | ||||
-rw-r--r-- | main/streams/streams.c | 2 | ||||
-rw-r--r-- | main/streams/transports.c | 3 | ||||
-rw-r--r-- | main/streams/userspace.c | 4 | ||||
-rw-r--r-- | main/streams/xp_socket.c | 59 |
8 files changed, 57 insertions, 35 deletions
diff --git a/main/streams/filter.c b/main/streams/filter.c index d063c1a915..e97dea9f21 100644 --- a/main/streams/filter.c +++ b/main/streams/filter.c @@ -252,10 +252,10 @@ PHPAPI php_stream_filter *php_stream_filter_create(const char *filtername, zval HashTable *filter_hash = (FG(stream_filters) ? FG(stream_filters) : &stream_filters_hash); php_stream_filter_factory *factory = NULL; php_stream_filter *filter = NULL; - int n; + size_t n; char *period; - n = (int)strlen(filtername); + n = strlen(filtername); if (NULL != (factory = zend_hash_str_find_ptr(filter_hash, filtername, n))) { filter = factory->create_filter(filtername, filterparams, persistent); diff --git a/main/streams/glob_wrapper.c b/main/streams/glob_wrapper.c index 85395107d5..d542e336e3 100644 --- a/main/streams/glob_wrapper.c +++ b/main/streams/glob_wrapper.c @@ -271,6 +271,7 @@ static php_stream_wrapper_ops php_glob_stream_wrapper_ops = { NULL, NULL, NULL, + NULL, NULL }; diff --git a/main/streams/memory.c b/main/streams/memory.c index 56ffe344aa..a1af61e3f0 100644 --- a/main/streams/memory.c +++ b/main/streams/memory.c @@ -695,7 +695,7 @@ static php_stream * php_stream_url_wrap_rfc2397(php_stream_wrapper *wrapper, con } /* found parameter ... the heart of cs ppl lies in +1/-1 or was it +2 this time? */ plen = sep - path; - vlen = (semi ? semi - sep : mlen - plen) - 1 /* '=' */; + vlen = (semi ? (size_t)(semi - sep) : (mlen - plen)) - 1 /* '=' */; key = estrndup(path, plen); if (plen != sizeof("mediatype")-1 || memcmp(key, "mediatype", sizeof("mediatype")-1)) { add_assoc_stringl_ex(&meta, key, plen, sep + 1, vlen); @@ -720,7 +720,7 @@ static php_stream * php_stream_url_wrap_rfc2397(php_stream_wrapper *wrapper, con dlen--; if (base64) { - base64_comma = php_base64_decode((const unsigned char *)comma, dlen); + base64_comma = php_base64_decode_ex((const unsigned char *)comma, dlen, 1); if (!base64_comma) { zval_ptr_dtor(&meta); php_stream_wrapper_log_error(wrapper, options, "rfc2397: unable to decode"); @@ -770,7 +770,8 @@ PHPAPI php_stream_wrapper_ops php_stream_rfc2397_wops = { NULL, /* unlink */ NULL, /* rename */ NULL, /* mkdir */ - NULL /* rmdir */ + NULL, /* rmdir */ + NULL, /* stream_metadata */ }; PHPAPI php_stream_wrapper php_stream_rfc2397_wrapper = { diff --git a/main/streams/plain_wrapper.c b/main/streams/plain_wrapper.c index 140e5e1fcd..69dd25acc5 100644 --- a/main/streams/plain_wrapper.c +++ b/main/streams/plain_wrapper.c @@ -42,6 +42,8 @@ #ifdef PHP_WIN32 # include "win32/winutil.h" # include "win32/time.h" +# include "win32/ioutil.h" +# include "win32/readdir.h" #endif #define php_stream_fopen_from_fd_int(fd, mode, persistent_id) _php_stream_fopen_from_fd_int((fd), (mode), (persistent_id) STREAMS_CC) @@ -465,7 +467,11 @@ static int php_stdiop_close(php_stream *stream, int close_handle) return 0; /* everything should be closed already -> success */ } if (data->temp_name) { +#ifdef PHP_WIN32 + php_win32_ioutil_unlink(ZSTR_VAL(data->temp_name)); +#else unlink(ZSTR_VAL(data->temp_name)); +#endif /* temporary streams are never persistent */ zend_string_release(data->temp_name); data->temp_name = NULL; @@ -999,9 +1005,11 @@ PHPAPI php_stream *_php_stream_fopen(const char *filename, const char *mode, zen return ret; } } - +#ifdef PHP_WIN32 + fd = php_win32_ioutil_open(realpath, open_flags, 0666); +#else fd = open(realpath, open_flags, 0666); - +#endif if (fd != -1) { if (options & STREAM_OPEN_FOR_INCLUDE) { diff --git a/main/streams/streams.c b/main/streams/streams.c index 788c0a192a..936f9990ab 100644 --- a/main/streams/streams.c +++ b/main/streams/streams.c @@ -1753,7 +1753,7 @@ PHPAPI php_stream_wrapper *php_stream_locate_url_wrapper(const char *path, const HashTable *wrapper_hash = (FG(stream_wrappers) ? FG(stream_wrappers) : &url_stream_wrappers_hash); php_stream_wrapper *wrapper = NULL; const char *p, *protocol = NULL; - int n = 0; + size_t n = 0; if (path_for_open) { *path_for_open = (char*)path; diff --git a/main/streams/transports.c b/main/streams/transports.c index feaa099c8c..795e2e8a44 100644 --- a/main/streams/transports.c +++ b/main/streams/transports.c @@ -60,7 +60,8 @@ PHPAPI php_stream *_php_stream_xport_create(const char *name, size_t namelen, in php_stream *stream = NULL; php_stream_transport_factory factory = NULL; const char *p, *protocol = NULL; - int n = 0, failed = 0; + size_t n = 0; + int failed = 0; zend_string *error_text = NULL; struct timeval default_timeout = { 0, 0 }; diff --git a/main/streams/userspace.c b/main/streams/userspace.c index 63a351a59b..eb8b32eed9 100644 --- a/main/streams/userspace.c +++ b/main/streams/userspace.c @@ -299,9 +299,7 @@ static void user_stream_create_object(struct php_user_stream_wrapper *uwrap, php zval retval; fci.size = sizeof(fci); - fci.function_table = &uwrap->ce->function_table; ZVAL_UNDEF(&fci.function_name); - fci.symbol_table = NULL; fci.object = Z_OBJ_P(object); fci.retval = &retval; fci.param_count = 0; @@ -310,7 +308,7 @@ static void user_stream_create_object(struct php_user_stream_wrapper *uwrap, php fcc.initialized = 1; fcc.function_handler = uwrap->ce->constructor; - fcc.calling_scope = EG(scope); + fcc.calling_scope = zend_get_executed_scope(); fcc.called_scope = Z_OBJCE_P(object); fcc.object = Z_OBJ_P(object); diff --git a/main/streams/xp_socket.c b/main/streams/xp_socket.c index bf7e98c56b..fa08a11752 100644 --- a/main/streams/xp_socket.c +++ b/main/streams/xp_socket.c @@ -102,7 +102,7 @@ retry: } while (err == EINTR); } estr = php_socket_strerror(err, NULL, 0); - php_error_docref(NULL, E_NOTICE, "send of " ZEND_LONG_FMT " bytes failed with errno=%ld %s", + php_error_docref(NULL, E_NOTICE, "send of " ZEND_LONG_FMT " bytes failed with errno=%d %s", (zend_long)count, err, estr); efree(estr); } @@ -752,6 +752,18 @@ static inline int php_tcp_sockop_connect(php_stream *stream, php_netstream_data_ } #endif + if (stream->ops != &php_stream_udp_socket_ops /* TCP_NODELAY is only applicable for TCP */ +#ifdef AF_UNIX + && stream->ops != &php_stream_unix_socket_ops + && stream->ops != &php_stream_unixdg_socket_ops +#endif + && PHP_STREAM_CONTEXT(stream) + && (tmpzval = php_stream_context_get_option(PHP_STREAM_CONTEXT(stream), "socket", "tcp_nodelay")) != NULL + && zend_is_true(tmpzval) + ) { + sockopts |= STREAM_SOCKOP_TCP_NODELAY; + } + /* Note: the test here for php_stream_udp_socket_ops is important, because we * want the default to be TCP sockets so that the openssl extension can * re-use this code. */ @@ -793,36 +805,37 @@ static inline int php_tcp_sockop_accept(php_stream *stream, php_netstream_data_t php_stream_xport_param *xparam STREAMS_DC) { int clisock; + zend_bool nodelay = 0; + zval *tmpzval = NULL; xparam->outputs.client = NULL; + if ((NULL != PHP_STREAM_CONTEXT(stream)) && + (tmpzval = php_stream_context_get_option(PHP_STREAM_CONTEXT(stream), "socket", "tcp_nodelay")) != NULL && + zend_is_true(tmpzval)) { + nodelay = 1; + } + clisock = php_network_accept_incoming(sock->socket, - xparam->want_textaddr ? &xparam->outputs.textaddr : NULL, - xparam->want_addr ? &xparam->outputs.addr : NULL, - xparam->want_addr ? &xparam->outputs.addrlen : NULL, - xparam->inputs.timeout, - xparam->want_errortext ? &xparam->outputs.error_text : NULL, - &xparam->outputs.error_code - ); + xparam->want_textaddr ? &xparam->outputs.textaddr : NULL, + xparam->want_addr ? &xparam->outputs.addr : NULL, + xparam->want_addr ? &xparam->outputs.addrlen : NULL, + xparam->inputs.timeout, + xparam->want_errortext ? &xparam->outputs.error_text : NULL, + &xparam->outputs.error_code, + nodelay); if (clisock >= 0) { - php_netstream_data_t *clisockdata; + php_netstream_data_t *clisockdata = (php_netstream_data_t*) emalloc(sizeof(*clisockdata)); - clisockdata = emalloc(sizeof(*clisockdata)); + memcpy(clisockdata, sock, sizeof(*clisockdata)); + clisockdata->socket = clisock; - if (clisockdata == NULL) { - close(clisock); - /* technically a fatal error */ - } else { - memcpy(clisockdata, sock, sizeof(*clisockdata)); - clisockdata->socket = clisock; - - xparam->outputs.client = php_stream_alloc_rel(stream->ops, clisockdata, NULL, "r+"); - if (xparam->outputs.client) { - xparam->outputs.client->ctx = stream->ctx; - if (stream->ctx) { - GC_REFCOUNT(stream->ctx)++; - } + xparam->outputs.client = php_stream_alloc_rel(stream->ops, clisockdata, NULL, "r+"); + if (xparam->outputs.client) { + xparam->outputs.client->ctx = stream->ctx; + if (stream->ctx) { + GC_REFCOUNT(stream->ctx)++; } } } |