mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Fixed possibly overflowing vars
Due to the change from `int` to `php_socket_t` some variables might overflow now. Changed all variables that might be affected.
This commit is contained in:
@@ -36,7 +36,7 @@
|
||||
static int
|
||||
mysqlnd_set_sock_no_delay(php_stream * stream)
|
||||
{
|
||||
int socketd = ((php_netstream_data_t*)stream->abstract)->socket;
|
||||
php_socket_t socketd = ((php_netstream_data_t*)stream->abstract)->socket;
|
||||
int ret = SUCCESS;
|
||||
int flag = 1;
|
||||
int result = setsockopt(socketd, IPPROTO_TCP, TCP_NODELAY, (char *) &flag, sizeof(int));
|
||||
@@ -56,7 +56,7 @@ mysqlnd_set_sock_no_delay(php_stream * stream)
|
||||
static int
|
||||
mysqlnd_set_sock_keepalive(php_stream * stream)
|
||||
{
|
||||
int socketd = ((php_netstream_data_t*)stream->abstract)->socket;
|
||||
php_socket_t socketd = ((php_netstream_data_t*)stream->abstract)->socket;
|
||||
int ret = SUCCESS;
|
||||
int flag = 1;
|
||||
int result = setsockopt(socketd, SOL_SOCKET, SO_KEEPALIVE, (char *) &flag, sizeof(int));
|
||||
|
||||
@@ -34,18 +34,22 @@
|
||||
* - Calling this with NULL sets as a portable way to sleep with sub-second
|
||||
* accuracy is not supported.
|
||||
* */
|
||||
PHPAPI int php_select(SOCKET max_fd, fd_set *rfds, fd_set *wfds, fd_set *efds, struct timeval *tv)
|
||||
PHPAPI int php_select(php_socket_t max_fd, fd_set *rfds, fd_set *wfds, fd_set *efds, struct timeval *tv)
|
||||
{
|
||||
ULONGLONG ms_total, limit;
|
||||
HANDLE handles[MAXIMUM_WAIT_OBJECTS];
|
||||
int handle_slot_to_fd[MAXIMUM_WAIT_OBJECTS];
|
||||
int n_handles = 0, i;
|
||||
php_socket_t handle_slot_to_fd[MAXIMUM_WAIT_OBJECTS];
|
||||
php_socket_t n_handles = 0, i;
|
||||
fd_set sock_read, sock_write, sock_except;
|
||||
fd_set aread, awrite, aexcept;
|
||||
int sock_max_fd = -1;
|
||||
php_socket_t sock_max_fd = -1;
|
||||
struct timeval tvslice;
|
||||
int retcode;
|
||||
|
||||
if (max_fd < 0) {
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
#define SAFE_FD_ISSET(fd, set) (set != NULL && FD_ISSET(fd, set))
|
||||
|
||||
/* calculate how long we need to wait in milliseconds */
|
||||
@@ -136,13 +140,13 @@ PHPAPI int php_select(SOCKET max_fd, fd_set *rfds, fd_set *wfds, fd_set *efds, s
|
||||
for (i = 0; i < n_handles; i++) {
|
||||
if (WAIT_OBJECT_0 == WaitForSingleObject(handles[i], 0)) {
|
||||
if (SAFE_FD_ISSET(handle_slot_to_fd[i], rfds)) {
|
||||
FD_SET((uint32_t)handle_slot_to_fd[i], &aread);
|
||||
FD_SET((php_socket_t) handle_slot_to_fd[i], &aread);
|
||||
}
|
||||
if (SAFE_FD_ISSET(handle_slot_to_fd[i], wfds)) {
|
||||
FD_SET((uint32_t)handle_slot_to_fd[i], &awrite);
|
||||
FD_SET((php_socket_t) handle_slot_to_fd[i], &awrite);
|
||||
}
|
||||
if (SAFE_FD_ISSET(handle_slot_to_fd[i], efds)) {
|
||||
FD_SET((uint32_t)handle_slot_to_fd[i], &aexcept);
|
||||
FD_SET((php_socket_t) handle_slot_to_fd[i], &aexcept);
|
||||
}
|
||||
retcode++;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,6 @@
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#include <WinSock2.h>
|
||||
#include "php_network.h"
|
||||
|
||||
PHPAPI int php_select(SOCKET max_fd, fd_set *rfds, fd_set *wfds, fd_set *efds, struct timeval *tv);
|
||||
PHPAPI int php_select(php_socket_t max_fd, fd_set *rfds, fd_set *wfds, fd_set *efds, struct timeval *tv);
|
||||
|
||||
Reference in New Issue
Block a user