diff options
Diffstat (limited to 'ssh-agent.c')
-rw-r--r-- | ssh-agent.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/ssh-agent.c b/ssh-agent.c index 4ddad9473..ad4cbf06d 100644 --- a/ssh-agent.c +++ b/ssh-agent.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssh-agent.c,v 1.65 2001/07/15 16:58:29 stevesk Exp $ */ | 1 | /* $OpenBSD: ssh-agent.c,v 1.66 2001/07/17 20:48:42 markus Exp $ */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 4 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
@@ -36,7 +36,7 @@ | |||
36 | */ | 36 | */ |
37 | 37 | ||
38 | #include "includes.h" | 38 | #include "includes.h" |
39 | RCSID("$OpenBSD: ssh-agent.c,v 1.65 2001/07/15 16:58:29 stevesk Exp $"); | 39 | RCSID("$OpenBSD: ssh-agent.c,v 1.66 2001/07/17 20:48:42 markus Exp $"); |
40 | 40 | ||
41 | #include <openssl/evp.h> | 41 | #include <openssl/evp.h> |
42 | #include <openssl/md5.h> | 42 | #include <openssl/md5.h> |
@@ -656,7 +656,7 @@ new_socket(int type, int fd) | |||
656 | } | 656 | } |
657 | 657 | ||
658 | static int | 658 | static int |
659 | prepare_select(fd_set **fdrp, fd_set **fdwp, int *fdl) | 659 | prepare_select(fd_set **fdrp, fd_set **fdwp, int *fdl, int *nallocp) |
660 | { | 660 | { |
661 | u_int i, sz; | 661 | u_int i, sz; |
662 | int n = 0; | 662 | int n = 0; |
@@ -676,15 +676,18 @@ prepare_select(fd_set **fdrp, fd_set **fdwp, int *fdl) | |||
676 | } | 676 | } |
677 | 677 | ||
678 | sz = howmany(n+1, NFDBITS) * sizeof(fd_mask); | 678 | sz = howmany(n+1, NFDBITS) * sizeof(fd_mask); |
679 | if (*fdrp == NULL || n > *fdl) { | 679 | if (*fdrp == NULL || sz > *nallocp) { |
680 | if (*fdrp) | 680 | if (*fdrp) |
681 | xfree(*fdrp); | 681 | xfree(*fdrp); |
682 | if (*fdwp) | 682 | if (*fdwp) |
683 | xfree(*fdwp); | 683 | xfree(*fdwp); |
684 | *fdrp = xmalloc(sz); | 684 | *fdrp = xmalloc(sz); |
685 | *fdwp = xmalloc(sz); | 685 | *fdwp = xmalloc(sz); |
686 | *fdl = n; | 686 | *nallocp = sz; |
687 | } | 687 | } |
688 | if (n < *fdl) | ||
689 | debug("XXX shrink: %d < %d", n, *fdl); | ||
690 | *fdl = n; | ||
688 | memset(*fdrp, 0, sz); | 691 | memset(*fdrp, 0, sz); |
689 | memset(*fdwp, 0, sz); | 692 | memset(*fdwp, 0, sz); |
690 | 693 | ||
@@ -824,7 +827,7 @@ usage(void) | |||
824 | int | 827 | int |
825 | main(int ac, char **av) | 828 | main(int ac, char **av) |
826 | { | 829 | { |
827 | int sock, c_flag = 0, d_flag = 0, k_flag = 0, s_flag = 0, ch; | 830 | int sock, c_flag = 0, d_flag = 0, k_flag = 0, s_flag = 0, ch, nalloc; |
828 | struct sockaddr_un sunaddr; | 831 | struct sockaddr_un sunaddr; |
829 | #ifdef HAVE_SETRLIMIT | 832 | #ifdef HAVE_SETRLIMIT |
830 | struct rlimit rlim; | 833 | struct rlimit rlim; |
@@ -1017,8 +1020,10 @@ skip: | |||
1017 | signal(SIGPIPE, SIG_IGN); | 1020 | signal(SIGPIPE, SIG_IGN); |
1018 | signal(SIGHUP, cleanup_handler); | 1021 | signal(SIGHUP, cleanup_handler); |
1019 | signal(SIGTERM, cleanup_handler); | 1022 | signal(SIGTERM, cleanup_handler); |
1023 | nalloc = 0; | ||
1024 | |||
1020 | while (1) { | 1025 | while (1) { |
1021 | prepare_select(&readsetp, &writesetp, &max_fd); | 1026 | prepare_select(&readsetp, &writesetp, &max_fd, &nalloc); |
1022 | if (select(max_fd + 1, readsetp, writesetp, NULL, NULL) < 0) { | 1027 | if (select(max_fd + 1, readsetp, writesetp, NULL, NULL) < 0) { |
1023 | if (errno == EINTR) | 1028 | if (errno == EINTR) |
1024 | continue; | 1029 | continue; |