mirror of
https://github.com/samba-team/samba.git
synced 2025-01-03 01:18:10 +03:00
s3:winbindd: Fix double close(fd)
Reported by Red Hat internal coverity
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15433
Signed-off-by: Pavel Filipenský <pfilipensky@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Pavel Filipensky <pfilipensky@samba.org>
Autobuild-Date(master): Tue Jul 25 12:08:49 UTC 2023 on atb-devel-224
(cherry picked from commit dd998cc163
)
Autobuild-User(v4-18-test): Jule Anger <janger@samba.org>
Autobuild-Date(v4-18-test): Fri Jul 28 13:37:01 UTC 2023 on atb-devel-224
This commit is contained in:
parent
aa2af3c0c2
commit
c1c2a0ec80
@ -708,6 +708,7 @@ static NTSTATUS cm_prepare_connection(struct winbindd_domain *domain,
|
||||
* connect to a foreign domain
|
||||
* without a direct outbound trust.
|
||||
*/
|
||||
close(sockfd);
|
||||
return NT_STATUS_NO_TRUST_LSA_SECRET;
|
||||
}
|
||||
|
||||
@ -761,6 +762,13 @@ static NTSTATUS cm_prepare_connection(struct winbindd_domain *domain,
|
||||
goto done;
|
||||
}
|
||||
|
||||
/*
|
||||
* cm_prepare_connection() is responsible that sockfd does not leak.
|
||||
* Once cli_state_create() returns with success, the
|
||||
* smbXcli_conn_destructor() makes sure that close(sockfd) is finally
|
||||
* called. Till that, close(sockfd) must be called on every unsuccessful
|
||||
* return.
|
||||
*/
|
||||
*cli = cli_state_create(NULL, sockfd, controller,
|
||||
smb_sign_client_connections, flags);
|
||||
if (*cli == NULL) {
|
||||
@ -1749,8 +1757,6 @@ static NTSTATUS cm_open_connection(struct winbindd_domain *domain,
|
||||
if (NT_STATUS_IS_OK(result)) {
|
||||
break;
|
||||
}
|
||||
close(fd);
|
||||
fd = -1;
|
||||
if (!retry) {
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user