Merge pull request #433 from stoeckmann/hushed

Handle malformed lines in hushlogins file.
This commit is contained in:
Serge Hallyn
2021-10-30 09:34:55 -05:00
committed by GitHub

View File

@@ -90,7 +90,7 @@ bool hushed (const char *username)
return false; return false;
} }
for (found = false; !found && (fgets (buf, (int) sizeof buf, fp) == buf);) { for (found = false; !found && (fgets (buf, (int) sizeof buf, fp) == buf);) {
buf[strlen (buf) - 1] = '\0'; buf[strcspn (buf, "\n")] = '\0';
found = (strcmp (buf, pw->pw_shell) == 0) || found = (strcmp (buf, pw->pw_shell) == 0) ||
(strcmp (buf, pw->pw_name) == 0); (strcmp (buf, pw->pw_name) == 0);
} }