Skip to content

Commit 101d19f

Browse files
Fix policy_callback mutex access
1 parent 4a091a2 commit 101d19f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/webserver.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -411,10 +411,10 @@ MHD_Result policy_callback(void *cls, const struct sockaddr* addr, socklen_t add
411411

412412
if (!ws->ban_system_enabled) return MHD_YES;
413413

414-
std::shared_lock bans_lock(bans_mutex);
415-
std::shared_lock allowances_lock(allowances_mutex);
416-
const bool is_banned = (static_cast<webserver *>(cls))->bans.count(ip_representation(addr));
417-
const bool is_allowed = (static_cast<webserver *>(cls))->allowances.count(ip_representation(addr));
414+
std::shared_lock bans_lock(ws->bans_mutex);
415+
std::shared_lock allowances_lock(ws->allowances_mutex);
416+
const bool is_banned = ws->bans.count(ip_representation(addr));
417+
const bool is_allowed = ws->allowances.count(ip_representation(addr));
418418

419419
if ((ws->default_policy == http_utils::ACCEPT && is_banned && !is_allowed) ||
420420
(ws->default_policy == http_utils::REJECT && !is_banned && is_allowed))

0 commit comments

Comments
 (0)