From 355cce4570c8c4cb6f1030c06a7360cbea44edd2 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Sat, 7 May 2016 05:07:38 -0600 Subject: [PATCH] Fix fd leak in sudo_edit_open_nonwritable() if dir_is_writable() returns an error. Coverity CID 104113. --- src/sudo_edit.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/sudo_edit.c b/src/sudo_edit.c index 9c83b0266..8679f7e2e 100644 --- a/src/sudo_edit.c +++ b/src/sudo_edit.c @@ -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++; -- 2.50.1