summaryrefslogtreecommitdiff
path: root/usr.bin/ssh/ssh-agent.c
diff options
context:
space:
mode:
authorMarkus Friedl <markus@cvs.openbsd.org>2001-07-17 20:48:43 +0000
committerMarkus Friedl <markus@cvs.openbsd.org>2001-07-17 20:48:43 +0000
commit10561b5c9ceb18a25e230050ece982bb31eb35d8 (patch)
treecdd47d2277f1c9c5eb217ca7d6d6104220a36a5b /usr.bin/ssh/ssh-agent.c
parent7a185b91dd62b88b1cf1c26dd189e72bd98b70e0 (diff)
update maxfd if maxfd is closed; report from jmcelroy@dtgnet.com
Diffstat (limited to 'usr.bin/ssh/ssh-agent.c')
-rw-r--r--usr.bin/ssh/ssh-agent.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/usr.bin/ssh/ssh-agent.c b/usr.bin/ssh/ssh-agent.c
index 2d3902b560d..2b20bb5f5ba 100644
--- a/usr.bin/ssh/ssh-agent.c
+++ b/usr.bin/ssh/ssh-agent.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssh-agent.c,v 1.65 2001/07/15 16:58:29 stevesk Exp $ */
+/* $OpenBSD: ssh-agent.c,v 1.66 2001/07/17 20:48:42 markus Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -36,7 +36,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: ssh-agent.c,v 1.65 2001/07/15 16:58:29 stevesk Exp $");
+RCSID("$OpenBSD: ssh-agent.c,v 1.66 2001/07/17 20:48:42 markus Exp $");
#include <openssl/evp.h>
#include <openssl/md5.h>
@@ -652,7 +652,7 @@ new_socket(int type, int fd)
}
static int
-prepare_select(fd_set **fdrp, fd_set **fdwp, int *fdl)
+prepare_select(fd_set **fdrp, fd_set **fdwp, int *fdl, int *nallocp)
{
u_int i, sz;
int n = 0;
@@ -672,15 +672,18 @@ prepare_select(fd_set **fdrp, fd_set **fdwp, int *fdl)
}
sz = howmany(n+1, NFDBITS) * sizeof(fd_mask);
- if (*fdrp == NULL || n > *fdl) {
+ if (*fdrp == NULL || sz > *nallocp) {
if (*fdrp)
xfree(*fdrp);
if (*fdwp)
xfree(*fdwp);
*fdrp = xmalloc(sz);
*fdwp = xmalloc(sz);
- *fdl = n;
+ *nallocp = sz;
}
+ if (n < *fdl)
+ debug("XXX shrink: %d < %d", n, *fdl);
+ *fdl = n;
memset(*fdrp, 0, sz);
memset(*fdwp, 0, sz);
@@ -820,7 +823,7 @@ usage(void)
int
main(int ac, char **av)
{
- int sock, c_flag = 0, d_flag = 0, k_flag = 0, s_flag = 0, ch;
+ int sock, c_flag = 0, d_flag = 0, k_flag = 0, s_flag = 0, ch, nalloc;
struct sockaddr_un sunaddr;
struct rlimit rlim;
pid_t pid;
@@ -989,8 +992,10 @@ skip:
signal(SIGPIPE, SIG_IGN);
signal(SIGHUP, cleanup_handler);
signal(SIGTERM, cleanup_handler);
+ nalloc = 0;
+
while (1) {
- prepare_select(&readsetp, &writesetp, &max_fd);
+ prepare_select(&readsetp, &writesetp, &max_fd, &nalloc);
if (select(max_fd + 1, readsetp, writesetp, NULL, NULL) < 0) {
if (errno == EINTR)
continue;