mirror of git://anongit.mindrot.org/openssh.git
- millert@cvs.openbsd.org 2001/03/03 21:19:41
[ssh-keyscan.c] Dynamically allocate read_wait and its copies. Since maxfd is based on resource limits it is often (usually?) larger than FD_SETSIZE.
This commit is contained in:
parent
d20b855bc6
commit
c1e0421cb4
|
@ -124,6 +124,10 @@
|
|||
- deraadt@cvs.openbsd.org 2001/03/03 06:53:12
|
||||
[ssh-keyscan.c]
|
||||
standard theo sweep
|
||||
- millert@cvs.openbsd.org 2001/03/03 21:19:41
|
||||
[ssh-keyscan.c]
|
||||
Dynamically allocate read_wait and its copies. Since maxfd is
|
||||
based on resource limits it is often (usually?) larger than FD_SETSIZE.
|
||||
|
||||
20010304
|
||||
- (bal) Remove make-ssh-known-hosts.1 since it's no longer valid.
|
||||
|
@ -4316,4 +4320,4 @@
|
|||
- Wrote replacements for strlcpy and mkdtemp
|
||||
- Released 1.0pre1
|
||||
|
||||
$Id: ChangeLog,v 1.889 2001/03/05 07:01:18 mouring Exp $
|
||||
$Id: ChangeLog,v 1.890 2001/03/05 07:04:38 mouring Exp $
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
*/
|
||||
|
||||
#include "includes.h"
|
||||
RCSID("$OpenBSD: ssh-keyscan.c,v 1.18 2001/03/03 06:53:12 deraadt Exp $");
|
||||
RCSID("$OpenBSD: ssh-keyscan.c,v 1.19 2001/03/03 21:19:41 millert Exp $");
|
||||
|
||||
#if defined(HAVE_SYS_QUEUE_H) && !defined(HAVE_BOGUS_SYS_QUEUE_H)
|
||||
#include <sys/queue.h>
|
||||
|
@ -45,7 +45,8 @@ extern char *__progname;
|
|||
#else
|
||||
char *__progname;
|
||||
#endif
|
||||
fd_set read_wait;
|
||||
fd_set *read_wait;
|
||||
size_t read_wait_size;
|
||||
int ncon;
|
||||
|
||||
/*
|
||||
|
@ -361,7 +362,7 @@ conalloc(char *iname, char *oname)
|
|||
gettimeofday(&fdcon[s].c_tv, NULL);
|
||||
fdcon[s].c_tv.tv_sec += timeout;
|
||||
TAILQ_INSERT_TAIL(&tq, &fdcon[s], c_link);
|
||||
FD_SET(s, &read_wait);
|
||||
FD_SET(s, read_wait);
|
||||
ncon++;
|
||||
return (s);
|
||||
}
|
||||
|
@ -378,7 +379,7 @@ confree(int s)
|
|||
xfree(fdcon[s].c_data);
|
||||
fdcon[s].c_status = CS_UNUSED;
|
||||
TAILQ_REMOVE(&tq, &fdcon[s], c_link);
|
||||
FD_CLR(s, &read_wait);
|
||||
FD_CLR(s, read_wait);
|
||||
ncon--;
|
||||
}
|
||||
|
||||
|
@ -481,7 +482,7 @@ conread(int s)
|
|||
void
|
||||
conloop(void)
|
||||
{
|
||||
fd_set r, e;
|
||||
fd_set *r, *e;
|
||||
struct timeval seltime, now;
|
||||
int i;
|
||||
con *c;
|
||||
|
@ -501,18 +502,24 @@ conloop(void)
|
|||
} else
|
||||
seltime.tv_sec = seltime.tv_usec = 0;
|
||||
|
||||
r = e = read_wait;
|
||||
while (select(maxfd, &r, NULL, &e, &seltime) == -1 &&
|
||||
r = xmalloc(read_wait_size);
|
||||
memcpy(r, read_wait, read_wait_size);
|
||||
e = xmalloc(read_wait_size);
|
||||
memcpy(e, read_wait, read_wait_size);
|
||||
|
||||
while (select(maxfd, r, NULL, e, &seltime) == -1 &&
|
||||
(errno == EAGAIN || errno == EINTR))
|
||||
;
|
||||
|
||||
for (i = 0; i < maxfd; i++) {
|
||||
if (FD_ISSET(i, &e)) {
|
||||
if (FD_ISSET(i, e)) {
|
||||
error("%s: exception!", fdcon[i].c_name);
|
||||
confree(i);
|
||||
} else if (FD_ISSET(i, &r))
|
||||
} else if (FD_ISSET(i, r))
|
||||
conread(i);
|
||||
}
|
||||
xfree(r);
|
||||
xfree(e);
|
||||
|
||||
c = tq.tqh_first;
|
||||
while (c && (c->c_tv.tv_sec < now.tv_sec ||
|
||||
|
@ -612,6 +619,10 @@ main(int argc, char **argv)
|
|||
fdcon = xmalloc(maxfd * sizeof(con));
|
||||
memset(fdcon, 0, maxfd * sizeof(con));
|
||||
|
||||
read_wait_size = howmany(maxfd, NFDBITS) * sizeof(fd_mask);
|
||||
read_wait = xmalloc(read_wait_size);
|
||||
memset(read_wait, 0, read_wait_size);
|
||||
|
||||
do {
|
||||
while (ncon < MAXCON) {
|
||||
char *name;
|
||||
|
|
Loading…
Reference in New Issue