diff options
author | Damien Miller <djm@mindrot.org> | 2002-09-04 16:31:21 +1000 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2002-09-04 16:31:21 +1000 |
commit | 58f3486c74aec48238501002d03839540fde3a61 (patch) | |
tree | 7af8469ff9c1db8cef92aa6ef22d8179d3e16c37 /ssh-agent.c | |
parent | 4efdfff6ba324cb71617b4bffdc8fa164a7749e0 (diff) |
- stevesk@cvs.openbsd.org 2002/08/22 19:27:53
[ssh-agent.c]
use common close function; ok markus@
Diffstat (limited to 'ssh-agent.c')
-rw-r--r-- | ssh-agent.c | 38 |
1 files changed, 16 insertions, 22 deletions
diff --git a/ssh-agent.c b/ssh-agent.c index da1bf3bd..cdc236d9 100644 --- a/ssh-agent.c +++ b/ssh-agent.c @@ -35,7 +35,7 @@ #include "includes.h" #include "openbsd-compat/fake-queue.h" -RCSID("$OpenBSD: ssh-agent.c,v 1.100 2002/08/21 20:10:28 stevesk Exp $"); +RCSID("$OpenBSD: ssh-agent.c,v 1.101 2002/08/22 19:27:53 stevesk Exp $"); #include <openssl/evp.h> #include <openssl/md5.h> @@ -107,6 +107,18 @@ char *__progname; #endif static void +close_socket(SocketEntry *e) +{ + shutdown(e->fd, SHUT_RDWR); + close(e->fd); + e->fd = -1; + e->type = AUTH_UNUSED; + buffer_free(&e->input); + buffer_free(&e->output); + buffer_free(&e->request); +} + +static void idtab_init(void) { int i; @@ -617,13 +629,7 @@ process_message(SocketEntry *e) cp = buffer_ptr(&e->input); msg_len = GET_32BIT(cp); if (msg_len > 256 * 1024) { - shutdown(e->fd, SHUT_RDWR); - close(e->fd); - e->fd = -1; - e->type = AUTH_UNUSED; - buffer_free(&e->input); - buffer_free(&e->output); - buffer_free(&e->request); + close_socket(e); return; } if (buffer_len(&e->input) < msg_len + 4) @@ -836,13 +842,7 @@ after_select(fd_set *readset, fd_set *writeset) break; } while (1); if (len <= 0) { - shutdown(sockets[i].fd, SHUT_RDWR); - close(sockets[i].fd); - sockets[i].fd = -1; - sockets[i].type = AUTH_UNUSED; - buffer_free(&sockets[i].input); - buffer_free(&sockets[i].output); - buffer_free(&sockets[i].request); + close_socket(&sockets[i]); break; } buffer_consume(&sockets[i].output, len); @@ -856,13 +856,7 @@ after_select(fd_set *readset, fd_set *writeset) break; } while (1); if (len <= 0) { - shutdown(sockets[i].fd, SHUT_RDWR); - close(sockets[i].fd); - sockets[i].fd = -1; - sockets[i].type = AUTH_UNUSED; - buffer_free(&sockets[i].input); - buffer_free(&sockets[i].output); - buffer_free(&sockets[i].request); + close_socket(&sockets[i]); break; } buffer_append(&sockets[i].input, buf, len); |