diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | ssh-keyscan.c | 29 |
2 files changed, 25 insertions, 10 deletions
@@ -124,6 +124,10 @@ | |||
124 | - deraadt@cvs.openbsd.org 2001/03/03 06:53:12 | 124 | - deraadt@cvs.openbsd.org 2001/03/03 06:53:12 |
125 | [ssh-keyscan.c] | 125 | [ssh-keyscan.c] |
126 | standard theo sweep | 126 | standard theo sweep |
127 | - millert@cvs.openbsd.org 2001/03/03 21:19:41 | ||
128 | [ssh-keyscan.c] | ||
129 | Dynamically allocate read_wait and its copies. Since maxfd is | ||
130 | based on resource limits it is often (usually?) larger than FD_SETSIZE. | ||
127 | 131 | ||
128 | 20010304 | 132 | 20010304 |
129 | - (bal) Remove make-ssh-known-hosts.1 since it's no longer valid. | 133 | - (bal) Remove make-ssh-known-hosts.1 since it's no longer valid. |
@@ -4316,4 +4320,4 @@ | |||
4316 | - Wrote replacements for strlcpy and mkdtemp | 4320 | - Wrote replacements for strlcpy and mkdtemp |
4317 | - Released 1.0pre1 | 4321 | - Released 1.0pre1 |
4318 | 4322 | ||
4319 | $Id: ChangeLog,v 1.889 2001/03/05 07:01:18 mouring Exp $ | 4323 | $Id: ChangeLog,v 1.890 2001/03/05 07:04:38 mouring Exp $ |
diff --git a/ssh-keyscan.c b/ssh-keyscan.c index fe03c145c..ab46e9edb 100644 --- a/ssh-keyscan.c +++ b/ssh-keyscan.c | |||
@@ -8,7 +8,7 @@ | |||
8 | */ | 8 | */ |
9 | 9 | ||
10 | #include "includes.h" | 10 | #include "includes.h" |
11 | RCSID("$OpenBSD: ssh-keyscan.c,v 1.18 2001/03/03 06:53:12 deraadt Exp $"); | 11 | RCSID("$OpenBSD: ssh-keyscan.c,v 1.19 2001/03/03 21:19:41 millert Exp $"); |
12 | 12 | ||
13 | #if defined(HAVE_SYS_QUEUE_H) && !defined(HAVE_BOGUS_SYS_QUEUE_H) | 13 | #if defined(HAVE_SYS_QUEUE_H) && !defined(HAVE_BOGUS_SYS_QUEUE_H) |
14 | #include <sys/queue.h> | 14 | #include <sys/queue.h> |
@@ -45,7 +45,8 @@ extern char *__progname; | |||
45 | #else | 45 | #else |
46 | char *__progname; | 46 | char *__progname; |
47 | #endif | 47 | #endif |
48 | fd_set read_wait; | 48 | fd_set *read_wait; |
49 | size_t read_wait_size; | ||
49 | int ncon; | 50 | int ncon; |
50 | 51 | ||
51 | /* | 52 | /* |
@@ -361,7 +362,7 @@ conalloc(char *iname, char *oname) | |||
361 | gettimeofday(&fdcon[s].c_tv, NULL); | 362 | gettimeofday(&fdcon[s].c_tv, NULL); |
362 | fdcon[s].c_tv.tv_sec += timeout; | 363 | fdcon[s].c_tv.tv_sec += timeout; |
363 | TAILQ_INSERT_TAIL(&tq, &fdcon[s], c_link); | 364 | TAILQ_INSERT_TAIL(&tq, &fdcon[s], c_link); |
364 | FD_SET(s, &read_wait); | 365 | FD_SET(s, read_wait); |
365 | ncon++; | 366 | ncon++; |
366 | return (s); | 367 | return (s); |
367 | } | 368 | } |
@@ -378,7 +379,7 @@ confree(int s) | |||
378 | xfree(fdcon[s].c_data); | 379 | xfree(fdcon[s].c_data); |
379 | fdcon[s].c_status = CS_UNUSED; | 380 | fdcon[s].c_status = CS_UNUSED; |
380 | TAILQ_REMOVE(&tq, &fdcon[s], c_link); | 381 | TAILQ_REMOVE(&tq, &fdcon[s], c_link); |
381 | FD_CLR(s, &read_wait); | 382 | FD_CLR(s, read_wait); |
382 | ncon--; | 383 | ncon--; |
383 | } | 384 | } |
384 | 385 | ||
@@ -481,7 +482,7 @@ conread(int s) | |||
481 | void | 482 | void |
482 | conloop(void) | 483 | conloop(void) |
483 | { | 484 | { |
484 | fd_set r, e; | 485 | fd_set *r, *e; |
485 | struct timeval seltime, now; | 486 | struct timeval seltime, now; |
486 | int i; | 487 | int i; |
487 | con *c; | 488 | con *c; |
@@ -501,18 +502,24 @@ conloop(void) | |||
501 | } else | 502 | } else |
502 | seltime.tv_sec = seltime.tv_usec = 0; | 503 | seltime.tv_sec = seltime.tv_usec = 0; |
503 | 504 | ||
504 | r = e = read_wait; | 505 | r = xmalloc(read_wait_size); |
505 | while (select(maxfd, &r, NULL, &e, &seltime) == -1 && | 506 | memcpy(r, read_wait, read_wait_size); |
507 | e = xmalloc(read_wait_size); | ||
508 | memcpy(e, read_wait, read_wait_size); | ||
509 | |||
510 | while (select(maxfd, r, NULL, e, &seltime) == -1 && | ||
506 | (errno == EAGAIN || errno == EINTR)) | 511 | (errno == EAGAIN || errno == EINTR)) |
507 | ; | 512 | ; |
508 | 513 | ||
509 | for (i = 0; i < maxfd; i++) { | 514 | for (i = 0; i < maxfd; i++) { |
510 | if (FD_ISSET(i, &e)) { | 515 | if (FD_ISSET(i, e)) { |
511 | error("%s: exception!", fdcon[i].c_name); | 516 | error("%s: exception!", fdcon[i].c_name); |
512 | confree(i); | 517 | confree(i); |
513 | } else if (FD_ISSET(i, &r)) | 518 | } else if (FD_ISSET(i, r)) |
514 | conread(i); | 519 | conread(i); |
515 | } | 520 | } |
521 | xfree(r); | ||
522 | xfree(e); | ||
516 | 523 | ||
517 | c = tq.tqh_first; | 524 | c = tq.tqh_first; |
518 | while (c && (c->c_tv.tv_sec < now.tv_sec || | 525 | while (c && (c->c_tv.tv_sec < now.tv_sec || |
@@ -612,6 +619,10 @@ main(int argc, char **argv) | |||
612 | fdcon = xmalloc(maxfd * sizeof(con)); | 619 | fdcon = xmalloc(maxfd * sizeof(con)); |
613 | memset(fdcon, 0, maxfd * sizeof(con)); | 620 | memset(fdcon, 0, maxfd * sizeof(con)); |
614 | 621 | ||
622 | read_wait_size = howmany(maxfd, NFDBITS) * sizeof(fd_mask); | ||
623 | read_wait = xmalloc(read_wait_size); | ||
624 | memset(read_wait, 0, read_wait_size); | ||
625 | |||
615 | do { | 626 | do { |
616 | while (ncon < MAXCON) { | 627 | while (ncon < MAXCON) { |
617 | char *name; | 628 | char *name; |