From: Todd C. Miller Date: Sat, 7 May 2016 13:49:35 +0000 (-0600) Subject: Fix fd leak in sudo_krb5_copy_cc_file() if restore_perms() fails. X-Git-Tag: SUDO_1_8_17^2~80 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=334b8f36a8f0195f1f10467888ff41946450ccc1;p=sudo Fix fd leak in sudo_krb5_copy_cc_file() if restore_perms() fails. Coverity CID 104571. --- diff --git a/plugins/sudoers/ldap.c b/plugins/sudoers/ldap.c index 00fcb2105..91d53acc6 100644 --- a/plugins/sudoers/ldap.c +++ b/plugins/sudoers/ldap.c @@ -2596,8 +2596,10 @@ sudo_krb5_copy_cc_file(const char *old_ccname) if (!set_perms(PERM_USER)) goto done; ofd = open(old_ccname, O_RDONLY|O_NONBLOCK); - if (!restore_perms()) + if (!restore_perms()) { + close(ofd); goto done; + } if (ofd != -1) { (void) fcntl(ofd, F_SETFL, 0);