From 62f6c5853f87259de320c54d12f7fb213aee4e27 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Wed, 19 Mar 2014 06:26:54 +0100 Subject: Fixes to various stream cast on win64 This fixes further issues on win64 with casts from the streams. Sockets/descriptors handling was unitized. This has an impact only on win64, php_socket_t otherwise can be feed back to int datatype. --- ext/standard/streamsfuncs.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'ext/standard/streamsfuncs.c') diff --git a/ext/standard/streamsfuncs.c b/ext/standard/streamsfuncs.c index b623447651..e19a453fd8 100644 --- a/ext/standard/streamsfuncs.c +++ b/ext/standard/streamsfuncs.c @@ -613,7 +613,7 @@ static int stream_array_to_fd_set(zval *stream_array, fd_set *fds, php_socket_t /* Temporary int fd is needed for the STREAM data type on windows, passing this_fd directly to php_stream_cast() would eventually bring a wrong result on x64. php_stream_cast() casts to int internally, and this will leave the higher bits of a SOCKET variable uninitialized on systems with little endian. */ - int tmp_fd; + php_socket_t this_fd; php_stream_from_zval_no_verify(stream, elem); if (stream == NULL) { @@ -624,9 +624,7 @@ static int stream_array_to_fd_set(zval *stream_array, fd_set *fds, php_socket_t * when casting. It is only used here so that the buffered data warning * is not displayed. * */ - if (SUCCESS == php_stream_cast(stream, PHP_STREAM_AS_FD_FOR_SELECT | PHP_STREAM_CAST_INTERNAL, (void*)&tmp_fd, 1) && tmp_fd != -1) { - - php_socket_t this_fd = (php_socket_t)tmp_fd; + if (SUCCESS == php_stream_cast(stream, PHP_STREAM_AS_FD_FOR_SELECT | PHP_STREAM_CAST_INTERNAL, (void*)&this_fd, 1) && this_fd != -1) { PHP_SAFE_FD_SET(this_fd, fds); @@ -660,10 +658,7 @@ static int stream_array_from_fd_set(zval *stream_array, fd_set *fds TSRMLS_DC) char *key; uint key_len; ulong num_ind; - /* Temporary int fd is needed for the STREAM data type on windows, passing this_fd directly to php_stream_cast() - would eventually bring a wrong result on x64. php_stream_cast() casts to int internally, and this will leave - the higher bits of a SOCKET variable uninitialized on systems with little endian. */ - int tmp_fd; + php_socket_t this_fd; type = zend_hash_get_current_key_ex(Z_ARRVAL_P(stream_array), @@ -682,10 +677,7 @@ static int stream_array_from_fd_set(zval *stream_array, fd_set *fds TSRMLS_DC) * when casting. It is only used here so that the buffered data warning * is not displayed. */ - if (SUCCESS == php_stream_cast(stream, PHP_STREAM_AS_FD_FOR_SELECT | PHP_STREAM_CAST_INTERNAL, (void*)&tmp_fd, 1) && tmp_fd != -1) { - - php_socket_t this_fd = (php_socket_t)tmp_fd; - + if (SUCCESS == php_stream_cast(stream, PHP_STREAM_AS_FD_FOR_SELECT | PHP_STREAM_CAST_INTERNAL, (void*)&this_fd, 1) && this_fd != SOCK_ERR) { if (PHP_SAFE_FD_ISSET(this_fd, fds)) { if (type == HASH_KEY_IS_LONG) { zend_hash_index_update(new_hash, num_ind, (void *)elem, sizeof(zval *), (void **)&dest_elem); -- cgit v1.2.1 From ec1153062040aa79382fb47bdcb42d24c2ab08f6 Mon Sep 17 00:00:00 2001 From: Anatol Belski Date: Wed, 19 Mar 2014 06:35:58 +0100 Subject: remove obsolete comment --- ext/standard/streamsfuncs.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'ext/standard/streamsfuncs.c') diff --git a/ext/standard/streamsfuncs.c b/ext/standard/streamsfuncs.c index e19a453fd8..8d42a51af6 100644 --- a/ext/standard/streamsfuncs.c +++ b/ext/standard/streamsfuncs.c @@ -610,9 +610,6 @@ static int stream_array_to_fd_set(zval *stream_array, fd_set *fds, php_socket_t zend_hash_get_current_data(Z_ARRVAL_P(stream_array), (void **) &elem) == SUCCESS; zend_hash_move_forward(Z_ARRVAL_P(stream_array))) { - /* Temporary int fd is needed for the STREAM data type on windows, passing this_fd directly to php_stream_cast() - would eventually bring a wrong result on x64. php_stream_cast() casts to int internally, and this will leave - the higher bits of a SOCKET variable uninitialized on systems with little endian. */ php_socket_t this_fd; php_stream_from_zval_no_verify(stream, elem); -- cgit v1.2.1