diff options
author | Tobias Stoeckmann <tobias@stoeckmann.org> | 2024-01-11 23:25:04 +0100 |
---|---|---|
committer | Dmitry V. Levin <ldv@strace.io> | 2024-01-12 17:01:04 +0000 |
commit | 9b577258a31024b159d541716d465a4944948d95 (patch) | |
tree | 93d71b7b702a8db9edef14638b88c08becf95d1e /modules/pam_listfile | |
parent | 47661a8eda337f23baf12d3bf6a479fc738be73f (diff) | |
download | pam-9b577258a31024b159d541716d465a4944948d95.tar.gz pam-9b577258a31024b159d541716d465a4944948d95.tar.bz2 pam-9b577258a31024b159d541716d465a4944948d95.zip |
pam_listfile: treat \r like \n
The characters \r and \n are replaced by NUL byte. Treat a line which
is empty after removal of \r just like lines which are empty after
the removal of \n.
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Diffstat (limited to 'modules/pam_listfile')
-rw-r--r-- | modules/pam_listfile/pam_listfile.c | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/modules/pam_listfile/pam_listfile.c b/modules/pam_listfile/pam_listfile.c index f8abc35a..509320c7 100644 --- a/modules/pam_listfile/pam_listfile.c +++ b/modules/pam_listfile/pam_listfile.c @@ -284,14 +284,9 @@ pam_sm_authenticate (pam_handle_t *pamh, int flags UNUSED, while(getline(&aline,&n,inf) != -1 && retval) { const char *a = aline; - if(strlen(aline) == 0) + aline[strcspn(aline, "\r\n")] = '\0'; + if(aline[0] == '\0') continue; - if(aline[strlen(aline) - 1] == '\n') - aline[strlen(aline) - 1] = '\0'; - if(strlen(aline) == 0) - continue; - if(aline[strlen(aline) - 1] == '\r') - aline[strlen(aline) - 1] = '\0'; if(citem == PAM_TTY) { const char *str = pam_str_skip_prefix(a, "/dev/"); if (str != NULL) |