From 025ebec4cc3a06f52f0dff8d99ca86d9e9670ad4 Mon Sep 17 00:00:00 2001 From: Yihong Wu Date: Thu, 2 Feb 2023 06:53:30 +0000 Subject: [PATCH] Fix thread safety after #1751 --- src/Cedar/Proto_PPP.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/Cedar/Proto_PPP.c b/src/Cedar/Proto_PPP.c index 542bafb8..3c9d845f 100644 --- a/src/Cedar/Proto_PPP.c +++ b/src/Cedar/Proto_PPP.c @@ -3651,17 +3651,28 @@ bool PPPProcessEAPTlsResponse(PPP_SESSION *p, PPP_EAP *eap_packet, UINT eapSize) if (p->Eap_MatchUserByCert) { - HUB* hub = GetHub(p->Cedar, p->Eap_Identity.HubName); + HUB *hub; bool found = false; + + LockHubList(p->Cedar); + { + hub = GetHub(p->Cedar, p->Eap_Identity.HubName); + } + UnlockHubList(p->Cedar); + if (hub != NULL) { - USER* user = AcGetUserByCert(hub, p->Eap_TlsCtx.ClientCert.X); - if (user != NULL) + AcLock(hub); { - StrCpy(p->Eap_Identity.UserName, sizeof(p->Eap_Identity.UserName), user->Name); - found = true; - ReleaseUser(user); + USER* user = AcGetUserByCert(hub, p->Eap_TlsCtx.ClientCert.X); + if (user != NULL) + { + StrCpy(p->Eap_Identity.UserName, sizeof(p->Eap_Identity.UserName), user->Name); + found = true; + ReleaseUser(user); + } } + AcUnlock(hub); ReleaseHub(hub); }