From 93dd09c45cac23eb62affd72e370729ada7b40e4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Deuc=D0=B5?= <shurd@sasktel.net>
Date: Tue, 9 Jan 2024 12:15:02 -0500
Subject: [PATCH] You can't just screw around with a pair of shared linked
 lists without locking!  That's chaos!

---
 src/sbbs3/ssl.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/sbbs3/ssl.c b/src/sbbs3/ssl.c
index ae91ac31b0..1eafacdd43 100644
--- a/src/sbbs3/ssl.c
+++ b/src/sbbs3/ssl.c
@@ -558,6 +558,7 @@ int destroy_session(int (*lprintf)(int level, const char* fmt, ...), CRYPT_SESSI
 	struct cert_list *psess = NULL;
 	int ret = CRYPT_ERROR_NOTFOUND;
 
+	pthread_mutex_lock(&ssl_cert_list_mutex);
 	sess = sess_list;
 	while (sess != NULL) {
 		if (sess->sess == csess) {
@@ -587,6 +588,7 @@ int destroy_session(int (*lprintf)(int level, const char* fmt, ...), CRYPT_SESSI
 		psess = sess;
 		sess = sess->next;
 	}
+	pthread_mutex_unlock(&ssl_cert_list_mutex);
 	if (ret == CRYPT_ERROR_NOTFOUND)
 		ret = cryptDestroySession(csess);
 	return ret;
-- 
GitLab