diff options
-rw-r--r-- | source3/include/client.h | 4 | ||||
-rw-r--r-- | source3/libsmb/cliconnect.c | 18 | ||||
-rw-r--r-- | source3/libsmb/clientgen.c | 6 |
3 files changed, 19 insertions, 9 deletions
diff --git a/source3/include/client.h b/source3/include/client.h index 77e1240046..3701aec554 100644 --- a/source3/include/client.h +++ b/source3/include/client.h @@ -70,7 +70,6 @@ struct cli_state { int readbraw_supported; int writebraw_supported; int timeout; /* in milliseconds. */ - size_t max_xmit; size_t max_mux; int initialised; int win95; @@ -130,13 +129,16 @@ struct cli_state { struct { struct { uint32_t capabilities; + uint32_t max_xmit; } client; struct { uint32_t capabilities; + uint32_t max_xmit; } server; uint32_t capabilities; + uint32_t max_xmit; uint16_t mid; } smb1; diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c index 6e34c3d622..1abd76018a 100644 --- a/source3/libsmb/cliconnect.c +++ b/source3/libsmb/cliconnect.c @@ -2611,6 +2611,9 @@ static void cli_negprot_done(struct tevent_req *subreq) uint32_t both_capabilities; uint32_t server_capabilities = 0; uint32_t capabilities; + uint32_t client_max_xmit = cli->conn.smb1.client.max_xmit; + uint32_t server_max_xmit = 0; + uint32_t max_xmit; enum protocol_types protocol; status = cli_smb_recv(subreq, state, &inbuf, 1, &wct, &vwv, @@ -2654,7 +2657,7 @@ static void cli_negprot_done(struct tevent_req *subreq) /* NT protocol */ cli->sec_mode = CVAL(vwv + 1, 0); cli->max_mux = SVAL(vwv + 1, 1); - cli->max_xmit = IVAL(vwv + 3, 1); + server_max_xmit = IVAL(vwv + 3, 1); cli->sesskey = IVAL(vwv + 7, 1); cli->serverzone = SVALS(vwv + 15, 1); cli->serverzone *= 60; @@ -2715,7 +2718,7 @@ static void cli_negprot_done(struct tevent_req *subreq) } cli->sec_mode = SVAL(vwv + 1, 0); - cli->max_xmit = SVAL(vwv + 2, 0); + server_max_xmit = SVAL(vwv + 2, 0); cli->max_mux = SVAL(vwv + 3, 0); cli->sesskey = IVAL(vwv + 6, 0); cli->serverzone = SVALS(vwv + 10, 0); @@ -2730,11 +2733,11 @@ static void cli_negprot_done(struct tevent_req *subreq) /* the old core protocol */ cli->sec_mode = 0; cli->serverzone = get_time_zone(time(NULL)); - cli->max_xmit = 1024; + server_max_xmit = 1024; cli->max_mux = 1; } - if (cli->max_xmit < 1024) { + if (server_max_xmit < 1024) { tevent_req_nterror(req, NT_STATUS_INVALID_NETWORK_RESPONSE); return; } @@ -2744,8 +2747,6 @@ static void cli_negprot_done(struct tevent_req *subreq) return; } - cli->max_xmit = MIN(cli->max_xmit, CLI_BUFFER_SIZE); - /* * Now calculate the negotiated capabilities * based on the mask for: @@ -2758,11 +2759,16 @@ static void cli_negprot_done(struct tevent_req *subreq) capabilities |= both_capabilities & SMB_CAP_BOTH_MASK; capabilities |= server_capabilities & SMB_CAP_SERVER_MASK; + max_xmit = MIN(client_max_xmit, server_max_xmit); + cli->conn.protocol = protocol; cli->conn.smb1.server.capabilities = server_capabilities; cli->conn.smb1.capabilities = capabilities; + cli->conn.smb1.server.max_xmit = server_max_xmit; + cli->conn.smb1.max_xmit = max_xmit; + tevent_req_done(req); } diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c index 720a118559..9091ad38d8 100644 --- a/source3/libsmb/clientgen.c +++ b/source3/libsmb/clientgen.c @@ -195,7 +195,6 @@ struct cli_state *cli_state_create(TALLOC_CTX *mem_ctx, } cli->raw_status = NT_STATUS_INTERNAL_ERROR; cli->timeout = 20000; /* Timeout is in milliseconds. */ - cli->max_xmit = CLI_BUFFER_SIZE+4; cli->case_sensitive = false; /* Set the CLI_FORCE_DOSERR environment variable to test @@ -302,7 +301,10 @@ struct cli_state *cli_state_create(TALLOC_CTX *mem_ctx, cli->conn.smb1.client.capabilities |= CAP_LEVEL_II_OPLOCKS; } + cli->conn.smb1.client.max_xmit = CLI_BUFFER_SIZE; + cli->conn.smb1.capabilities = cli->conn.smb1.client.capabilities; + cli->conn.smb1.max_xmit = 1024; cli->conn.smb1.mid = 1; @@ -548,7 +550,7 @@ uint32_t cli_state_capabilities(struct cli_state *cli) uint32_t cli_state_available_size(struct cli_state *cli, uint32_t ofs) { - uint32_t ret = cli->max_xmit; + uint32_t ret = cli->conn.smb1.max_xmit; if (ofs >= ret) { return 0; |