mirror of
https://github.com/linux-pam/linux-pam.git
synced 2024-11-27 03:33:39 +08:00
modules: do not invoke getline(3) unnecessarily
Replace while (getline(...) != -1 && retval) with while (retval && getline(...) != -1) * modules/pam_listfile/pam_listfile.c (pam_listfile): Do not invoke getline(3) when its result is going to be ignored. * modules/pam_securetty/pam_securetty.c (securetty_perform_check): Likewise.
This commit is contained in:
parent
bb9edf1bdd
commit
7055a56794
@ -307,7 +307,7 @@ pam_listfile(pam_handle_t *pamh, int argc, const char **argv)
|
||||
assert(PAM_SUCCESS == 0);
|
||||
assert(PAM_AUTH_ERR != 0);
|
||||
#endif
|
||||
while(getline(&aline,&n,inf) != -1 && retval) {
|
||||
while(retval && getline(&aline,&n,inf) != -1) {
|
||||
const char *a = aline;
|
||||
|
||||
aline[strcspn(aline, "\r\n")] = '\0';
|
||||
|
@ -157,8 +157,7 @@ securetty_perform_check (pam_handle_t *pamh, int ctrl,
|
||||
|
||||
retval = 1;
|
||||
|
||||
while ((getline(&ttyfileline, &ttyfilelinelen, ttyfile) != -1)
|
||||
&& retval) {
|
||||
while (retval && getline(&ttyfileline, &ttyfilelinelen, ttyfile) != -1) {
|
||||
ttyfileline[strcspn(ttyfileline, "\n")] = '\0';
|
||||
|
||||
retval = ( strcmp(ttyfileline, uttyname)
|
||||
|
Loading…
Reference in New Issue
Block a user