Index: b/cipher/rndlinux.c =================================================================== --- b/cipher/rndlinux.c +++ b/cipher/rndlinux.c @@ -117,28 +117,33 @@ #endif #endif while( length ) { +#ifdef FD_SETSIZE fd_set rfds; struct timeval tv; - int rc; + int rc; FD_ZERO(&rfds); - FD_SET(fd, &rfds); tv.tv_sec = 3; tv.tv_usec = 0; - if( !(rc=select(fd+1, &rfds, NULL, NULL, &tv)) ) { - if( !warn ) + if (fd < FD_SETSIZE) + { + FD_SET(fd, &rfds); + if( !(rc=select(fd+1, &rfds, NULL, NULL, &tv)) ) { + if( !warn ) tty_printf( _("\n" "Not enough random bytes available. Please do some other work to give\n" "the OS a chance to collect more entropy! (Need %d more bytes)\n"), (int)length ); - warn = 1; - continue; - } - else if( rc == -1 ) { - tty_printf( - "select() error: %s\n", strerror(errno)); - continue; - } + warn = 1; + continue; + } + else if( rc == -1 ) { + tty_printf( + "select() error: %s\n", strerror(errno)); + continue; + } + } +#endif /*FD_SETSIZE*/ do { int nbytes = length < sizeof(buffer)? length : sizeof(buffer); Index: b/cipher/rndunix.c =================================================================== --- b/cipher/rndunix.c +++ b/cipher/rndunix.c @@ -290,10 +290,10 @@ /* This is a complex and screwball program. Some systems have things * like rX_dmn, x = integer, for RAID systems, but the statistics are * pretty dodgy */ -#ifdef __QNXNTO__ +#ifdef __QNXNTO__ { "/bin/pidin", "-F%A%B%c%d%E%I%J%K%m%M%n%N%p%P%S%s%T", SC(0.3), NULL, 0, 0, 0, 0 }, -#endif +#endif #if 0 /* The following aren't enabled since they're somewhat slow and not very * unpredictable, however they give an indication of the sort of sources @@ -625,6 +625,8 @@ FD_ZERO(&fds); for (i = 0; dataSources[i].path != NULL; i++) { if (dataSources[i].pipe != NULL) { + /* FIXME: We need to make sure that PIPEFD is less + than FD_SETSIZE. */ FD_SET(dataSources[i].pipeFD, &fds); moreSources = 1; } @@ -707,7 +709,7 @@ #else nmax = 20; /* assume a reasonable value */ #endif - { + { int fd; if ((fd = open ("/dev/null", O_RDWR)) != -1) { dup2 (fd, STDIN_FILENO);