diff options
author | Damien Miller <djm@cvs.openbsd.org> | 2008-06-12 15:19:18 +0000 |
---|---|---|
committer | Damien Miller <djm@cvs.openbsd.org> | 2008-06-12 15:19:18 +0000 |
commit | 3da59843ed86de28180c9e8495c971286b3db262 (patch) | |
tree | b3d98cba806f38084d9207c6aad715b8bc552aab /usr.bin/ssh | |
parent | b20c3776b182bdc029a6ab0f723b1ea14576130c (diff) |
The multiplexing escape char handler commit last night introduced a
small memory leak per session; plug it.
Diffstat (limited to 'usr.bin/ssh')
-rw-r--r-- | usr.bin/ssh/channels.c | 9 | ||||
-rw-r--r-- | usr.bin/ssh/channels.h | 6 | ||||
-rw-r--r-- | usr.bin/ssh/clientloop.c | 10 | ||||
-rw-r--r-- | usr.bin/ssh/clientloop.h | 3 | ||||
-rw-r--r-- | usr.bin/ssh/mux.c | 3 |
5 files changed, 24 insertions, 7 deletions
diff --git a/usr.bin/ssh/channels.c b/usr.bin/ssh/channels.c index f0c78ac0388..5171d78d05a 100644 --- a/usr.bin/ssh/channels.c +++ b/usr.bin/ssh/channels.c @@ -1,4 +1,4 @@ -/* $OpenBSD: channels.c,v 1.279 2008/06/12 03:40:52 djm Exp $ */ +/* $OpenBSD: channels.c,v 1.280 2008/06/12 15:19:17 djm Exp $ */ /* * Author: Tatu Ylonen <ylo@cs.hut.fi> * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland @@ -323,6 +323,8 @@ channel_new(char *ctype, int type, int rfd, int wfd, int efd, c->open_confirm_ctx = NULL; c->input_filter = NULL; c->output_filter = NULL; + c->filter_ctx = NULL; + c->filter_cleanup = NULL; TAILQ_INIT(&c->status_confirms); debug("channel %d: new [%s]", found, remote_name); return c; @@ -411,6 +413,8 @@ channel_free(Channel *c) bzero(cc, sizeof(*cc)); xfree(cc); } + if (c->filter_cleanup != NULL && c->filter_ctx != NULL) + c->filter_cleanup(c->self, c->filter_ctx); channels[c->self] = NULL; xfree(c); } @@ -726,7 +730,7 @@ channel_cancel_cleanup(int id) void channel_register_filter(int id, channel_infilter_fn *ifn, - channel_outfilter_fn *ofn, void *ctx) + channel_outfilter_fn *ofn, channel_filter_cleanup_fn *cfn, void *ctx) { Channel *c = channel_lookup(id); @@ -737,6 +741,7 @@ channel_register_filter(int id, channel_infilter_fn *ifn, c->input_filter = ifn; c->output_filter = ofn; c->filter_ctx = ctx; + c->filter_cleanup = cfn; } void diff --git a/usr.bin/ssh/channels.h b/usr.bin/ssh/channels.h index 7201bed9446..295774cf3e0 100644 --- a/usr.bin/ssh/channels.h +++ b/usr.bin/ssh/channels.h @@ -1,4 +1,4 @@ -/* $OpenBSD: channels.h,v 1.94 2008/06/12 03:40:52 djm Exp $ */ +/* $OpenBSD: channels.h,v 1.95 2008/06/12 15:19:17 djm Exp $ */ /* * Author: Tatu Ylonen <ylo@cs.hut.fi> @@ -62,6 +62,7 @@ typedef struct Channel Channel; typedef void channel_callback_fn(int, void *); typedef int channel_infilter_fn(struct Channel *, char *, int); +typedef void channel_filter_cleanup_fn(int, void *); typedef u_char *channel_outfilter_fn(struct Channel *, u_char **, u_int *); /* Channel success/failure callbacks */ @@ -131,6 +132,7 @@ struct Channel { channel_infilter_fn *input_filter; channel_outfilter_fn *output_filter; void *filter_ctx; + channel_filter_cleanup_fn *filter_cleanup; /* keep boundaries */ int datagram; @@ -195,7 +197,7 @@ void channel_request_start(int, char *, int); void channel_register_cleanup(int, channel_callback_fn *, int); void channel_register_open_confirm(int, channel_callback_fn *, void *); void channel_register_filter(int, channel_infilter_fn *, - channel_outfilter_fn *, void *); + channel_outfilter_fn *, channel_filter_cleanup_fn *, void *); void channel_register_status_confirm(int, channel_confirm_cb *, channel_confirm_abandon_cb *, void *); void channel_cancel_cleanup(int); diff --git a/usr.bin/ssh/clientloop.c b/usr.bin/ssh/clientloop.c index 3b1ceb8fc0b..1d73a0f529c 100644 --- a/usr.bin/ssh/clientloop.c +++ b/usr.bin/ssh/clientloop.c @@ -1,4 +1,4 @@ -/* $OpenBSD: clientloop.c,v 1.197 2008/06/12 04:17:47 djm Exp $ */ +/* $OpenBSD: clientloop.c,v 1.198 2008/06/12 15:19:17 djm Exp $ */ /* * Author: Tatu Ylonen <ylo@cs.hut.fi> * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland @@ -1252,6 +1252,13 @@ client_new_escape_filter_ctx(int escape_char) return (void *)ret; } +/* Free the escape filter context on channel free */ +void +client_filter_cleanup(int cid, void *ctx) +{ + xfree(ctx); +} + int client_simple_escape_filter(Channel *c, char *buf, int len) { @@ -1349,6 +1356,7 @@ client_loop(int have_pty, int escape_char_arg, int ssh2_chan_id) if (escape_char_arg != SSH_ESCAPECHAR_NONE) channel_register_filter(session_ident, client_simple_escape_filter, NULL, + client_filter_cleanup, client_new_escape_filter_ctx(escape_char_arg)); if (session_ident != -1) channel_register_cleanup(session_ident, diff --git a/usr.bin/ssh/clientloop.h b/usr.bin/ssh/clientloop.h index 3353a9a80d4..8bb874b3882 100644 --- a/usr.bin/ssh/clientloop.h +++ b/usr.bin/ssh/clientloop.h @@ -1,4 +1,4 @@ -/* $OpenBSD: clientloop.h,v 1.21 2008/06/12 04:06:00 djm Exp $ */ +/* $OpenBSD: clientloop.h,v 1.22 2008/06/12 15:19:17 djm Exp $ */ /* * Author: Tatu Ylonen <ylo@cs.hut.fi> @@ -48,6 +48,7 @@ int client_request_tun_fwd(int, int, int); /* Escape filter for protocol 2 sessions */ void *client_new_escape_filter_ctx(int); +void client_filter_cleanup(int, void *); int client_simple_escape_filter(Channel *, char *, int); /* Global request confirmation callbacks */ diff --git a/usr.bin/ssh/mux.c b/usr.bin/ssh/mux.c index 6ab94ddfebe..41c95697e76 100644 --- a/usr.bin/ssh/mux.c +++ b/usr.bin/ssh/mux.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mux.c,v 1.3 2008/06/12 05:32:30 djm Exp $ */ +/* $OpenBSD: mux.c,v 1.4 2008/06/12 15:19:17 djm Exp $ */ /* * Copyright (c) 2002-2008 Damien Miller <djm@openbsd.org> * @@ -424,6 +424,7 @@ muxserver_accept_control(void) if (cctx->want_tty && escape_char != 0xffffffff) { channel_register_filter(c->self, client_simple_escape_filter, NULL, + client_filter_cleanup, client_new_escape_filter_ctx((int)escape_char)); } |