Skip to content

Commit 942efe6

Browse files
committed
new_connection: Fix fd leak if connection_closure_alloc() fails
Found by the ZeroPath AI Security Engineer <https://zeropath.com>
1 parent 22d753a commit 942efe6

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

logsrvd/logsrvd.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1497,8 +1497,10 @@ new_connection(int sock, bool tls, const union sockaddr_union *sa_un,
14971497
struct connection_closure *closure;
14981498
debug_decl(new_connection, SUDO_DEBUG_UTIL);
14991499

1500-
if ((closure = connection_closure_alloc(sock, tls, false, evbase)) == NULL)
1500+
if ((closure = connection_closure_alloc(sock, tls, false, evbase)) == NULL) {
1501+
close(sock);
15011502
goto bad;
1503+
}
15021504

15031505
/* store the peer's IP address in the closure object */
15041506
if (sa_un->sa.sa_family == AF_INET) {

0 commit comments

Comments
 (0)