aboutsummaryrefslogtreecommitdiff
path: root/nss/nsswitch.c
diff options
context:
space:
mode:
authorDJ Delorie <dj@redhat.com>2020-12-09 21:46:30 -0500
committerDJ Delorie <dj@redhat.com>2020-12-14 12:19:43 -0500
commitd2e929a907914e233d001d1dd5e3143e84fa69e0 (patch)
treee0fc726fa628727fee23a86a6053f9107502c84b /nss/nsswitch.c
parent2ee7711bdd7de9dd30073b223ce29d5cd50320f6 (diff)
downloadglibc-d2e929a907914e233d001d1dd5e3143e84fa69e0.zip
glibc-d2e929a907914e233d001d1dd5e3143e84fa69e0.tar.gz
glibc-d2e929a907914e233d001d1dd5e3143e84fa69e0.tar.bz2
nsswitch: handle missing actions properly
Some internal functions need to know if a database has a nonzero list of actions; success getting the database does not guarantee that. Add checks for such as needed. Skip the ":" in each nsswitch.conf line so as not to add a dummy action libnss_:.so See also https://bugzilla.redhat.com/show_bug.cgi?id=1906066 Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Diffstat (limited to 'nss/nsswitch.c')
-rw-r--r--nss/nsswitch.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/nss/nsswitch.c b/nss/nsswitch.c
index 40109c7..5b46d06 100644
--- a/nss/nsswitch.c
+++ b/nss/nsswitch.c
@@ -81,7 +81,10 @@ __nss_database_lookup2 (const char *database, const char *alternate_name,
if (database_names[database_id] == NULL)
return -1;
- if (__nss_database_get (database_id, ni))
+ /* If *NI is NULL, the database was not mentioned in nsswitch.conf.
+ If *NI is not NULL, but *NI->module is NULL, the database was in
+ nsswitch.conf but listed no actions. We test for the former. */
+ if (__nss_database_get (database_id, ni) && *ni != NULL)
{
/* Success. */
return 0;