aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Stoeckmann <tobias@stoeckmann.org>2024-01-02 22:38:23 +0100
committerDmitry V. Levin <ldv@strace.io>2024-01-03 17:28:06 +0000
commitb285652d864120a967401da28f3d20555f6cc9f5 (patch)
tree08ed141b4a21dda7692777ffbd82de5e79a32161
parentc0ca17b36aa850e33ecd4254e5445f798d885e3b (diff)
downloadpam-b285652d864120a967401da28f3d20555f6cc9f5.tar.gz
pam-b285652d864120a967401da28f3d20555f6cc9f5.tar.bz2
pam-b285652d864120a967401da28f3d20555f6cc9f5.zip
pam_xauth: use getline
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
-rw-r--r--modules/pam_xauth/pam_xauth.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/modules/pam_xauth/pam_xauth.c b/modules/pam_xauth/pam_xauth.c
index 20ae3e6b..920dcb6e 100644
--- a/modules/pam_xauth/pam_xauth.c
+++ b/modules/pam_xauth/pam_xauth.c
@@ -288,9 +288,10 @@ check_acl(pam_handle_t *pamh,
}
}
if (fp) {
- char buf[LINE_MAX];
+ char *buf = NULL;
+ size_t n = 0;
/* Scan the file for a list of specs of users to "trust". */
- while (fgets(buf, sizeof(buf), fp) != NULL) {
+ while (getline(&buf, &n, fp) != -1) {
buf[strcspn(buf, "\r\n")] = '\0';
if (fnmatch(buf, other_user, 0) == 0) {
if (debug) {
@@ -298,6 +299,7 @@ check_acl(pam_handle_t *pamh,
"%s %s allowed by %s",
other_user, sense, path);
}
+ free(buf);
fclose(fp);
free(path);
return PAM_SUCCESS;
@@ -308,6 +310,7 @@ check_acl(pam_handle_t *pamh,
pam_syslog(pamh, LOG_DEBUG, "%s not listed in %s",
other_user, path);
}
+ free(buf);
fclose(fp);
free(path);
return PAM_PERM_DENIED;