mirror of
https://github.com/postgres/postgres.git
synced 2025-07-26 01:22:12 +03:00
Fix some memory leaks and improve restricted token handling on Windows
The leaks have been detected by a Coverity run on Windows. No backpatch is done as the leaks are minor. While on it, make restricted token creation more consistent in its error handling by logging an error instead of a warning if missing advapi32.dll, which was missing in the NT4 days. Any modern platform should have this DLL around. Now, if the library is not there, an error is still reported back to the caller, and nothing is done do there is no behavior change done in this commit. Author: Ranier Vilela Discussion: https://postgr.es/m/CAEudQApa9MG0foPkgPX87fipk=vhnF2Xfg+CfUyR08h4R7Mywg@mail.gmail.com
This commit is contained in:
@ -1387,6 +1387,13 @@ pg_SSPI_recvauth(Port *port)
|
||||
mtype = pq_getbyte();
|
||||
if (mtype != 'p')
|
||||
{
|
||||
if (sspictx != NULL)
|
||||
{
|
||||
DeleteSecurityContext(sspictx);
|
||||
free(sspictx);
|
||||
}
|
||||
FreeCredentialsHandle(&sspicred);
|
||||
|
||||
/* Only log error if client didn't disconnect. */
|
||||
if (mtype != EOF)
|
||||
ereport(ERROR,
|
||||
@ -1402,6 +1409,12 @@ pg_SSPI_recvauth(Port *port)
|
||||
{
|
||||
/* EOF - pq_getmessage already logged error */
|
||||
pfree(buf.data);
|
||||
if (sspictx != NULL)
|
||||
{
|
||||
DeleteSecurityContext(sspictx);
|
||||
free(sspictx);
|
||||
}
|
||||
FreeCredentialsHandle(&sspicred);
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
@ -2517,6 +2530,7 @@ InitializeLDAPConnection(Port *port, LDAP **ldap)
|
||||
(errmsg("could not load function _ldap_start_tls_sA in wldap32.dll"),
|
||||
errdetail("LDAP over SSL is not supported on this platform.")));
|
||||
ldap_unbind(*ldap);
|
||||
FreeLibrary(ldaphandle);
|
||||
return STATUS_ERROR;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user