From 43f7a4b8332052d02fa70be5c30fc5ec1cedb9db Mon Sep 17 00:00:00 2001 From: djm Date: Wed, 21 Jan 2004 00:02:50 +0000 Subject: [PATCH] - markus@cvs.openbsd.org 2004/01/19 21:25:15 [auth2-hostbased.c auth2-pubkey.c serverloop.c ssh-keysign.c sshconnect2.c] fix mem leaks; some fixes from Pete Flugstad; tested dtucker@ --- ChangeLog | 3 +++ auth2-hostbased.c | 4 ++-- auth2-pubkey.c | 6 +++--- serverloop.c | 14 +++++++------- ssh-keysign.c | 3 ++- sshconnect2.c | 8 ++++---- 6 files changed, 21 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0218210a..d9168f6a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -20,6 +20,9 @@ fake consumption for half closed channels since the peer is waiting for window adjust messages; bugzilla #790 Matthew Dillon; test + ok dtucker@ reproduce with sh -c 'ulimit -f 10; ssh host -n od /bsd | cat > foo' + - markus@cvs.openbsd.org 2004/01/19 21:25:15 + [auth2-hostbased.c auth2-pubkey.c serverloop.c ssh-keysign.c sshconnect2.c] + fix mem leaks; some fixes from Pete Flugstad; tested dtucker@ 20040114 - (dtucker) [auth-pam.c] Have monitor die if PAM authentication thread exits diff --git a/auth2-hostbased.c b/auth2-hostbased.c index 505d3eff..1111ed67 100644 --- a/auth2-hostbased.c +++ b/auth2-hostbased.c @@ -23,7 +23,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: auth2-hostbased.c,v 1.5 2003/06/24 08:23:46 markus Exp $"); +RCSID("$OpenBSD: auth2-hostbased.c,v 1.6 2004/01/19 21:25:15 markus Exp $"); #include "ssh2.h" #include "xmalloc.h" @@ -114,7 +114,7 @@ userauth_hostbased(Authctxt *authctxt) buffer_len(&b))) == 1) authenticated = 1; - buffer_clear(&b); + buffer_free(&b); done: debug2("userauth_hostbased: authenticated %d", authenticated); if (key != NULL) diff --git a/auth2-pubkey.c b/auth2-pubkey.c index c28571ab..3063eecc 100644 --- a/auth2-pubkey.c +++ b/auth2-pubkey.c @@ -23,7 +23,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: auth2-pubkey.c,v 1.5 2003/11/04 08:54:09 djm Exp $"); +RCSID("$OpenBSD: auth2-pubkey.c,v 1.6 2004/01/19 21:25:15 markus Exp $"); #include "ssh2.h" #include "xmalloc.h" @@ -123,9 +123,9 @@ userauth_pubkey(Authctxt *authctxt) authenticated = 0; if (PRIVSEP(user_key_allowed(authctxt->pw, key)) && PRIVSEP(key_verify(key, sig, slen, buffer_ptr(&b), - buffer_len(&b))) == 1) + buffer_len(&b))) == 1) authenticated = 1; - buffer_clear(&b); + buffer_free(&b); xfree(sig); } else { debug("test whether pkalg/pkblob are acceptable"); diff --git a/serverloop.c b/serverloop.c index bc7cd656..a777a048 100644 --- a/serverloop.c +++ b/serverloop.c @@ -35,7 +35,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: serverloop.c,v 1.114 2003/12/09 15:28:43 markus Exp $"); +RCSID("$OpenBSD: serverloop.c,v 1.115 2004/01/19 21:25:15 markus Exp $"); #include "xmalloc.h" #include "packet.h" @@ -850,7 +850,7 @@ server_input_window_size(int type, u_int32_t seq, void *ctxt) } static Channel * -server_request_direct_tcpip(char *ctype) +server_request_direct_tcpip(void) { Channel *c; int sock; @@ -872,14 +872,14 @@ server_request_direct_tcpip(char *ctype) xfree(originator); if (sock < 0) return NULL; - c = channel_new(ctype, SSH_CHANNEL_CONNECTING, + c = channel_new("direct-tcpip", SSH_CHANNEL_CONNECTING, sock, sock, -1, CHAN_TCP_WINDOW_DEFAULT, CHAN_TCP_PACKET_DEFAULT, 0, "direct-tcpip", 1); return c; } static Channel * -server_request_session(char *ctype) +server_request_session(void) { Channel *c; @@ -891,7 +891,7 @@ server_request_session(char *ctype) * SSH_CHANNEL_LARVAL. Additionally, a callback for handling all * CHANNEL_REQUEST messages is registered. */ - c = channel_new(ctype, SSH_CHANNEL_LARVAL, + c = channel_new("session", SSH_CHANNEL_LARVAL, -1, -1, -1, /*window size*/0, CHAN_SES_PACKET_DEFAULT, 0, "server-session", 1); if (session_open(the_authctxt, c->self) != 1) { @@ -920,9 +920,9 @@ server_input_channel_open(int type, u_int32_t seq, void *ctxt) ctype, rchan, rwindow, rmaxpack); if (strcmp(ctype, "session") == 0) { - c = server_request_session(ctype); + c = server_request_session(); } else if (strcmp(ctype, "direct-tcpip") == 0) { - c = server_request_direct_tcpip(ctype); + c = server_request_direct_tcpip(); } if (c != NULL) { debug("server_input_channel_open: confirm %s", ctype); diff --git a/ssh-keysign.c b/ssh-keysign.c index b3db628c..9e9ebe2f 100644 --- a/ssh-keysign.c +++ b/ssh-keysign.c @@ -22,7 +22,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "includes.h" -RCSID("$OpenBSD: ssh-keysign.c,v 1.14 2003/11/17 09:45:39 djm Exp $"); +RCSID("$OpenBSD: ssh-keysign.c,v 1.15 2004/01/19 21:25:15 markus Exp $"); #include #include @@ -126,6 +126,7 @@ valid_request(struct passwd *pw, char *host, Key **ret, u_char *data, /* end of message */ if (buffer_len(&b) != 0) fail++; + buffer_free(&b); debug3("valid_request: fail %d", fail); diff --git a/sshconnect2.c b/sshconnect2.c index 281fecdc..3a218113 100644 --- a/sshconnect2.c +++ b/sshconnect2.c @@ -23,7 +23,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: sshconnect2.c,v 1.133 2003/11/21 11:57:03 djm Exp $"); +RCSID("$OpenBSD: sshconnect2.c,v 1.134 2004/01/19 21:25:15 markus Exp $"); #include "openbsd-compat/sys-queue.h" @@ -1267,7 +1267,7 @@ ssh_keysign(Key *key, u_char **sigp, u_int *lenp, if (ssh_msg_recv(from[0], &b) < 0) { error("ssh_keysign: no reply"); - buffer_clear(&b); + buffer_free(&b); return -1; } close(from[0]); @@ -1279,11 +1279,11 @@ ssh_keysign(Key *key, u_char **sigp, u_int *lenp, if (buffer_get_char(&b) != version) { error("ssh_keysign: bad version"); - buffer_clear(&b); + buffer_free(&b); return -1; } *sigp = buffer_get_string(&b, lenp); - buffer_clear(&b); + buffer_free(&b); return 0; } -- 2.45.1