Fix fd leak in sudo_edit_open_nonwritable() if dir_is_writable()

returns an error.  Coverity CID 104113.
This commit is contained in:
Todd C. Miller
2016-05-07 05:07:38 -06:00
parent d733dd7783
commit 355cce4570

View 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++;