From: millert Date: Fri, 21 Feb 1997 17:10:08 +0000 (+0000) Subject: FreeBSD PR ports/2766 (Patch from Marc Slemko marcs@znep.com): X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=025fec4d8011eb6815f2c7f84678e7cfd0570cd8;p=openbsd FreeBSD PR ports/2766 (Patch from Marc Slemko marcs@znep.com): Don't pass getdtablesize() as first arg to select(2). No need to do this since we only select on one fd--use (fd+1) as nfds. This fixes the problem with fdesc as well (though that is really an fdesc bug). Fix will be in sudo 1.5.4. --- diff --git a/gnu/usr.bin/sudo/sudo/tgetpass.c b/gnu/usr.bin/sudo/sudo/tgetpass.c index e92178517ba..0031986e293 100644 --- a/gnu/usr.bin/sudo/sudo/tgetpass.c +++ b/gnu/usr.bin/sudo/sudo/tgetpass.c @@ -27,7 +27,7 @@ */ #ifndef lint -static char rcsid[] = "$Id: tgetpass.c,v 1.2 1996/11/17 16:34:06 millert Exp $"; +static char rcsid[] = "$Id: tgetpass.c,v 1.3 1997/02/21 17:10:08 millert Exp $"; #endif /* lint */ #include "config.h" @@ -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';