]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/nss.c: Fix use of invalid p
authorAlejandro Colomar <alx@kernel.org>
Wed, 31 May 2023 10:24:14 +0000 (12:24 +0200)
committerSerge Hallyn <serge@hallyn.com>
Wed, 31 May 2023 14:29:49 +0000 (09:29 -0500)
getline(3) might have succeeded in a previous iteration, in which case
p points to an offset that is not valid.  Make p NULL at the end of the
loop, to make sure it doesn't hold old stuff.

Link: <https://github.com/shadow-maint/shadow/pull/737#issuecomment-1568948769>
Reported-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/nss.c

index e6776fb1aa460a8fbf2c57da82b3ec11446ed3e4..b697f0a0929e1eced7087af6d26b8206899e38fa 100644 (file)
--- a/lib/nss.c
+++ b/lib/nss.c
@@ -82,6 +82,7 @@ void nss_init(const char *nsswitch_path) {
                        p++;
                if (*p != '\0')
                        break;
+               p = NULL;
        }
        if (p == NULL) {
                goto null_subid;