mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
libcli/smb: Allow dynamic setting of the max_data in SMB Pipe transaction.
Some services like WSP can send larger messages than the current 'Max Ioctl' limit, this results in the server producing a BUFFER_OVERFLOW status (and additionally clipping the message sent). Add support to allow a client to modify the hardcoded 'Max Ioctl' default value to allow the server to successfully send larger responses. Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
parent
53d8744554
commit
8cc1e25a00
@ -57,6 +57,7 @@ struct tstream_smbXcli_np {
|
||||
uint16_t fnum;
|
||||
uint64_t fid_persistent;
|
||||
uint64_t fid_volatile;
|
||||
uint32_t max_data;
|
||||
|
||||
struct {
|
||||
bool active;
|
||||
@ -362,6 +363,7 @@ NTSTATUS _tstream_smbXcli_np_open_recv(struct tevent_req *req,
|
||||
cli_nps->fnum = state->fnum;
|
||||
cli_nps->fid_persistent = state->fid_persistent;
|
||||
cli_nps->fid_volatile = state->fid_volatile;
|
||||
cli_nps->max_data = TSTREAM_SMBXCLI_NP_MAX_BUF_SIZE;
|
||||
|
||||
talloc_set_destructor(cli_nps, tstream_smbXcli_np_destructor);
|
||||
talloc_set_destructor(cli_nps->conn_ref,
|
||||
@ -430,6 +432,15 @@ NTSTATUS tstream_smbXcli_np_use_trans(struct tstream_context *stream)
|
||||
return NT_STATUS_OK;
|
||||
}
|
||||
|
||||
void tstream_smbXcli_np_set_max_data(struct tstream_context *stream,
|
||||
uint32_t max_data)
|
||||
{
|
||||
struct tstream_smbXcli_np *cli_nps = tstream_context_data(
|
||||
stream, struct tstream_smbXcli_np);
|
||||
|
||||
cli_nps->max_data = max_data;
|
||||
}
|
||||
|
||||
unsigned int tstream_smbXcli_np_set_timeout(struct tstream_context *stream,
|
||||
unsigned int timeout)
|
||||
{
|
||||
@ -540,7 +551,7 @@ static void tstream_smbXcli_np_writev_write_next(struct tevent_req *req)
|
||||
}
|
||||
|
||||
cli_nps->write.ofs = 0;
|
||||
cli_nps->write.left = MIN(left, TSTREAM_SMBXCLI_NP_MAX_BUF_SIZE);
|
||||
cli_nps->write.left = MIN(left, cli_nps->max_data);
|
||||
cli_nps->write.buf = talloc_realloc(cli_nps, cli_nps->write.buf,
|
||||
uint8_t, cli_nps->write.left);
|
||||
if (tevent_req_nomem(cli_nps->write.buf, req)) {
|
||||
@ -862,14 +873,14 @@ static void tstream_smbXcli_np_readv_read_next(struct tevent_req *req)
|
||||
cli_nps->session,
|
||||
cli_nps->fnum,
|
||||
0, /* offset */
|
||||
TSTREAM_SMBXCLI_NP_MAX_BUF_SIZE);
|
||||
cli_nps->max_data);
|
||||
} else {
|
||||
subreq = smb2cli_read_send(state, state->ev,
|
||||
cli_nps->conn,
|
||||
cli_nps->timeout,
|
||||
cli_nps->session,
|
||||
cli_nps->tcon,
|
||||
TSTREAM_SMBXCLI_NP_MAX_BUF_SIZE, /* length */
|
||||
cli_nps->max_data, /* length */
|
||||
0, /* offset */
|
||||
cli_nps->fid_persistent,
|
||||
cli_nps->fid_volatile,
|
||||
@ -917,7 +928,7 @@ static void tstream_smbXcli_np_readv_trans_start(struct tevent_req *req)
|
||||
NULL, 0, 0,
|
||||
cli_nps->write.buf,
|
||||
cli_nps->write.ofs,
|
||||
TSTREAM_SMBXCLI_NP_MAX_BUF_SIZE);
|
||||
cli_nps->max_data);
|
||||
} else {
|
||||
DATA_BLOB in_input_buffer = data_blob_null;
|
||||
DATA_BLOB in_output_buffer = data_blob_null;
|
||||
@ -936,7 +947,7 @@ static void tstream_smbXcli_np_readv_trans_start(struct tevent_req *req)
|
||||
0, /* in_max_input_length */
|
||||
&in_input_buffer,
|
||||
/* in_max_output_length */
|
||||
TSTREAM_SMBXCLI_NP_MAX_BUF_SIZE,
|
||||
cli_nps->max_data,
|
||||
&in_output_buffer,
|
||||
SMB2_IOCTL_FLAG_IS_FSCTL);
|
||||
}
|
||||
@ -999,7 +1010,7 @@ static void tstream_smbXcli_np_readv_trans_done(struct tevent_req *subreq)
|
||||
return;
|
||||
}
|
||||
|
||||
if (received > TSTREAM_SMBXCLI_NP_MAX_BUF_SIZE) {
|
||||
if (received > cli_nps->max_data) {
|
||||
tstream_smbXcli_np_readv_disconnect_now(req, EIO, __location__);
|
||||
return;
|
||||
}
|
||||
@ -1083,7 +1094,7 @@ static void tstream_smbXcli_np_readv_read_done(struct tevent_req *subreq)
|
||||
return;
|
||||
}
|
||||
|
||||
if (received > TSTREAM_SMBXCLI_NP_MAX_BUF_SIZE) {
|
||||
if (received > cli_nps->max_data) {
|
||||
TALLOC_FREE(subreq);
|
||||
tstream_smbXcli_np_readv_disconnect_now(req, EIO, __location__);
|
||||
return;
|
||||
|
@ -69,4 +69,7 @@ unsigned int tstream_smbXcli_np_set_timeout(struct tstream_context *stream,
|
||||
*/
|
||||
#define TSTREAM_SMBXCLI_NP_MAX_BUF_SIZE 4280
|
||||
|
||||
void tstream_smbXcli_np_set_max_data(struct tstream_context *stream,
|
||||
uint32_t max_data);
|
||||
|
||||
#endif /* _CLI_NP_TSTREAM_H_ */
|
||||
|
Loading…
Reference in New Issue
Block a user