summaryrefslogtreecommitdiff
path: root/usr.bin/ssh
diff options
context:
space:
mode:
authorKevin Steves <stevesk@cvs.openbsd.org>2002-08-22 19:27:54 +0000
committerKevin Steves <stevesk@cvs.openbsd.org>2002-08-22 19:27:54 +0000
commite3b7fd288bb439436bb3ac7d8ba8e36d87703e1a (patch)
tree2d96b9e54b0386836d93714b95c61f5cf5ba8665 /usr.bin/ssh
parent0ef60d853496c4e43402fb804192bfe0b64132f3 (diff)
use common close function; ok markus@
Diffstat (limited to 'usr.bin/ssh')
-rw-r--r--usr.bin/ssh/ssh-agent.c38
1 files changed, 16 insertions, 22 deletions
diff --git a/usr.bin/ssh/ssh-agent.c b/usr.bin/ssh/ssh-agent.c
index 14298fdb24f..6723148a8dc 100644
--- a/usr.bin/ssh/ssh-agent.c
+++ b/usr.bin/ssh/ssh-agent.c
@@ -35,7 +35,7 @@
#include "includes.h"
#include <sys/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>
@@ -103,6 +103,18 @@ char *lock_passwd = NULL;
extern char *__progname;
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;
@@ -613,13 +625,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)
@@ -832,13 +838,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);
@@ -852,13 +852,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);