]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/nss.c: Fix incorrect handling of white space
authorAlejandro Colomar <alx@kernel.org>
Tue, 3 Mar 2026 14:33:34 +0000 (15:33 +0100)
committerSerge Hallyn <serge@hallyn.com>
Thu, 11 Jun 2026 12:23:18 +0000 (07:23 -0500)
Having trailing white space in a line doesn't remove the need for
a trailing '\n'.  Let's fail if a line doesn't have it, regardless of
how much trailing white space there is.

Fixes: 8492dee6 (2021-04-16; "subids: support nsswitch")
Cc: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/nss.c

index c487800e264ca253fbae38895748b621ae7bead3..7455babc9f8b41772a8af73b753a8b9cee24ff6b 100644 (file)
--- a/lib/nss.c
+++ b/lib/nss.c
@@ -94,11 +94,12 @@ nss_init(const char *nsswitch_path) {
        if (p == NULL) {
                goto null_subid;
        }
-       if (stpsep(p, " \t\n") == NULL) {
+       if (stpsep(p, "\n") == NULL) {
                fprintf(log_get_logfd(), "No usable subid NSS module found, using files\n");
                // subid_nss has to be null here, but to ease reviews:
                goto null_subid;
        }
+       stpsep(p, " \t");
        if (streq(p, "files")) {
                goto null_subid;
        }