]> andersk Git - openssh.git/commitdiff
- djm@cvs.openbsd.org 2008/06/12 15:19:17
authordtucker <dtucker>
Thu, 12 Jun 2008 18:55:46 +0000 (18:55 +0000)
committerdtucker <dtucker>
Thu, 12 Jun 2008 18:55:46 +0000 (18:55 +0000)
     [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.

ChangeLog
channels.c
channels.h
clientloop.c
clientloop.h
mux.c

index 1d1ab2de201ffa2a807c2d01a768b0c95219ecfc..d4d4197013d3013d0ab3b08925f4d54ebb96e76e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
      We already mark the start of the worm, now also mark the end of the worm
      in our random art drawings.
      ok djm@
+   - 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.
 
 20080611
  - (djm) [channels.c configure.ac]
index c539990f64bb1a23fed2c97539aace8fd5fa1860..04cd6b0a781593b0f2d7110850a99e643a4b9848 100644 (file)
@@ -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
@@ -328,6 +328,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;
@@ -416,6 +418,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);
 }
@@ -731,7 +735,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);
 
@@ -742,6 +746,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
index 450321d43fe2ee847659fbd86ba99d08186098af..ec8ea1c405b0d7522d387d619ad169292e3a8eec 100644 (file)
@@ -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 */
@@ -132,6 +133,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;
@@ -196,7 +198,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);
index 663daae769338740cf25f629e53dc202818c029e..d2407ed7e62fb40919a4111e70b4f1e42ad119f0 100644 (file)
@@ -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
@@ -1260,6 +1260,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)
 {
@@ -1357,6 +1364,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,
index 3353a9a80d426b3e3857e838060af9e4816ee4bc..8bb874b38821962e1757f043434566d9999f9000 100644 (file)
@@ -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/mux.c b/mux.c
index f5e68f65312007e5e2b0328df01e28b9e68d2c86..8f7bfb79320363aee9682e3532893d789e38833c 100644 (file)
--- a/mux.c
+++ b/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>
  *
@@ -436,6 +436,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));
        }
 
This page took 0.094555 seconds and 5 git commands to generate.