aboutsummaryrefslogtreecommitdiff
path: root/modules/pam_rootok
diff options
context:
space:
mode:
authorIker Pedrosa <ipedrosa@redhat.com>2024-05-22 11:20:02 +0200
committerDmitry V. Levin <ldv@strace.io>2024-05-23 10:25:09 +0000
commitd00f6cb366b492de455f9b72fcbd2e49abf323e0 (patch)
treef919995346a5b04f8f1b47ebe9ec2a7f244a76b7 /modules/pam_rootok
parent5eccaf9b3488d3f6da800281363697e4e4834e77 (diff)
downloadpam-d00f6cb366b492de455f9b72fcbd2e49abf323e0.tar.gz
pam-d00f6cb366b492de455f9b72fcbd2e49abf323e0.tar.bz2
pam-d00f6cb366b492de455f9b72fcbd2e49abf323e0.zip
pam_rootok: close the audit socket on error path
* modules/pam_rootok/pam_rootok.c (log_callback): Close the audit socket if vasprintf returned an error. ``` Error: RESOURCE_LEAK (CWE-772): Linux-PAM-1.6.0/modules/pam_rootok/pam_rootok.c:59: open_fn: Returning handle opened by "audit_open". Linux-PAM-1.6.0/modules/pam_rootok/pam_rootok.c:59: var_assign: Assigning: "audit_fd" = handle returned from "audit_open()". Linux-PAM-1.6.0/modules/pam_rootok/pam_rootok.c:69: leaked_handle: Handle variable "audit_fd" going out of scope leaks the handle. 67| va_end(ap); 68| if (ret < 0) { 69|-> return 0; 70| } 71| audit_log_user_avc_message(audit_fd, AUDIT_USER_AVC, buf, NULL, NULL, ``` Resolves: https://issues.redhat.com/browse/RHEL-36475 Signed-off-by: Iker Pedrosa <ipedrosa@redhat.com>
Diffstat (limited to 'modules/pam_rootok')
-rw-r--r--modules/pam_rootok/pam_rootok.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/modules/pam_rootok/pam_rootok.c b/modules/pam_rootok/pam_rootok.c
index 6d2dfa07..1b88fb19 100644
--- a/modules/pam_rootok/pam_rootok.c
+++ b/modules/pam_rootok/pam_rootok.c
@@ -66,6 +66,7 @@ log_callback (int type UNUSED, const char *fmt, ...)
ret = vasprintf (&buf, fmt, ap);
va_end(ap);
if (ret < 0) {
+ audit_close(audit_fd);
return 0;
}
audit_log_user_avc_message(audit_fd, AUDIT_USER_AVC, buf, NULL, NULL,