From 3711e03ad615c3183aa401b4d80e3630f25bcb6d Mon Sep 17 00:00:00 2001
From: "Rob Swindell (on Windows 11)" <rob@synchro.net>
Date: Sat, 23 Mar 2024 16:32:50 -0700
Subject: [PATCH] Use volatile keyword to (maybe) fix CID 488122: Data race
 condition

Ideally, I'd use atomic_bool instead, but we're using an older WinSDK for Win7
compatibility and so... can't.

Perhaps an xpdev 'protected_bool_t' should be created.
---
 src/sbbs3/websrvr.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/sbbs3/websrvr.c b/src/sbbs3/websrvr.c
index d31b4a4965..728ea78739 100644
--- a/src/sbbs3/websrvr.c
+++ b/src/sbbs3/websrvr.c
@@ -256,7 +256,7 @@ typedef struct  {
 	char			host_ip[INET6_ADDRSTRLEN];
 	char			host_name[128];	/* Resolved remote host */
 	int				http_ver;       /* Request HTTP version.  0 = HTTP/0.9, 1=HTTP/1.0, 2=HTTP/1.1 */
-	bool			send_failed;
+	volatile bool	send_failed;
 	bool			finished;		/* Do not accept any more input from client */
 	enum parsed_vpath parsed_vpath; /* file area/base access */
 	int				libnum;
@@ -640,7 +640,7 @@ static bool session_check(http_session_t *session, bool *rd, bool *wr, unsigned
 	return socket_check(session->socket, rd, wr, timeout);
 }
 
-static int sess_sendbuf(http_session_t *session, const char *buf, size_t len, bool *failed)
+static int sess_sendbuf(http_session_t *session, const char *buf, size_t len, volatile bool *failed)
 {
 	size_t sent=0;
 	int	tls_sent;
-- 
GitLab