From 91e73d54fec4471990bcc60638d0db49dfcc2d10 Mon Sep 17 00:00:00 2001 From: Tyler Hicks Date: Mon, 1 Feb 2016 10:35:57 -0600 Subject: [PATCH] pam_apparmor: Don't leak /dev/urandom fd If reading /dev/urandom failed, the corresponding file descriptor was leaked through the error path. Coverity CID #56012 Signed-off-by: Tyler Hicks Acked-by: Steve Beattie --- changehat/pam_apparmor/pam_apparmor.c | 1 + 1 file changed, 1 insertion(+) diff --git a/changehat/pam_apparmor/pam_apparmor.c b/changehat/pam_apparmor/pam_apparmor.c index 21c323f8f..85b6f7bbb 100644 --- a/changehat/pam_apparmor/pam_apparmor.c +++ b/changehat/pam_apparmor/pam_apparmor.c @@ -111,6 +111,7 @@ int pam_sm_open_session(pam_handle_t *pamh, int flags, sizeof(magic_token)); if (retval < 0) { pam_syslog(pamh, LOG_ERR, "Can't read from /dev/urandom\n"); + close(fd); return PAM_PERM_DENIED; } } while ((magic_token == 0) || (retval != sizeof(magic_token)));