[SCM] Samba Shared Repository - branch master updated

Pavel Filipensky pfilipensky at samba.org
Tue Jul 25 12:09:01 UTC 2023


The branch, master has been updated
       via  dd998cc1633 s3:winbindd: Fix double close(fd)
      from  61c951e063e mdscli: correct handling of in-progress searches

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit dd998cc163358edd6c748e40900247877f91eb1f
Author: Pavel Filipenský <pfilipensky at samba.org>
Date:   Tue Jul 25 11:16:56 2023 +0200

    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 at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    
    Autobuild-User(master): Pavel Filipensky <pfilipensky at samba.org>
    Autobuild-Date(master): Tue Jul 25 12:08:49 UTC 2023 on atb-devel-224

-----------------------------------------------------------------------

Summary of changes:
 source3/winbindd/winbindd_cm.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/winbindd/winbindd_cm.c b/source3/winbindd/winbindd_cm.c
index 23dbb9c0cb7..9f56596669b 100644
--- a/source3/winbindd/winbindd_cm.c
+++ b/source3/winbindd/winbindd_cm.c
@@ -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;
 		}


-- 
Samba Shared Repository



More information about the samba-cvs mailing list