From a9fec35d421340487e764b56a208d7341ada9ffb Mon Sep 17 00:00:00 2001 From: Soner Tari Date: Wed, 27 Dec 2023 18:08:34 +0300 Subject: [PATCH] Fix possible segfault in proto smtp in split mode srvdst is disabled in split mode, and srvdst.bev is null --- src/protosmtp.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/protosmtp.c b/src/protosmtp.c index dcfdbe1..181bf15 100644 --- a/src/protosmtp.c +++ b/src/protosmtp.c @@ -222,7 +222,11 @@ protosmtp_bev_eventcb_connected_dst(struct bufferevent *bev, pxy_conn_ctx_t *ctx ctx->connected = 1; bufferevent_enable(bev, EV_READ|EV_WRITE); - bufferevent_enable(ctx->srvdst.bev, EV_READ); + + // srvdst is disabled in split mode, see prototcp_setup_dst() + if (ctx->srvdst.bev) { + bufferevent_enable(ctx->srvdst.bev, EV_READ); + } if (ctx->proto == PROTO_SMTP) { prototcp_enable_src(ctx);