diff options
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 da1bf3bd1..cdc236d99 100644 --- a/ssh-agent.c +++ b/ssh-agent.c | |||
@@ -35,7 +35,7 @@ | |||
35 | 35 | ||
36 | #include "includes.h" | 36 | #include "includes.h" |
37 | #include "openbsd-compat/fake-queue.h" | 37 | #include "openbsd-compat/fake-queue.h" |
38 | RCSID("$OpenBSD: ssh-agent.c,v 1.100 2002/08/21 20:10:28 stevesk Exp $"); | 38 | RCSID("$OpenBSD: ssh-agent.c,v 1.101 2002/08/22 19:27:53 stevesk Exp $"); |
39 | 39 | ||
40 | #include <openssl/evp.h> | 40 | #include <openssl/evp.h> |
41 | #include <openssl/md5.h> | 41 | #include <openssl/md5.h> |
@@ -107,6 +107,18 @@ char *__progname; | |||
107 | #endif | 107 | #endif |
108 | 108 | ||
109 | static void | 109 | static void |
110 | close_socket(SocketEntry *e) | ||
111 | { | ||
112 | shutdown(e->fd, SHUT_RDWR); | ||
113 | close(e->fd); | ||
114 | e->fd = -1; | ||
115 | e->type = AUTH_UNUSED; | ||
116 | buffer_free(&e->input); | ||
117 | buffer_free(&e->output); | ||
118 | buffer_free(&e->request); | ||
119 | } | ||
120 | |||
121 | static void | ||
110 | idtab_init(void) | 122 | idtab_init(void) |
111 | { | 123 | { |
112 | int i; | 124 | int i; |
@@ -617,13 +629,7 @@ process_message(SocketEntry *e) | |||
617 | cp = buffer_ptr(&e->input); | 629 | cp = buffer_ptr(&e->input); |
618 | msg_len = GET_32BIT(cp); | 630 | msg_len = GET_32BIT(cp); |
619 | if (msg_len > 256 * 1024) { | 631 | if (msg_len > 256 * 1024) { |
620 | shutdown(e->fd, SHUT_RDWR); | 632 | close_socket(e); |
621 | close(e->fd); | ||
622 | e->fd = -1; | ||
623 | e->type = AUTH_UNUSED; | ||
624 | buffer_free(&e->input); | ||
625 | buffer_free(&e->output); | ||
626 | buffer_free(&e->request); | ||
627 | return; | 633 | return; |
628 | } | 634 | } |
629 | if (buffer_len(&e->input) < msg_len + 4) | 635 | if (buffer_len(&e->input) < msg_len + 4) |
@@ -836,13 +842,7 @@ after_select(fd_set *readset, fd_set *writeset) | |||
836 | break; | 842 | break; |
837 | } while (1); | 843 | } while (1); |
838 | if (len <= 0) { | 844 | if (len <= 0) { |
839 | shutdown(sockets[i].fd, SHUT_RDWR); | 845 | close_socket(&sockets[i]); |
840 | close(sockets[i].fd); | ||
841 | sockets[i].fd = -1; | ||
842 | sockets[i].type = AUTH_UNUSED; | ||
843 | buffer_free(&sockets[i].input); | ||
844 | buffer_free(&sockets[i].output); | ||
845 | buffer_free(&sockets[i].request); | ||
846 | break; | 846 | break; |
847 | } | 847 | } |
848 | buffer_consume(&sockets[i].output, len); | 848 | buffer_consume(&sockets[i].output, len); |
@@ -856,13 +856,7 @@ after_select(fd_set *readset, fd_set *writeset) | |||
856 | break; | 856 | break; |
857 | } while (1); | 857 | } while (1); |
858 | if (len <= 0) { | 858 | if (len <= 0) { |
859 | shutdown(sockets[i].fd, SHUT_RDWR); | 859 | close_socket(&sockets[i]); |
860 | close(sockets[i].fd); | ||
861 | sockets[i].fd = -1; | ||
862 | sockets[i].type = AUTH_UNUSED; | ||
863 | buffer_free(&sockets[i].input); | ||
864 | buffer_free(&sockets[i].output); | ||
865 | buffer_free(&sockets[i].request); | ||
866 | break; | 860 | break; |
867 | } | 861 | } |
868 | buffer_append(&sockets[i].input, buf, len); | 862 | buffer_append(&sockets[i].input, buf, len); |