Skip to content

Commit f9e2885

Browse files
committed
Fix some null pointer dereferences in LDAP auth code
An LDAP URL without a host name such as "ldap://" or without a base DN such as "ldap://localhost" would cause a crash when reading pg_hba.conf. If no binddn is configured, an error message might end up trying to print a null pointer, which could crash on some platforms. Author: Thomas Munro <thomas.munro@enterprisedb.com> Reviewed-by: Michael Paquier <michael.paquier@gmail.com>
1 parent d33fc27 commit f9e2885

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/backend/libpq/auth.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2474,7 +2474,8 @@ CheckLDAPAuth(Port *port)
24742474
{
24752475
ereport(LOG,
24762476
(errmsg("could not perform initial LDAP bind for ldapbinddn \"%s\" on server \"%s\": %s",
2477-
port->hba->ldapbinddn, port->hba->ldapserver, ldap_err2string(r))));
2477+
port->hba->ldapbinddn ? port->hba->ldapbinddn : "",
2478+
port->hba->ldapserver, ldap_err2string(r))));
24782479
pfree(passwd);
24792480
return STATUS_ERROR;
24802481
}

src/backend/libpq/hba.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1721,9 +1721,11 @@ parse_hba_auth_opt(char *name, char *val, HbaLine *hbaline,
17211721
return false;
17221722
}
17231723

1724-
hbaline->ldapserver = pstrdup(urldata->lud_host);
1724+
if (urldata->lud_host)
1725+
hbaline->ldapserver = pstrdup(urldata->lud_host);
17251726
hbaline->ldapport = urldata->lud_port;
1726-
hbaline->ldapbasedn = pstrdup(urldata->lud_dn);
1727+
if (urldata->lud_dn)
1728+
hbaline->ldapbasedn = pstrdup(urldata->lud_dn);
17271729

17281730
if (urldata->lud_attrs)
17291731
hbaline->ldapsearchattribute = pstrdup(urldata->lud_attrs[0]); /* only use first one */

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy