s3:libsmb: Pass a memory context to cli_start_connection()
authorAndreas Schneider <asn@samba.org>
Thu, 23 Nov 2023 13:51:48 +0000 (14:51 +0100)
committerVolker Lendecke <vl@samba.org>
Mon, 29 Apr 2024 08:43:32 +0000 (08:43 +0000)
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
source3/client/smbspool.c
source3/libsmb/cliconnect.c
source3/libsmb/proto.h
source3/torture/torture.c

index b3da87556d2d437259381c8272c4f21e2051649f..363f14a085f45449ca218cc38dda7531254a0e7f 100644 (file)
@@ -544,8 +544,14 @@ smb_complete_connection(struct cli_state **output_cli,
        struct cli_credentials *creds = NULL;
 
        /* Start the SMB connection */
-       nt_status = cli_start_connection(&cli, myname, server, NULL, port,
-                                        SMB_SIGNING_DEFAULT, 0);
+       nt_status = cli_start_connection(talloc_tos(),
+                                        &cli,
+                                        myname,
+                                        server,
+                                        NULL,
+                                        port,
+                                        SMB_SIGNING_DEFAULT,
+                                        0);
        if (!NT_STATUS_IS_OK(nt_status)) {
                fprintf(stderr, "ERROR: Connection failed: %s\n", nt_errstr(nt_status));
                return nt_status;
index 327848bbdeff987774e7d0b152c594abb9864f1f..8ac22ba2ae83339a5da6ba29b818925cf2773107 100644 (file)
@@ -2961,7 +2961,8 @@ static NTSTATUS cli_start_connection_recv(struct tevent_req *req,
        return NT_STATUS_OK;
 }
 
-NTSTATUS cli_start_connection(struct cli_state **output_cli,
+NTSTATUS cli_start_connection(TALLOC_CTX *mem_ctx,
+                             struct cli_state **output_cli,
                              const char *my_name,
                              const char *dest_host,
                              const struct sockaddr_storage *dest_ss, int port,
@@ -2971,7 +2972,7 @@ NTSTATUS cli_start_connection(struct cli_state **output_cli,
        struct tevent_req *req;
        NTSTATUS status = NT_STATUS_NO_MEMORY;
 
-       ev = samba_tevent_context_init(talloc_tos());
+       ev = samba_tevent_context_init(mem_ctx);
        if (ev == NULL) {
                goto fail;
        }
@@ -2983,7 +2984,7 @@ NTSTATUS cli_start_connection(struct cli_state **output_cli,
        if (!tevent_req_poll_ntstatus(req, ev, &status)) {
                goto fail;
        }
-       status = cli_start_connection_recv(req, NULL, output_cli);
+       status = cli_start_connection_recv(req, mem_ctx, output_cli);
 fail:
        TALLOC_FREE(ev);
        return status;
index ec24f411a4c6ec84c6bfef272277049d3a48f7b5..2f67cbfd074d366dd68eb5d5c7b4ff64ea7f7e07 100644 (file)
@@ -91,7 +91,8 @@ NTSTATUS cli_connect_nb(TALLOC_CTX *mem_ctx,
                        enum smb_signing_setting signing_state,
                        int flags,
                        struct cli_state **pcli);
-NTSTATUS cli_start_connection(struct cli_state **output_cli,
+NTSTATUS cli_start_connection(TALLOC_CTX *mem_ctx,
+                             struct cli_state **output_cli,
                              const char *my_name,
                              const char *dest_host,
                              const struct sockaddr_storage *dest_ss, int port,
index ca66a6db5fcc9c95f41d41c7cbc19e974580fa6f..a154b5286816ad18e058129f1ed5121424484635 100644 (file)
@@ -10644,8 +10644,14 @@ static bool run_chain2(int dummy)
        int flags = CLI_FULL_CONNECTION_FORCE_SMB1;
 
        printf("starting chain2 test\n");
-       status = cli_start_connection(&cli1, lp_netbios_name(), host, NULL,
-                                     port_to_use, SMB_SIGNING_DEFAULT, flags);
+       status = cli_start_connection(talloc_tos(),
+                                     &cli1,
+                                     lp_netbios_name(),
+                                     host,
+                                     NULL,
+                                     port_to_use,
+                                     SMB_SIGNING_DEFAULT,
+                                     flags);
        if (!NT_STATUS_IS_OK(status)) {
                return False;
        }