lib/nss.c: Fix use of invalid p

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>
This commit is contained in:
Alejandro Colomar
2023-05-31 12:24:14 +02:00
committed by Serge Hallyn
parent 848a95329c
commit 70399856c1
+1
View File
@@ -82,6 +82,7 @@ void nss_init(const char *nsswitch_path) {
p++;
if (*p != '\0')
break;
p = NULL;
}
if (p == NULL) {
goto null_subid;