diff options
author | Wez Furlong <wez@php.net> | 2004-08-06 14:08:17 +0000 |
---|---|---|
committer | Wez Furlong <wez@php.net> | 2004-08-06 14:08:17 +0000 |
commit | d0ce6368b10ea315347399ccebf191338d8f91f8 (patch) | |
tree | d981b86bde13f33658aec799e6edf701583972ac /ext | |
parent | b7b14403308575bd0151d99f8ef77db0a46a2d2b (diff) | |
download | php-git-d0ce6368b10ea315347399ccebf191338d8f91f8.tar.gz |
Avoid possible segfault when using stream_socket_client with bogus flags.
Diffstat (limited to 'ext')
-rw-r--r-- | ext/standard/streamsfuncs.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/ext/standard/streamsfuncs.c b/ext/standard/streamsfuncs.c index 993188cb6d..75b7014e47 100644 --- a/ext/standard/streamsfuncs.c +++ b/ext/standard/streamsfuncs.c @@ -542,7 +542,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*)&this_fd, 1)) { + if (SUCCESS == php_stream_cast(stream, PHP_STREAM_AS_FD_FOR_SELECT | PHP_STREAM_CAST_INTERNAL, (void*)&this_fd, 1) && this_fd >= 0) { FD_SET(this_fd, fds); if (this_fd > *max_fd) { *max_fd = this_fd; @@ -578,7 +578,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*)&this_fd, 1)) { + if (SUCCESS == php_stream_cast(stream, PHP_STREAM_AS_FD_FOR_SELECT | PHP_STREAM_CAST_INTERNAL, (void*)&this_fd, 1) && this_fd >= 0) { if (FD_ISSET(this_fd, fds)) { zend_hash_next_index_insert(new_hash, (void *)elem, sizeof(zval *), (void **)&dest_elem); if (dest_elem) { |