summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2009-02-23 12:19:52 +0000
committerRoy Marples <roy@marples.name>2009-02-23 12:19:52 +0000
commit94872ce7d36d016e5dcf37b336e216dc9d6ad145 (patch)
tree60607aa8f0643f0b7458315d3b0bc019c0667f21
parent893d878748cc494436639bfc6282ea7726e62dd5 (diff)
downloaddhcpcd-94872ce7d36d016e5dcf37b336e216dc9d6ad145.tar.xz
If we get POLLERR or POLLNVAL then we should not return >0 with an fd.
Thanks to Michael Olney.
-rw-r--r--client.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/client.c b/client.c
index f9f5c630..11b529f0 100644
--- a/client.c
+++ b/client.c
@@ -837,12 +837,24 @@ wait_for_fd(struct if_state *state, int *fd)
}
/* We configured our array in the order we should deal with them */
- for (i = 0; i < nfds; i++)
- if (fds[i].revents & POLLIN) {
+ for (i = 0; i < nfds; i++) {
+ if (fds[i].revents & POLLERR) {
+ syslog(LOG_ERR, "poll: POLLERR on fd %d", fds[i].fd);
+ errno = EBADF;
+ return -1;
+ }
+ if (fds[i].revents & POLLNVAL) {
+ syslog(LOG_ERR, "poll: POLLNVAL on fd %d", fds[i].fd);
+ errno = EINVAL;
+ return -1;
+ }
+ if (fds[i].revents & (POLLIN | POLLHUP)) {
*fd = fds[i].fd;
return r;
}
- return r;
+ }
+ /* We should never get here. */
+ return 0;
}
static int