aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cynapses.org>2010-06-20 21:16:29 +0200
committerAndreas Schneider <asn@cynapses.org>2010-06-20 21:18:46 +0200
commit6f9fea7fd5b3801231fa1938cead6efab54c5ea9 (patch)
treedc35b5e14aee913b6e46b191136945241c1017b5
parentc8d978f4e9f28f6bb0a682ab423fd4820299d2fd (diff)
downloadlibssh-6f9fea7fd5b3801231fa1938cead6efab54c5ea9.tar.gz
libssh-6f9fea7fd5b3801231fa1938cead6efab54c5ea9.tar.xz
libssh-6f9fea7fd5b3801231fa1938cead6efab54c5ea9.zip
poll: Check if maxfd has been set.
-rw-r--r--libssh/poll.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/libssh/poll.c b/libssh/poll.c
index 0de7a23..27e7633 100644
--- a/libssh/poll.c
+++ b/libssh/poll.c
@@ -135,7 +135,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;
}
@@ -154,10 +154,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;
}