From 56842b2f63a16d56e71c9acbbe9219034c78aa40 Mon Sep 17 00:00:00 2001 From: Daniel Roethlisberger Date: Sat, 11 Jan 2014 19:03:36 +0100 Subject: [PATCH] Fix file descriptor leak in passthrough mode (-P) When using passthrough mode, if a connection to a server fails with an SSL error, sslsplit falls back to plain TCP passthrough. When reconnecting with plain TCP, the SSL context was freed, but the file descriptor was never closed. The fix remedies that by calling the proper cleanup function for the dst bev before reconnecting. Reported by: Peter Haag --- pxyconn.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pxyconn.c b/pxyconn.c index f935374..68623db 100644 --- a/pxyconn.c +++ b/pxyconn.c @@ -1428,6 +1428,7 @@ pxy_bev_eventcb(struct bufferevent *bev, short events, void *arg) ctx->src.ssl = pxy_srcssl_create(ctx, this->ssl); if (!ctx->src.ssl) { bufferevent_free_and_close_fd(bev, ctx); + ctx->dst.bev = NULL; ctx->dst.ssl = NULL; if (ctx->opts->passthrough && !ctx->enomem) { ctx->passthrough = 1; @@ -1569,7 +1570,8 @@ pxy_bev_eventcb(struct bufferevent *bev, short events, void *arg) ctx->opts->passthrough && have_sslerr) { /* ssl callout failed, fall back to plain * TCP passthrough of SSL connection */ - SSL_free(ctx->dst.ssl); + bufferevent_free_and_close_fd(bev, ctx); + ctx->dst.bev = NULL; ctx->dst.ssl = NULL; ctx->passthrough = 1; log_dbg_printf("SSL dst connection failed; fal"