@@ -41,9 +41,9 @@ namespace
4141 Firebird::SimpleFactory<Auth::WinSspiClient> clientFactory;
4242 Firebird::SimpleFactory<Auth::WinSspiServer> serverFactory;
4343
44- const char * plugName = " Win_Sspi" ;
44+ constexpr const char * plugName = " Win_Sspi" ;
4545
46- void makeDesc (SecBufferDesc& d, SecBuffer& b, FB_SIZE_T len, void * p)
46+ void makeDesc (SecBufferDesc& d, SecBuffer& b, FB_SIZE_T len, void * p) noexcept
4747 {
4848 b.BufferType = SECBUFFER_TOKEN;
4949 b.cbBuffer = len;
@@ -57,7 +57,7 @@ namespace
5757 ToType getProc (HINSTANCE lib, const char * entry)
5858 {
5959 FARPROC rc = GetProcAddress (lib, entry);
60- if (! rc)
60+ if (!rc)
6161 {
6262 LongJump::raise ();
6363 }
@@ -70,21 +70,21 @@ namespace Auth {
7070
7171static thread_local bool legacySSP = false ;
7272
73- void setLegacySSP (bool value)
73+ void setLegacySSP (bool value) noexcept
7474{
7575 legacySSP = value;
7676}
7777
7878
7979HINSTANCE AuthSspi::library = 0 ;
8080
81- bool AuthSspi::initEntries ()
81+ bool AuthSspi::initEntries () noexcept
8282{
83- if (! library)
83+ if (!library)
8484 {
8585 library = LoadLibrary (" secur32.dll" );
8686 }
87- if (! library)
87+ if (!library)
8888 {
8989 return false ;
9090 }
@@ -136,7 +136,7 @@ AuthSspi::~AuthSspi()
136136 }
137137}
138138
139- const AuthSspi::Key* AuthSspi::getKey () const
139+ const AuthSspi::Key* AuthSspi::getKey () const noexcept
140140{
141141 if (sessionKey.hasData ())
142142 return &sessionKey;
@@ -152,6 +152,7 @@ bool AuthSspi::checkAdminPrivilege()
152152 {
153153 return false ;
154154 }
155+ fb_assert (spc.AccessToken );
155156
156157 // Query required buffer size
157158 DWORD token_len = 0 ;
@@ -187,7 +188,6 @@ bool AuthSspi::checkAdminPrivilege()
187188 bool matched = false ;
188189 char groupName[256 ];
189190 char domainName[256 ];
190- DWORD dwAcctName = 1 , dwDomainName = 1 ;
191191 SID_NAME_USE snu = SidTypeUnknown;
192192
193193 groupNames.clear ();
@@ -200,8 +200,9 @@ bool AuthSspi::checkAdminPrivilege()
200200 if ((ptg->Groups [i].Attributes & SE_GROUP_ENABLED) &&
201201 !(ptg->Groups [i].Attributes & SE_GROUP_USE_FOR_DENY_ONLY))
202202 {
203- DWORD dwSize = 256 ;
204- if (LookupAccountSid (NULL , ptg->Groups [i].Sid , groupName, &dwSize, domainName, &dwSize, &snu) &&
203+ DWORD dwGroupName = sizeof (groupName);
204+ DWORD dwDomainName = sizeof (domainName);
205+ if (LookupAccountSid (NULL , ptg->Groups [i].Sid , groupName, &dwGroupName, domainName, &dwDomainName, &snu) &&
205206 domainName[0 ] && strcmp (domainName, " NT AUTHORITY" ))
206207 {
207208 string sumName = domainName;
@@ -246,7 +247,7 @@ bool AuthSspi::request(AuthSspi::DataHolder& data)
246247
247248 ULONG fContextAttr = 0 ;
248249
249- SECURITY_STATUS x = fInitializeSecurityContext (
250+ const SECURITY_STATUS x = fInitializeSecurityContext (
250251 &secHndl, hasContext ? &ctxtHndl : 0 , 0 , 0 , 0 , SECURITY_NATIVE_DREP,
251252 hasContext ? &inputDesc : 0 , 0 , &ctxtHndl, &outputDesc, &fContextAttr , &timeOut);
252253
@@ -308,7 +309,7 @@ bool AuthSspi::accept(AuthSspi::DataHolder& data)
308309 ULONG fContextAttr = 0 ;
309310 SecPkgContext_Names name;
310311 SecPkgContext_SessionKey key;
311- SECURITY_STATUS x = fAcceptSecurityContext (
312+ const SECURITY_STATUS x = fAcceptSecurityContext (
312313 &secHndl, hasContext ? &ctxtHndl : 0 , &inputDesc, 0 ,
313314 SECURITY_NATIVE_DREP, &ctxtHndl, &outputDesc,
314315 &fContextAttr , &timeOut);
0 commit comments