From: Todd C. Miller Date: Sun, 23 Nov 1997 18:24:31 +0000 (+0000) Subject: use fileno(input) + 1 instead of getdtablesize() as the nfds arg to select(2) X-Git-Tag: SUDO_1_5_4~17 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ea498e61d3d2413bfb775297074fe8da8aae3702;p=sudo use fileno(input) + 1 instead of getdtablesize() as the nfds arg to select(2) --- diff --git a/tgetpass.c b/tgetpass.c index f7fab9150..be0ab0edf 100644 --- a/tgetpass.c +++ b/tgetpass.c @@ -206,18 +206,12 @@ char * tgetpass(prompt, timeout, user, host) tv.tv_sec = timeout; tv.tv_usec = 0; - /* how many file descriptors may we have? */ -#ifdef HAVE_SYSCONF - n = sysconf(_SC_OPEN_MAX); -#else - n = getdtablesize(); -#endif /* HAVE_SYSCONF */ - /* * get password or return empty string if nothing to read by timeout */ buf[0] = '\0'; - if (select(n, &readfds, 0, 0, &tv) > 0 && fgets(buf, sizeof(buf), input)) { + if (select(fileno(input) + 1, &readfds, 0, 0, &tv) > 0 && + fgets(buf, sizeof(buf), input)) { n = strlen(buf); if (buf[n - 1] == '\n') buf[n - 1] = '\0';