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]
-/* $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
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;
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);
}
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);
c->input_filter = ifn;
c->output_filter = ofn;
c->filter_ctx = ctx;
+ c->filter_cleanup = cfn;
}
void
-/* $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>
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 */
channel_infilter_fn *input_filter;
channel_outfilter_fn *output_filter;
void *filter_ctx;
+ channel_filter_cleanup_fn *filter_cleanup;
/* keep boundaries */
int datagram;
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);
-/* $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
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)
{
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,
-/* $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>
/* 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 */
-/* $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>
*
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));
}