aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Stoeckmann <tobias@stoeckmann.org>2023-12-12 17:03:05 +0100
committerDmitry V. Levin <ldv@strace.io>2023-12-12 20:05:08 +0000
commit86506bddaa02e845c87f6513e04e109c4e3c78ff (patch)
treef1cb2335c497732c268ab08a71d2abeb8a9775c2
parenteec4358a49dc0d6d699532965f453f0da240227e (diff)
downloadpam-86506bddaa02e845c87f6513e04e109c4e3c78ff.tar.gz
pam-86506bddaa02e845c87f6513e04e109c4e3c78ff.tar.bz2
pam-86506bddaa02e845c87f6513e04e109c4e3c78ff.zip
pam_xauth: simplify check_acl
The strcspn function can easily replace memchr here. The latter would scan the entire buffer and requires a manual size limitation. Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
-rw-r--r--modules/pam_xauth/pam_xauth.c11
1 files changed, 2 insertions, 9 deletions
diff --git a/modules/pam_xauth/pam_xauth.c b/modules/pam_xauth/pam_xauth.c
index 35bc5aeb..bc8a3d74 100644
--- a/modules/pam_xauth/pam_xauth.c
+++ b/modules/pam_xauth/pam_xauth.c
@@ -290,17 +290,10 @@ check_acl(pam_handle_t *pamh,
}
}
if (fp) {
- char buf[LINE_MAX], *tmp;
+ char buf[LINE_MAX];
/* Scan the file for a list of specs of users to "trust". */
while (fgets(buf, sizeof(buf), fp) != NULL) {
- tmp = memchr(buf, '\r', sizeof(buf));
- if (tmp != NULL) {
- *tmp = '\0';
- }
- tmp = memchr(buf, '\n', sizeof(buf));
- if (tmp != NULL) {
- *tmp = '\0';
- }
+ buf[strcspn(buf, "\r\n")] = '\0';
if (fnmatch(buf, other_user, 0) == 0) {
if (debug) {
pam_syslog(pamh, LOG_DEBUG,