1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-08-10 06:23:01 +03:00

poll: Fixed a malfunction with wrong max fd value check.

This commit is contained in:
Andreas Schneider
2010-06-17 11:16:24 +02:00
parent b9a9f54c45
commit c30a25e64c
2 changed files with 8 additions and 4 deletions

View File

@@ -120,10 +120,14 @@ typedef struct ssh_string_struct* ssh_string;
/* Socket type */ /* Socket type */
#ifdef _WIN32 #ifdef _WIN32
#define socket_t SOCKET #ifndef socket_t
#else typedef SOCKET socket_t;
#endif /* socket_t */
#else /* _WIN32 */
#ifndef socket_t
typedef int socket_t; typedef int socket_t;
#endif #endif
#endif /* _WIN32 */
/* the offsets of methods */ /* the offsets of methods */
enum ssh_kex_types_e { enum ssh_kex_types_e {

View File

@@ -135,7 +135,7 @@ static int bsd_poll(ssh_pollfd_t *fds, nfds_t nfds, int timeout) {
FD_ZERO (&exceptfds); FD_ZERO (&exceptfds);
/* compute fd_sets and find largest descriptor */ /* compute fd_sets and find largest descriptor */
for (max_fd = -1, i = 0; i < nfds; i++) { for (max_fd = 0, i = 0; i < nfds; i++) {
if (fds[i].fd < 0) { if (fds[i].fd < 0) {
continue; continue;
} }
@@ -157,7 +157,7 @@ static int bsd_poll(ssh_pollfd_t *fds, nfds_t nfds, int timeout) {
} }
} }
if (max_fd == -1) { if (max_fd == (socket_t) -1) {
errno = EINVAL; errno = EINVAL;
return -1; return -1;
} }