From 53d2a7587db3bbc307db44f7a77ae5b9780643d8 Mon Sep 17 00:00:00 2001 From: dmiller Date: Fri, 6 Dec 2024 18:41:57 +0000 Subject: [PATCH] Ncat: Don't call SSL_shutdown if --no-shutdown --- ncat/ncat_core.c | 3 ++- ncat/ncat_exec_win.c | 4 +++- ncat/ncat_listen.c | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/ncat/ncat_core.c b/ncat/ncat_core.c index 82962bf01..23a8e7b70 100644 --- a/ncat/ncat_core.c +++ b/ncat/ncat_core.c @@ -286,7 +286,8 @@ int fdinfo_close(struct fdinfo *fdn) { #ifdef HAVE_OPENSSL if (o.ssl && fdn->ssl != NULL) { - SSL_shutdown(fdn->ssl); + if (!o.noshutdown) + SSL_shutdown(fdn->ssl); SSL_free(fdn->ssl); fdn->ssl = NULL; } diff --git a/ncat/ncat_exec_win.c b/ncat/ncat_exec_win.c index adbf8467a..ba7d90245 100644 --- a/ncat/ncat_exec_win.c +++ b/ncat/ncat_exec_win.c @@ -294,8 +294,10 @@ static void subprocess_info_close(struct subprocess_info *info) { #ifdef HAVE_OPENSSL if (info->fdn.ssl != NULL) { - SSL_shutdown(info->fdn.ssl); + if (!o.noshutdown) + SSL_shutdown(info->fdn.ssl); SSL_free(info->fdn.ssl); + info->fdn.ssl = NULL; } #endif closesocket(info->fdn.fd); diff --git a/ncat/ncat_listen.c b/ncat/ncat_listen.c index ff08e7d85..9245775f8 100644 --- a/ncat/ncat_listen.c +++ b/ncat/ncat_listen.c @@ -629,7 +629,7 @@ static void close_fd(struct fdinfo *fdn, int eof) { logdebug("Closing connection.\n"); #ifdef HAVE_OPENSSL if (o.ssl && fdn->ssl) { - if (eof) + if (eof && !o.noshutdown) SSL_shutdown(fdn->ssl); SSL_free(fdn->ssl); }