From d380d080fa0ad230d86bc5e4bc3512a199f68e43 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Fri, 10 Nov 2017 14:21:32 -0500 Subject: 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 Reviewed-by: Michael Paquier --- src/backend/libpq/hba.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/backend/libpq/hba.c') diff --git a/src/backend/libpq/hba.c b/src/backend/libpq/hba.c index d3b316b9e34..b3c44f2ec53 100644 --- a/src/backend/libpq/hba.c +++ b/src/backend/libpq/hba.c @@ -1488,9 +1488,11 @@ parse_hba_auth_opt(char *name, char *val, HbaLine *hbaline, int line_num) return false; } - hbaline->ldapserver = pstrdup(urldata->lud_host); + if (urldata->lud_host) + hbaline->ldapserver = pstrdup(urldata->lud_host); hbaline->ldapport = urldata->lud_port; - hbaline->ldapbasedn = pstrdup(urldata->lud_dn); + if (urldata->lud_dn) + hbaline->ldapbasedn = pstrdup(urldata->lud_dn); if (urldata->lud_attrs) hbaline->ldapsearchattribute = pstrdup(urldata->lud_attrs[0]); /* only use first one */ -- cgit v1.2.3