summaryrefslogtreecommitdiff
path: root/main/streams
diff options
context:
space:
mode:
Diffstat (limited to 'main/streams')
-rw-r--r--main/streams/glob_wrapper.c1
-rw-r--r--main/streams/memory.c7
-rw-r--r--main/streams/plain_wrapper.c12
-rw-r--r--main/streams/streams.c2
-rw-r--r--main/streams/transports.c3
-rw-r--r--main/streams/userspace.c4
-rw-r--r--main/streams/xp_socket.c59
7 files changed, 55 insertions, 33 deletions
diff --git a/main/streams/glob_wrapper.c b/main/streams/glob_wrapper.c
index f41ce19d23..1288fa6bad 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 6e3d1dd0c1..b1483e0786 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 39c629b458..6bc0138f29 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)
@@ -471,7 +473,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;
@@ -1005,9 +1011,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 c4cb8d824c..0ad72a6433 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 6cf484e6e7..eb1909f1ce 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 94d32abd11..2b21dc9616 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 3ff64787aa..83b8fc7e30 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);
}
@@ -759,6 +759,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. */
@@ -800,36 +812,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)++;
}
}
}