getline(3) might have never succeeded, in which case p is uninitialized
when used in strtok_r(3).
Link: <https://github.com/shadow-maint/shadow/pull/737#discussion_r1206007358>
Cc: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
atomic_store(&nss_init_completed, true);
return;
}
- while ((getline(&line, &len, nssfp)) != -1) {
+ p = NULL;
+ while (getline(&line, &len, nssfp) != -1) {
if (line[0] == '#')
continue;
if (strlen(line) < 8)
if (*p != '\0')
break;
}
+ if (p == NULL) {
+ goto null_subid;
+ }
token = strtok_r(p, " \n\t", &saveptr);
if (token == NULL) {
fprintf(shadow_logfd, "No usable subid NSS module found, using files\n");