diff options
author | Simo Sorce <ssorce@redhat.com> | 2011-05-03 12:15:07 -0400 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2011-05-03 13:02:53 -0400 |
commit | e5627351445d23fc3994263419bf746c8e1c95cf (patch) | |
tree | 5b9912ef9922318cdf204c1b7b47994d238f1f82 | |
parent | 0f26d4060418fea4d2aa5de433ee6b0505e750fd (diff) | |
download | sssd-1.5.1-34.el6.tar.gz sssd-1.5.1-34.el6.tar.xz sssd-1.5.1-34.el6.zip |
clients: use poll instead of selectsssd-1.5.1-34.el6
select is limited to fd numbers up to 1024, we need to use poll() here
to avoid causing memory corruption in the calling process.
Fixes: https://fedorahosted.org/sssd/ticket/861
-rw-r--r-- | src/sss_client/common.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/src/sss_client/common.c b/src/sss_client/common.c index d4b230889..c17629a9f 100644 --- a/src/sss_client/common.c +++ b/src/sss_client/common.c @@ -501,6 +501,7 @@ static int sss_nss_open_socket(int *errnop, const char *socket_name) bool connected = false; unsigned int wait_time; unsigned int sleep_time; + time_t start_time = time(NULL); int ret; int sd; @@ -529,8 +530,7 @@ static int sss_nss_open_socket(int *errnop, const char *socket_name) while (inprogress) { int connect_errno = 0; socklen_t errnosize; - struct timeval tv; - fd_set w_fds; + struct pollfd pfd; wait_time += sleep_time; @@ -543,12 +543,10 @@ static int sss_nss_open_socket(int *errnop, const char *socket_name) switch(errno) { case EINPROGRESS: - FD_ZERO(&w_fds); - FD_SET(sd, &w_fds); - tv.tv_sec = SSS_CLI_SOCKET_TIMEOUT - wait_time; - tv.tv_usec = 0; + pfd.fd = sd; + pfd.events = POLLOUT; - ret = select(sd + 1, NULL, &w_fds, NULL, &tv); + ret = poll(&pfd, 1, SSS_CLI_SOCKET_TIMEOUT - wait_time); if (ret > 0) { errnosize = sizeof(connect_errno); @@ -559,8 +557,7 @@ static int sss_nss_open_socket(int *errnop, const char *socket_name) break; } } - wait_time += tv.tv_sec; - if (tv.tv_usec != 0) wait_time++; + wait_time = time(NULL) - start_time; break; case EAGAIN: if (wait_time < SSS_CLI_SOCKET_TIMEOUT) { |