]> granicus.if.org Git - sudo/commitdiff
Fix fd leak in sudo_edit_open_nonwritable() if dir_is_writable()
authorTodd C. Miller <Todd.Miller@courtesan.com>
Sat, 7 May 2016 11:07:38 +0000 (05:07 -0600)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Sat, 7 May 2016 11:07:38 +0000 (05:07 -0600)
returns an error.  Coverity CID 104113.

src/sudo_edit.c

index 9c83b02666d0e089d00aa10db8c494001f2e81d6..8679f7e2e64b43582e30b98f0689103c3dc566ed 100644 (file)
@@ -384,8 +384,10 @@ sudo_edit_open_nonwritable(char *path, int oflags, mode_t mode,
         * writable directories.
         */
        is_writable = dir_is_writable(dfd, &user_details, command_details);
-       if (is_writable == -1)
+       if (is_writable == -1) {
+           close(dfd);
            debug_return_int(-1);
+       }
 
        while (path[0] == '/')
            path++;