]> granicus.if.org Git - sudo/commitdiff
Fix fd leak in sudo_krb5_copy_cc_file() if restore_perms() fails.
authorTodd C. Miller <Todd.Miller@courtesan.com>
Sat, 7 May 2016 13:49:35 +0000 (07:49 -0600)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Sat, 7 May 2016 13:49:35 +0000 (07:49 -0600)
Coverity CID 104571.

plugins/sudoers/ldap.c

index 00fcb2105548e48da6453c51fc7f32802b31fe6e..91d53acc61bab169d2bf4cad353caa384f1ccc08 100644 (file)
@@ -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);