From: Roy Marples Date: Mon, 23 Feb 2009 12:19:52 +0000 (+0000) Subject: If we get POLLERR or POLLNVAL then we should not return >0 with an fd. X-Git-Tag: v4.0.12~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=94872ce7d36d016e5dcf37b336e216dc9d6ad145;p=thirdparty%2Fdhcpcd.git If we get POLLERR or POLLNVAL then we should not return >0 with an fd. Thanks to Michael Olney. --- 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