aboutsummaryrefslogtreecommitdiff
path: root/modules/pam_securetty
diff options
context:
space:
mode:
authorTobias Stoeckmann <tobias@stoeckmann.org>2024-01-11 23:21:54 +0100
committerDmitry V. Levin <ldv@strace.io>2024-01-12 17:01:04 +0000
commitd9494352c571d332cf92bdadcd898894f0af12df (patch)
treeef1b99c51a3b7d3f8fdcb87803fe957f95a7dafc /modules/pam_securetty
parentcf80332ddb98c109c5abc35c74d6dd371ca7fa5b (diff)
downloadpam-d9494352c571d332cf92bdadcd898894f0af12df.tar.gz
pam-d9494352c571d332cf92bdadcd898894f0af12df.tar.bz2
pam-d9494352c571d332cf92bdadcd898894f0af12df.zip
modules: simplify newline removal
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Diffstat (limited to 'modules/pam_securetty')
-rw-r--r--modules/pam_securetty/pam_securetty.c11
1 files changed, 2 insertions, 9 deletions
diff --git a/modules/pam_securetty/pam_securetty.c b/modules/pam_securetty/pam_securetty.c
index f60cf32a..617af679 100644
--- a/modules/pam_securetty/pam_securetty.c
+++ b/modules/pam_securetty/pam_securetty.c
@@ -159,10 +159,7 @@ securetty_perform_check (pam_handle_t *pamh, int ctrl,
while ((getline(&ttyfileline, &ttyfilelinelen, ttyfile) != -1)
&& retval) {
- size_t len;
- len = strlen(ttyfileline);
- if (len > 0 && ttyfileline[len - 1] == '\n')
- ttyfileline[len - 1] = '\0';
+ ttyfileline[strcspn(ttyfileline, "\n")] = '\0';
retval = ( strcmp(ttyfileline, uttyname)
&& (!ptname[0] || strcmp(ptname, uttyname)) );
@@ -226,12 +223,8 @@ securetty_perform_check (pam_handle_t *pamh, int ctrl,
fclose(consoleactivefile);
if (p) {
- size_t len;
-
/* remove the newline character at end */
- len = strlen(line);
- if (len && line[len-1] == '\n')
- line[len-1] = 0;
+ line[strcspn(line, "\n")] = '\0';
for (n = p; n != NULL; p = n+1) {
if ((n = strchr(p, ' ')) != NULL)