diff options
| author | Roy Marples <roy@marples.name> | 2009-02-23 12:19:52 +0000 |
|---|---|---|
| committer | Roy Marples <roy@marples.name> | 2009-02-23 12:19:52 +0000 |
| commit | 94872ce7d36d016e5dcf37b336e216dc9d6ad145 (patch) | |
| tree | 60607aa8f0643f0b7458315d3b0bc019c0667f21 | |
| parent | 893d878748cc494436639bfc6282ea7726e62dd5 (diff) | |
| download | dhcpcd-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.c | 18 |
1 files changed, 15 insertions, 3 deletions
@@ -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 |
