summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarren Tucker <dtucker@zip.com.au>2008-06-13 04:55:46 +1000
committerDarren Tucker <dtucker@zip.com.au>2008-06-13 04:55:46 +1000
commit84c56f536ca664f79172d595e088fce6aa84be21 (patch)
treeed9f037d4935c1bb0a59c8a0dd3e815883a07fa2
parent4b3b9773ec9d5e0de31a1a8e113488497c7113dc (diff)
- djm@cvs.openbsd.org 2008/06/12 15:19:17
[clientloop.h channels.h clientloop.c channels.c mux.c] The multiplexing escape char handler commit last night introduced a small memory leak per session; plug it.
-rw-r--r--ChangeLog6
-rw-r--r--channels.c9
-rw-r--r--channels.h6
-rw-r--r--clientloop.c10
-rw-r--r--clientloop.h3
-rw-r--r--mux.c3
6 files changed, 29 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index 12471ba3b..0aec356d3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -108,6 +108,10 @@
108 We already mark the start of the worm, now also mark the end of the worm 108 We already mark the start of the worm, now also mark the end of the worm
109 in our random art drawings. 109 in our random art drawings.
110 ok djm@ 110 ok djm@
111 - djm@cvs.openbsd.org 2008/06/12 15:19:17
112 [clientloop.h channels.h clientloop.c channels.c mux.c]
113 The multiplexing escape char handler commit last night introduced a
114 small memory leak per session; plug it.
111 115
11220080611 11620080611
113 - (djm) [channels.c configure.ac] 117 - (djm) [channels.c configure.ac]
@@ -4270,4 +4274,4 @@
4270 OpenServer 6 and add osr5bigcrypt support so when someone migrates 4274 OpenServer 6 and add osr5bigcrypt support so when someone migrates
4271 passwords between UnixWare and OpenServer they will still work. OK dtucker@ 4275 passwords between UnixWare and OpenServer they will still work. OK dtucker@
4272 4276
4273$Id: ChangeLog,v 1.4983 2008/06/12 18:55:10 dtucker Exp $ 4277$Id: ChangeLog,v 1.4984 2008/06/12 18:55:46 dtucker Exp $
diff --git a/channels.c b/channels.c
index c539990f6..04cd6b0a7 100644
--- a/channels.c
+++ b/channels.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: channels.c,v 1.279 2008/06/12 03:40:52 djm Exp $ */ 1/* $OpenBSD: channels.c,v 1.280 2008/06/12 15:19:17 djm Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -328,6 +328,8 @@ channel_new(char *ctype, int type, int rfd, int wfd, int efd,
328 c->open_confirm_ctx = NULL; 328 c->open_confirm_ctx = NULL;
329 c->input_filter = NULL; 329 c->input_filter = NULL;
330 c->output_filter = NULL; 330 c->output_filter = NULL;
331 c->filter_ctx = NULL;
332 c->filter_cleanup = NULL;
331 TAILQ_INIT(&c->status_confirms); 333 TAILQ_INIT(&c->status_confirms);
332 debug("channel %d: new [%s]", found, remote_name); 334 debug("channel %d: new [%s]", found, remote_name);
333 return c; 335 return c;
@@ -416,6 +418,8 @@ channel_free(Channel *c)
416 bzero(cc, sizeof(*cc)); 418 bzero(cc, sizeof(*cc));
417 xfree(cc); 419 xfree(cc);
418 } 420 }
421 if (c->filter_cleanup != NULL && c->filter_ctx != NULL)
422 c->filter_cleanup(c->self, c->filter_ctx);
419 channels[c->self] = NULL; 423 channels[c->self] = NULL;
420 xfree(c); 424 xfree(c);
421} 425}
@@ -731,7 +735,7 @@ channel_cancel_cleanup(int id)
731 735
732void 736void
733channel_register_filter(int id, channel_infilter_fn *ifn, 737channel_register_filter(int id, channel_infilter_fn *ifn,
734 channel_outfilter_fn *ofn, void *ctx) 738 channel_outfilter_fn *ofn, channel_filter_cleanup_fn *cfn, void *ctx)
735{ 739{
736 Channel *c = channel_lookup(id); 740 Channel *c = channel_lookup(id);
737 741
@@ -742,6 +746,7 @@ channel_register_filter(int id, channel_infilter_fn *ifn,
742 c->input_filter = ifn; 746 c->input_filter = ifn;
743 c->output_filter = ofn; 747 c->output_filter = ofn;
744 c->filter_ctx = ctx; 748 c->filter_ctx = ctx;
749 c->filter_cleanup = cfn;
745} 750}
746 751
747void 752void
diff --git a/channels.h b/channels.h
index 450321d43..ec8ea1c40 100644
--- a/channels.h
+++ b/channels.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: channels.h,v 1.94 2008/06/12 03:40:52 djm Exp $ */ 1/* $OpenBSD: channels.h,v 1.95 2008/06/12 15:19:17 djm Exp $ */
2 2
3/* 3/*
4 * Author: Tatu Ylonen <ylo@cs.hut.fi> 4 * Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -62,6 +62,7 @@ typedef struct Channel Channel;
62 62
63typedef void channel_callback_fn(int, void *); 63typedef void channel_callback_fn(int, void *);
64typedef int channel_infilter_fn(struct Channel *, char *, int); 64typedef int channel_infilter_fn(struct Channel *, char *, int);
65typedef void channel_filter_cleanup_fn(int, void *);
65typedef u_char *channel_outfilter_fn(struct Channel *, u_char **, u_int *); 66typedef u_char *channel_outfilter_fn(struct Channel *, u_char **, u_int *);
66 67
67/* Channel success/failure callbacks */ 68/* Channel success/failure callbacks */
@@ -132,6 +133,7 @@ struct Channel {
132 channel_infilter_fn *input_filter; 133 channel_infilter_fn *input_filter;
133 channel_outfilter_fn *output_filter; 134 channel_outfilter_fn *output_filter;
134 void *filter_ctx; 135 void *filter_ctx;
136 channel_filter_cleanup_fn *filter_cleanup;
135 137
136 /* keep boundaries */ 138 /* keep boundaries */
137 int datagram; 139 int datagram;
@@ -196,7 +198,7 @@ void channel_request_start(int, char *, int);
196void channel_register_cleanup(int, channel_callback_fn *, int); 198void channel_register_cleanup(int, channel_callback_fn *, int);
197void channel_register_open_confirm(int, channel_callback_fn *, void *); 199void channel_register_open_confirm(int, channel_callback_fn *, void *);
198void channel_register_filter(int, channel_infilter_fn *, 200void channel_register_filter(int, channel_infilter_fn *,
199 channel_outfilter_fn *, void *); 201 channel_outfilter_fn *, channel_filter_cleanup_fn *, void *);
200void channel_register_status_confirm(int, channel_confirm_cb *, 202void channel_register_status_confirm(int, channel_confirm_cb *,
201 channel_confirm_abandon_cb *, void *); 203 channel_confirm_abandon_cb *, void *);
202void channel_cancel_cleanup(int); 204void channel_cancel_cleanup(int);
diff --git a/clientloop.c b/clientloop.c
index 663daae76..d2407ed7e 100644
--- a/clientloop.c
+++ b/clientloop.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: clientloop.c,v 1.197 2008/06/12 04:17:47 djm Exp $ */ 1/* $OpenBSD: clientloop.c,v 1.198 2008/06/12 15:19:17 djm Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -1260,6 +1260,13 @@ client_new_escape_filter_ctx(int escape_char)
1260 return (void *)ret; 1260 return (void *)ret;
1261} 1261}
1262 1262
1263/* Free the escape filter context on channel free */
1264void
1265client_filter_cleanup(int cid, void *ctx)
1266{
1267 xfree(ctx);
1268}
1269
1263int 1270int
1264client_simple_escape_filter(Channel *c, char *buf, int len) 1271client_simple_escape_filter(Channel *c, char *buf, int len)
1265{ 1272{
@@ -1357,6 +1364,7 @@ client_loop(int have_pty, int escape_char_arg, int ssh2_chan_id)
1357 if (escape_char_arg != SSH_ESCAPECHAR_NONE) 1364 if (escape_char_arg != SSH_ESCAPECHAR_NONE)
1358 channel_register_filter(session_ident, 1365 channel_register_filter(session_ident,
1359 client_simple_escape_filter, NULL, 1366 client_simple_escape_filter, NULL,
1367 client_filter_cleanup,
1360 client_new_escape_filter_ctx(escape_char_arg)); 1368 client_new_escape_filter_ctx(escape_char_arg));
1361 if (session_ident != -1) 1369 if (session_ident != -1)
1362 channel_register_cleanup(session_ident, 1370 channel_register_cleanup(session_ident,
diff --git a/clientloop.h b/clientloop.h
index 3353a9a80..8bb874b38 100644
--- a/clientloop.h
+++ b/clientloop.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: clientloop.h,v 1.21 2008/06/12 04:06:00 djm Exp $ */ 1/* $OpenBSD: clientloop.h,v 1.22 2008/06/12 15:19:17 djm Exp $ */
2 2
3/* 3/*
4 * Author: Tatu Ylonen <ylo@cs.hut.fi> 4 * Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -48,6 +48,7 @@ int client_request_tun_fwd(int, int, int);
48 48
49/* Escape filter for protocol 2 sessions */ 49/* Escape filter for protocol 2 sessions */
50void *client_new_escape_filter_ctx(int); 50void *client_new_escape_filter_ctx(int);
51void client_filter_cleanup(int, void *);
51int client_simple_escape_filter(Channel *, char *, int); 52int client_simple_escape_filter(Channel *, char *, int);
52 53
53/* Global request confirmation callbacks */ 54/* Global request confirmation callbacks */
diff --git a/mux.c b/mux.c
index f5e68f653..8f7bfb793 100644
--- a/mux.c
+++ b/mux.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: mux.c,v 1.3 2008/06/12 05:32:30 djm Exp $ */ 1/* $OpenBSD: mux.c,v 1.4 2008/06/12 15:19:17 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2002-2008 Damien Miller <djm@openbsd.org> 3 * Copyright (c) 2002-2008 Damien Miller <djm@openbsd.org>
4 * 4 *
@@ -436,6 +436,7 @@ muxserver_accept_control(void)
436 if (cctx->want_tty && escape_char != 0xffffffff) { 436 if (cctx->want_tty && escape_char != 0xffffffff) {
437 channel_register_filter(c->self, 437 channel_register_filter(c->self,
438 client_simple_escape_filter, NULL, 438 client_simple_escape_filter, NULL,
439 client_filter_cleanup,
439 client_new_escape_filter_ctx((int)escape_char)); 440 client_new_escape_filter_ctx((int)escape_char));
440 } 441 }
441 442