Skip to content

Commit 7f6de89

Browse files
committed
log_server_connect: Close socket on error
Fixes a potential fd leak on the error path. Thanks to Joshua Rogers for finding this.
1 parent f278cb8 commit 7f6de89

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

plugins/sudoers/log_client.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -638,8 +638,11 @@ log_server_connect(struct client_closure *closure)
638638
}
639639
free(copy);
640640

641-
if (!ret && cause != NULL)
642-
sudo_warn("%s", cause);
641+
if (!ret) {
642+
if (cause != NULL)
643+
sudo_warn("%s", cause);
644+
close(sock);
645+
}
643646

644647
debug_return_bool(ret);
645648
}

0 commit comments

Comments
 (0)