1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-11 05:18:09 +03:00

s3: libsmb: Correctly do lifecycle management on cli->smb1.tcon and cli->smb2.tcon.

Treat them identically. Create them on demand after for a tcon call,
and delete them on a tdis call.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=12831

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Richard Sharpe <realrichardsharpe@gmail.com>
This commit is contained in:
Jeremy Allison 2017-06-13 16:37:39 -07:00
parent c9178ed9cc
commit 50f50256aa
2 changed files with 21 additions and 7 deletions

View File

@ -1948,6 +1948,13 @@ struct tevent_req *cli_tcon_andx_create(TALLOC_CTX *mem_ctx,
state->cli = cli;
vwv = state->vwv;
TALLOC_FREE(cli->smb1.tcon);
cli->smb1.tcon = smbXcli_tcon_create(cli);
if (tevent_req_nomem(cli->smb1.tcon, req)) {
return tevent_req_post(req, ev);
}
smb1cli_tcon_set_id(cli->smb1.tcon, UINT16_MAX);
cli->share = talloc_strdup(cli, share);
if (!cli->share) {
return NULL;
@ -2257,6 +2264,7 @@ static struct tevent_req *cli_tree_connect_send(
if (smbXcli_conn_protocol(cli->conn) >= PROTOCOL_SMB2_02) {
char *unc;
TALLOC_FREE(cli->smb2.tcon);
cli->smb2.tcon = smbXcli_tcon_create(cli);
if (tevent_req_nomem(cli->smb2.tcon, req)) {
return tevent_req_post(req, ev);
@ -2429,7 +2437,7 @@ static void cli_tdis_done(struct tevent_req *subreq)
tevent_req_nterror(req, status);
return;
}
cli_state_set_tid(state->cli, UINT16_MAX);
TALLOC_FREE(state->cli->smb1.tcon);
tevent_req_done(req);
}
@ -2445,10 +2453,14 @@ NTSTATUS cli_tdis(struct cli_state *cli)
NTSTATUS status = NT_STATUS_NO_MEMORY;
if (smbXcli_conn_protocol(cli->conn) >= PROTOCOL_SMB2_02) {
return smb2cli_tdis(cli->conn,
status = smb2cli_tdis(cli->conn,
cli->timeout,
cli->smb2.session,
cli->smb2.tcon);
if (NT_STATUS_IS_OK(status)) {
TALLOC_FREE(cli->smb2.tcon);
}
return status;
}
if (smbXcli_conn_has_async_calls(cli->conn)) {
@ -3623,6 +3635,13 @@ static struct tevent_req *cli_raw_tcon_send(
return tevent_req_post(req, ev);
}
TALLOC_FREE(cli->smb1.tcon);
cli->smb1.tcon = smbXcli_tcon_create(cli);
if (tevent_req_nomem(cli->smb1.tcon, req)) {
return tevent_req_post(req, ev);
}
smb1cli_tcon_set_id(cli->smb1.tcon, UINT16_MAX);
bytes = talloc_array(state, uint8_t, 0);
bytes = smb_bytes_push_bytes(bytes, 4, NULL, 0);
bytes = smb_bytes_push_str(bytes, smbXcli_conn_use_unicode(cli->conn),

View File

@ -227,11 +227,6 @@ struct cli_state *cli_state_create(TALLOC_CTX *mem_ctx,
cli->smb1.pid = (uint32_t)getpid();
cli->smb1.vc_num = cli->smb1.pid;
cli->smb1.tcon = smbXcli_tcon_create(cli);
if (cli->smb1.tcon == NULL) {
goto error;
}
smb1cli_tcon_set_id(cli->smb1.tcon, UINT16_MAX);
cli->smb1.session = smbXcli_session_create(cli, cli->conn);
if (cli->smb1.session == NULL) {
goto error;