mirror of
git://git.gnupg.org/gnupg.git
synced 2025-04-17 15:44:34 +02:00
Fix a problem with select and high fds.
* cipher/rndlinux.c (rndlinux_gather_random): Check fd before using FD_SET. -- If on systems where the maximum number of fds may be dynamically configured to a value of FD_MAXSIZE or higher and the RNG is first used after more than FD_SETSIZE-1 descriptors are in use, we disable the progress messages from the RNG. A better solution would be too use poll but that requires more tests. The same problem exists in rndunix.c - however this rng is only used on old Unices and I assume that they don't feature dynamically configured maximum fd sizes. (from Libgcrypt commit 9487099071af4478d2882e633a0ade805801d6fa) This may fix GnuPG-bug-id: 1818
This commit is contained in:
parent
ed6287d2e1
commit
8adb5ff260
@ -117,14 +117,17 @@ rndlinux_gather_random( void (*add)(const void*, size_t, int), int requester,
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
while( length ) {
|
while( length ) {
|
||||||
|
#ifdef FD_SETSIZE
|
||||||
fd_set rfds;
|
fd_set rfds;
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
FD_ZERO(&rfds);
|
FD_ZERO(&rfds);
|
||||||
FD_SET(fd, &rfds);
|
|
||||||
tv.tv_sec = 3;
|
tv.tv_sec = 3;
|
||||||
tv.tv_usec = 0;
|
tv.tv_usec = 0;
|
||||||
|
if (fd < FD_SETSIZE)
|
||||||
|
{
|
||||||
|
FD_SET(fd, &rfds);
|
||||||
if( !(rc=select(fd+1, &rfds, NULL, NULL, &tv)) ) {
|
if( !(rc=select(fd+1, &rfds, NULL, NULL, &tv)) ) {
|
||||||
if( !warn )
|
if( !warn )
|
||||||
tty_printf(
|
tty_printf(
|
||||||
@ -139,6 +142,8 @@ _("\n"
|
|||||||
"select() error: %s\n", strerror(errno));
|
"select() error: %s\n", strerror(errno));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
#endif /*FD_SETSIZE*/
|
||||||
|
|
||||||
do {
|
do {
|
||||||
int nbytes = length < sizeof(buffer)? length : sizeof(buffer);
|
int nbytes = length < sizeof(buffer)? length : sizeof(buffer);
|
||||||
|
@ -625,6 +625,8 @@ slow_poll(FILE *dbgfp, int dbgall, size_t *nbytes )
|
|||||||
FD_ZERO(&fds);
|
FD_ZERO(&fds);
|
||||||
for (i = 0; dataSources[i].path != NULL; i++) {
|
for (i = 0; dataSources[i].path != NULL; i++) {
|
||||||
if (dataSources[i].pipe != NULL) {
|
if (dataSources[i].pipe != NULL) {
|
||||||
|
/* FIXME: We need to make sure that PIPEFD is less
|
||||||
|
than FD_SETSIZE. */
|
||||||
FD_SET(dataSources[i].pipeFD, &fds);
|
FD_SET(dataSources[i].pipeFD, &fds);
|
||||||
moreSources = 1;
|
moreSources = 1;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user