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
commit 1ff0b37134
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -90,7 +90,7 @@ bool hushed (const char *username)
return false;
}
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) ||
(strcmp (buf, pw->pw_name) == 0);
}