From 3a215f4f3f94406b5af9901f84a2526cf18ecf17 Mon Sep 17 00:00:00 2001 From: Soner Tari Date: Mon, 11 Apr 2022 12:27:30 +0300 Subject: [PATCH] Use parent protoctx for autossl ctx This fixes a crash. And improve logging. --- src/protoautossl.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/protoautossl.c b/src/protoautossl.c index 86dc1ab..b3cf3e3 100644 --- a/src/protoautossl.c +++ b/src/protoautossl.c @@ -245,13 +245,13 @@ protoautossl_peek_and_upgrade(pxy_conn_ctx_t *ctx) if (!ctx->children) { // This means that there was no autossl handshake prior to ClientHello, e.g. no STARTTLS message // This is perhaps the SSL handshake of a direct SSL connection - log_err_level(LOG_CRIT, "No children setup yet, upgrading srvdst"); + log_fine("Upgrading srvdst, no child conn set up yet"); protoautossl_upgrade_srvdst(ctx); bufferevent_enable(ctx->srvdst.bev, EV_READ|EV_WRITE); } else { // @attention Autossl protocol should never have multiple children. - log_err_level(LOG_CRIT, "Upgrading child dst"); + log_fine("Upgrading child dst"); protoautossl_upgrade_dst_child(ctx->children); } @@ -263,6 +263,9 @@ protoautossl_peek_and_upgrade(pxy_conn_ctx_t *ctx) if (pxy_set_sslproxy_header(ctx, 1) == -1) { return -1; } + } else { + log_err_level(LOG_CRIT, "No sslproxy_header set up in divert mode in autossl"); + return -1; } } else { // srvdst == dst in split mode @@ -566,7 +569,7 @@ protoautossl_enable_conn_src_child(pxy_conn_child_ctx_t *ctx) // Now open the gates for a second time after autossl upgrade bufferevent_enable(ctx->conn->src.bev, EV_READ|EV_WRITE); - protoautossl_ctx_t *autossl_ctx = ctx->protoctx->arg; + protoautossl_ctx_t *autossl_ctx = ctx->conn->protoctx->arg; autossl_ctx->clienthello_found = 0; return 0; }