Search
j0ke.net Open Build Service
>
Projects
>
home:netmax
:
rebuilds
:
php4
>
php4
> php-4.3.7-select.patch
Sign Up
|
Log In
Username
Password
Cancel
Overview
Repositories
Revisions
Requests
Users
Advanced
Attributes
Meta
File php-4.3.7-select.patch of Package php4
Passing fds > FD_SETSIZE to FD_SET gives undefined behaviour; avoid it. Proper fix is to use poll() where available rather than select(). --- php-4.3.8/ext/sockets/sockets.c.select +++ php-4.3.8/ext/sockets/sockets.c @@ -511,6 +511,7 @@ php_sock = (php_socket*) zend_fetch_resource(element TSRMLS_CC, -1, le_socket_name, NULL, 1, le_socket); if (!php_sock) continue; /* If element is not a resource, skip it */ + if (php_sock->bsd_socket > FD_SETSIZE) continue; /* must ignore it */ FD_SET(php_sock->bsd_socket, fds); if (php_sock->bsd_socket > *max_fd) { --- php-4.3.8/ext/standard/file.c.select +++ php-4.3.8/ext/standard/file.c @@ -684,6 +684,9 @@ * is not displayed. * */ if (SUCCESS == php_stream_cast(stream, PHP_STREAM_AS_FD_FOR_SELECT | PHP_STREAM_CAST_INTERNAL, (void*)&this_fd, 1)) { + if (this_fd > FD_SETSIZE) + continue; + FD_SET(this_fd, fds); if (this_fd > *max_fd) { *max_fd = this_fd; --- php-4.3.8/main/network.c.select +++ php-4.3.8/main/network.c @@ -287,7 +287,7 @@ fd_set wset; fd_set eset; - if (timeout == NULL) { + if (timeout == NULL || sockfd > FD_SETSIZE) { /* blocking mode */ return connect(sockfd, addr, addrlen); } @@ -1010,6 +1010,8 @@ int retval; struct timeval timeout, *ptimeout; + if (sock->socket > FD_SETSIZE) return; + FD_ZERO(&fdr); FD_SET(sock->socket, &fdr); sock->timeout_event = 0; @@ -1186,6 +1188,9 @@ fd_set rfds; struct timeval tv = {0, 0}; char buf; + + if (fd > FD_SETSIZE) + return 1; /* logic: if the select call indicates that there is data to * be read, but a read returns 0 bytes of data, then the socket