diff options
author | Andreas Schneider <asn@cynapses.org> | 2010-06-20 21:16:29 +0200 |
---|---|---|
committer | Andreas Schneider <asn@cynapses.org> | 2010-06-20 21:16:29 +0200 |
commit | 541b38b772785db0c405c2697babacb2a95cfdfa (patch) | |
tree | 1b723f8c99b743d465e4c64468173f6028a36480 | |
parent | a85a4cc1928df69b6d3ad01fd2a8519534b35af5 (diff) | |
download | libssh-541b38b772785db0c405c2697babacb2a95cfdfa.tar.gz libssh-541b38b772785db0c405c2697babacb2a95cfdfa.tar.xz libssh-541b38b772785db0c405c2697babacb2a95cfdfa.zip |
poll: Check if maxfd has been set.
-rw-r--r-- | libssh/poll.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/libssh/poll.c b/libssh/poll.c index 2b7096b0..c50f2ab3 100644 --- a/libssh/poll.c +++ b/libssh/poll.c @@ -110,7 +110,7 @@ static int bsd_poll(ssh_pollfd_t *fds, nfds_t nfds, int timeout) { FD_ZERO (&exceptfds); /* compute fd_sets and find largest descriptor */ - for (max_fd = 0, i = 0; i < nfds; i++) { + for (rc = -1; max_fd = 0, i = 0; i < nfds; i++) { if (fds[i].fd == SSH_INVALID_SOCKET) { continue; } @@ -129,10 +129,11 @@ static int bsd_poll(ssh_pollfd_t *fds, nfds_t nfds, int timeout) { POLLRDNORM | POLLRDBAND | POLLWRNORM | POLLWRBAND))) { max_fd = fds[i].fd; + rc = 0; } } - if (max_fd == SSH_INVALID_SOCKET) { + if (max_fd == SSH_INVALID_SOCKET || rc = -1) { errno = EINVAL; return -1; } |