summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source4/libcli/smb2/close.c2
-rw-r--r--source4/libcli/smb2/create.c2
-rw-r--r--source4/libcli/smb2/find.c2
-rw-r--r--source4/libcli/smb2/flush.c2
-rw-r--r--source4/libcli/smb2/getinfo.c2
-rw-r--r--source4/libcli/smb2/ioctl.c2
-rw-r--r--source4/libcli/smb2/keepalive.c2
-rw-r--r--source4/libcli/smb2/logoff.c2
-rw-r--r--source4/libcli/smb2/negprot.c2
-rw-r--r--source4/libcli/smb2/read.c2
-rw-r--r--source4/libcli/smb2/request.c17
-rw-r--r--source4/libcli/smb2/session.c2
-rw-r--r--source4/libcli/smb2/setinfo.c2
-rw-r--r--source4/libcli/smb2/tcon.c2
-rw-r--r--source4/libcli/smb2/tdis.c2
-rw-r--r--source4/libcli/smb2/write.c2
-rw-r--r--source4/smb_server/smb2/keepalive.c2
-rw-r--r--source4/smb_server/smb2/negprot.c2
-rw-r--r--source4/smb_server/smb2/receive.c13
-rw-r--r--source4/smb_server/smb2/sesssetup.c4
-rw-r--r--source4/smb_server/smb2/tcon.c4
-rw-r--r--source4/torture/smb2/scan.c2
22 files changed, 47 insertions, 27 deletions
diff --git a/source4/libcli/smb2/close.c b/source4/libcli/smb2/close.c
index 3e559fe893..4483f3c75b 100644
--- a/source4/libcli/smb2/close.c
+++ b/source4/libcli/smb2/close.c
@@ -32,7 +32,7 @@ struct smb2_request *smb2_close_send(struct smb2_tree *tree, struct smb2_close *
{
struct smb2_request *req;
- req = smb2_request_init_tree(tree, SMB2_OP_CLOSE, 0x18, 0);
+ req = smb2_request_init_tree(tree, SMB2_OP_CLOSE, 0x18, False, 0);
if (req == NULL) return NULL;
SSVAL(req->out.body, 0x02, io->in.flags);
diff --git a/source4/libcli/smb2/create.c b/source4/libcli/smb2/create.c
index c7bb190559..339258a0df 100644
--- a/source4/libcli/smb2/create.c
+++ b/source4/libcli/smb2/create.c
@@ -67,7 +67,7 @@ struct smb2_request *smb2_create_send(struct smb2_tree *tree, struct smb2_create
NTSTATUS status;
DATA_BLOB blob = data_blob(NULL, 0);
- req = smb2_request_init_tree(tree, SMB2_OP_CREATE, 0x38, 1);
+ req = smb2_request_init_tree(tree, SMB2_OP_CREATE, 0x38, True, 0);
if (req == NULL) return NULL;
SSVAL(req->out.body, 0x02, io->in.oplock_flags);
diff --git a/source4/libcli/smb2/find.c b/source4/libcli/smb2/find.c
index aa14347022..e811095f42 100644
--- a/source4/libcli/smb2/find.c
+++ b/source4/libcli/smb2/find.c
@@ -33,7 +33,7 @@ struct smb2_request *smb2_find_send(struct smb2_tree *tree, struct smb2_find *io
struct smb2_request *req;
NTSTATUS status;
- req = smb2_request_init_tree(tree, SMB2_OP_FIND, 0x20, 1);
+ req = smb2_request_init_tree(tree, SMB2_OP_FIND, 0x20, True, 0);
if (req == NULL) return NULL;
SCVAL(req->out.body, 0x02, io->in.level);
diff --git a/source4/libcli/smb2/flush.c b/source4/libcli/smb2/flush.c
index d9178aeb9f..596eb26009 100644
--- a/source4/libcli/smb2/flush.c
+++ b/source4/libcli/smb2/flush.c
@@ -31,7 +31,7 @@ struct smb2_request *smb2_flush_send(struct smb2_tree *tree, struct smb2_flush *
{
struct smb2_request *req;
- req = smb2_request_init_tree(tree, SMB2_OP_FLUSH, 0x18, 0);
+ req = smb2_request_init_tree(tree, SMB2_OP_FLUSH, 0x18, False, 0);
if (req == NULL) return NULL;
SSVAL(req->out.body, 0x02, 0); /* pad? */
diff --git a/source4/libcli/smb2/getinfo.c b/source4/libcli/smb2/getinfo.c
index d52ff03922..57a363b63f 100644
--- a/source4/libcli/smb2/getinfo.c
+++ b/source4/libcli/smb2/getinfo.c
@@ -32,7 +32,7 @@ struct smb2_request *smb2_getinfo_send(struct smb2_tree *tree, struct smb2_getin
{
struct smb2_request *req;
- req = smb2_request_init_tree(tree, SMB2_OP_GETINFO, 0x28, 0);
+ req = smb2_request_init_tree(tree, SMB2_OP_GETINFO, 0x28, False, 0);
if (req == NULL) return NULL;
/* this seems to be a bug, they use 0x29 but only send 0x28 bytes */
diff --git a/source4/libcli/smb2/ioctl.c b/source4/libcli/smb2/ioctl.c
index 533f12c9d3..ffe029e16e 100644
--- a/source4/libcli/smb2/ioctl.c
+++ b/source4/libcli/smb2/ioctl.c
@@ -32,7 +32,7 @@ struct smb2_request *smb2_ioctl_send(struct smb2_tree *tree, struct smb2_ioctl *
NTSTATUS status;
struct smb2_request *req;
- req = smb2_request_init_tree(tree, SMB2_OP_IOCTL, 0x38,
+ req = smb2_request_init_tree(tree, SMB2_OP_IOCTL, 0x38, True,
io->in.in.length+io->in.out.length);
if (req == NULL) return NULL;
diff --git a/source4/libcli/smb2/keepalive.c b/source4/libcli/smb2/keepalive.c
index b800bdb3b1..ac31afd4dc 100644
--- a/source4/libcli/smb2/keepalive.c
+++ b/source4/libcli/smb2/keepalive.c
@@ -31,7 +31,7 @@ struct smb2_request *smb2_keepalive_send(struct smb2_transport *transport)
{
struct smb2_request *req;
- req = smb2_request_init(transport, SMB2_OP_KEEPALIVE, 0x04, 0);
+ req = smb2_request_init(transport, SMB2_OP_KEEPALIVE, 0x04, False, 0);
if (req == NULL) return NULL;
SSVAL(req->out.body, 0x02, 0);
diff --git a/source4/libcli/smb2/logoff.c b/source4/libcli/smb2/logoff.c
index 977c1e57af..cfaa389ef8 100644
--- a/source4/libcli/smb2/logoff.c
+++ b/source4/libcli/smb2/logoff.c
@@ -31,7 +31,7 @@ struct smb2_request *smb2_logoff_send(struct smb2_session *session)
{
struct smb2_request *req;
- req = smb2_request_init(session->transport, SMB2_OP_LOGOFF, 0x04, 0);
+ req = smb2_request_init(session->transport, SMB2_OP_LOGOFF, 0x04, False, 0);
if (req == NULL) return NULL;
SBVAL(req->out.hdr, SMB2_HDR_UID, session->uid);
diff --git a/source4/libcli/smb2/negprot.c b/source4/libcli/smb2/negprot.c
index a3cf8eb018..c3b72186a9 100644
--- a/source4/libcli/smb2/negprot.c
+++ b/source4/libcli/smb2/negprot.c
@@ -33,7 +33,7 @@ struct smb2_request *smb2_negprot_send(struct smb2_transport *transport,
{
struct smb2_request *req;
- req = smb2_request_init(transport, SMB2_OP_NEGPROT, 0x26, 0);
+ req = smb2_request_init(transport, SMB2_OP_NEGPROT, 0x26, False, 0);
if (req == NULL) return NULL;
/* this seems to be a bug, they use 0x24 but the length is 0x26 */
diff --git a/source4/libcli/smb2/read.c b/source4/libcli/smb2/read.c
index da2d3bb7c9..82e9b13280 100644
--- a/source4/libcli/smb2/read.c
+++ b/source4/libcli/smb2/read.c
@@ -31,7 +31,7 @@ struct smb2_request *smb2_read_send(struct smb2_tree *tree, struct smb2_read *io
{
struct smb2_request *req;
- req = smb2_request_init_tree(tree, SMB2_OP_READ, 0x31, 0);
+ req = smb2_request_init_tree(tree, SMB2_OP_READ, 0x31, False, 0);
if (req == NULL) return NULL;
SSVAL(req->out.body, 0x02, 0); /* pad */
diff --git a/source4/libcli/smb2/request.c b/source4/libcli/smb2/request.c
index 2476270d49..136b81e977 100644
--- a/source4/libcli/smb2/request.c
+++ b/source4/libcli/smb2/request.c
@@ -31,10 +31,19 @@
initialise a smb2 request
*/
struct smb2_request *smb2_request_init(struct smb2_transport *transport, uint16_t opcode,
- uint16_t body_fixed_size, uint32_t body_dynamic_size)
+ uint16_t body_fixed_size, BOOL body_dynamic_present,
+ uint32_t body_dynamic_size)
{
struct smb2_request *req;
+ if (body_dynamic_present) {
+ if (body_dynamic_size == 0) {
+ body_dynamic_size = 1;
+ }
+ } else {
+ body_dynamic_size = 0;
+ }
+
req = talloc(transport, struct smb2_request);
if (req == NULL) return NULL;
@@ -95,10 +104,12 @@ struct smb2_request *smb2_request_init(struct smb2_transport *transport, uint16_
initialise a smb2 request for tree operations
*/
struct smb2_request *smb2_request_init_tree(struct smb2_tree *tree, uint16_t opcode,
- uint16_t body_fixed_size, uint32_t body_dynamic_size)
+ uint16_t body_fixed_size, BOOL body_dynamic_present,
+ uint32_t body_dynamic_size)
{
struct smb2_request *req = smb2_request_init(tree->session->transport, opcode,
- body_fixed_size, body_dynamic_size);
+ body_fixed_size, body_dynamic_present,
+ body_dynamic_size);
if (req == NULL) return NULL;
SBVAL(req->out.hdr, SMB2_HDR_UID, tree->session->uid);
diff --git a/source4/libcli/smb2/session.c b/source4/libcli/smb2/session.c
index 1d1b97600a..83e6d1ae00 100644
--- a/source4/libcli/smb2/session.c
+++ b/source4/libcli/smb2/session.c
@@ -69,7 +69,7 @@ struct smb2_request *smb2_session_setup_send(struct smb2_session *session,
NTSTATUS status;
req = smb2_request_init(session->transport, SMB2_OP_SESSSETUP,
- 0x10, io->in.secblob.length);
+ 0x10, True, io->in.secblob.length);
if (req == NULL) return NULL;
SBVAL(req->out.hdr, SMB2_HDR_UID, session->uid);
diff --git a/source4/libcli/smb2/setinfo.c b/source4/libcli/smb2/setinfo.c
index c445880440..432034b13b 100644
--- a/source4/libcli/smb2/setinfo.c
+++ b/source4/libcli/smb2/setinfo.c
@@ -33,7 +33,7 @@ struct smb2_request *smb2_setinfo_send(struct smb2_tree *tree, struct smb2_setin
NTSTATUS status;
struct smb2_request *req;
- req = smb2_request_init_tree(tree, SMB2_OP_SETINFO, 0x20, io->in.blob.length);
+ req = smb2_request_init_tree(tree, SMB2_OP_SETINFO, 0x20, True, io->in.blob.length);
if (req == NULL) return NULL;
SSVAL(req->out.body, 0x02, io->in.level);
diff --git a/source4/libcli/smb2/tcon.c b/source4/libcli/smb2/tcon.c
index 3fc14075a5..8b94936c42 100644
--- a/source4/libcli/smb2/tcon.c
+++ b/source4/libcli/smb2/tcon.c
@@ -54,7 +54,7 @@ struct smb2_request *smb2_tree_connect_send(struct smb2_tree *tree,
NTSTATUS status;
req = smb2_request_init(tree->session->transport, SMB2_OP_TCON,
- 0x08, 1);
+ 0x08, True, 0);
if (req == NULL) return NULL;
SBVAL(req->out.hdr, SMB2_HDR_UID, tree->session->uid);
diff --git a/source4/libcli/smb2/tdis.c b/source4/libcli/smb2/tdis.c
index 9ea58113b3..f89e5c8e90 100644
--- a/source4/libcli/smb2/tdis.c
+++ b/source4/libcli/smb2/tdis.c
@@ -31,7 +31,7 @@ struct smb2_request *smb2_tdis_send(struct smb2_tree *tree)
{
struct smb2_request *req;
- req = smb2_request_init_tree(tree, SMB2_OP_TDIS, 0x04, 0);
+ req = smb2_request_init_tree(tree, SMB2_OP_TDIS, 0x04, False, 0);
if (req == NULL) return NULL;
SSVAL(req->out.body, 0x02, 0);
diff --git a/source4/libcli/smb2/write.c b/source4/libcli/smb2/write.c
index adf690c1b3..1edce3f773 100644
--- a/source4/libcli/smb2/write.c
+++ b/source4/libcli/smb2/write.c
@@ -32,7 +32,7 @@ struct smb2_request *smb2_write_send(struct smb2_tree *tree, struct smb2_write *
NTSTATUS status;
struct smb2_request *req;
- req = smb2_request_init_tree(tree, SMB2_OP_WRITE, 0x30, io->in.data.length);
+ req = smb2_request_init_tree(tree, SMB2_OP_WRITE, 0x30, True, io->in.data.length);
if (req == NULL) return NULL;
status = smb2_push_o16s32_blob(&req->out, 0x02, io->in.data);
diff --git a/source4/smb_server/smb2/keepalive.c b/source4/smb_server/smb2/keepalive.c
index ca8983d5e2..4994af4a0d 100644
--- a/source4/smb_server/smb2/keepalive.c
+++ b/source4/smb_server/smb2/keepalive.c
@@ -39,7 +39,7 @@ static void smb2srv_keepalive_send(struct smb2srv_request *req)
return;
}
- status = smb2srv_setup_reply(req, 0x04, 0);
+ status = smb2srv_setup_reply(req, 0x04, False, 0);
if (!NT_STATUS_IS_OK(status)) {
smbsrv_terminate_connection(req->smb_conn, nt_errstr(status));
talloc_free(req);
diff --git a/source4/smb_server/smb2/negprot.c b/source4/smb_server/smb2/negprot.c
index 351c9e718f..6d180eb1d6 100644
--- a/source4/smb_server/smb2/negprot.c
+++ b/source4/smb_server/smb2/negprot.c
@@ -117,7 +117,7 @@ static void smb2srv_negprot_send(struct smb2srv_request *req, struct smb2_negpro
return;
}
- status = smb2srv_setup_reply(req, 0x40, io->out.secblob.length);
+ status = smb2srv_setup_reply(req, 0x40, True, io->out.secblob.length);
if (!NT_STATUS_IS_OK(status)) {
smbsrv_terminate_connection(req->smb_conn, nt_errstr(status));
talloc_free(req);
diff --git a/source4/smb_server/smb2/receive.c b/source4/smb_server/smb2/receive.c
index e27e622a4a..abd825adcc 100644
--- a/source4/smb_server/smb2/receive.c
+++ b/source4/smb_server/smb2/receive.c
@@ -41,8 +41,17 @@ static struct smb2srv_request *smb2srv_init_request(struct smbsrv_connection *sm
return req;
}
-NTSTATUS smb2srv_setup_reply(struct smb2srv_request *req, uint_t body_fixed_size, size_t body_dynamic_size)
+NTSTATUS smb2srv_setup_reply(struct smb2srv_request *req, uint16_t body_fixed_size,
+ BOOL body_dynamic_present, uint32_t body_dynamic_size)
{
+ if (body_dynamic_present) {
+ if (body_dynamic_size == 0) {
+ body_dynamic_size = 1;
+ }
+ } else {
+ body_dynamic_size = 0;
+ }
+
req->out.size = SMB2_HDR_BODY+NBT_HDR_SIZE+body_fixed_size;
req->out.allocated = req->out.size + body_dynamic_size;
@@ -103,7 +112,7 @@ void smb2srv_send_error(struct smb2srv_request *req, NTSTATUS error)
{
NTSTATUS status;
- status = smb2srv_setup_reply(req, 8, 1);
+ status = smb2srv_setup_reply(req, 8, True, 0);
if (!NT_STATUS_IS_OK(status)) {
smbsrv_terminate_connection(req->smb_conn, nt_errstr(status));
talloc_free(req);
diff --git a/source4/smb_server/smb2/sesssetup.c b/source4/smb_server/smb2/sesssetup.c
index 6d94d43155..a5b9cf50bd 100644
--- a/source4/smb_server/smb2/sesssetup.c
+++ b/source4/smb_server/smb2/sesssetup.c
@@ -126,7 +126,7 @@ static void smb2srv_sesssetup_send(struct smb2srv_request *req, struct smb2_sess
return;
}
- status = smb2srv_setup_reply(req, 0x08, io->out.secblob.length);
+ status = smb2srv_setup_reply(req, 0x08, True, io->out.secblob.length);
if (!NT_STATUS_IS_OK(status)) {
smbsrv_terminate_connection(req->smb_conn, nt_errstr(status));
talloc_free(req);
@@ -199,7 +199,7 @@ static void smb2srv_logoff_send(struct smb2srv_request *req)
return;
}
- status = smb2srv_setup_reply(req, 0x04, 0);
+ status = smb2srv_setup_reply(req, 0x04, False, 0);
if (!NT_STATUS_IS_OK(status)) {
smbsrv_terminate_connection(req->smb_conn, nt_errstr(status));
talloc_free(req);
diff --git a/source4/smb_server/smb2/tcon.c b/source4/smb_server/smb2/tcon.c
index 8d6c002d50..ba7758b362 100644
--- a/source4/smb_server/smb2/tcon.c
+++ b/source4/smb_server/smb2/tcon.c
@@ -54,7 +54,7 @@ static void smb2srv_tcon_send(struct smb2srv_request *req, struct smb2_tree_conn
return;
}
- status = smb2srv_setup_reply(req, 0x10, 0);
+ status = smb2srv_setup_reply(req, 0x10, False, 0);
if (!NT_STATUS_IS_OK(status)) {
smbsrv_terminate_connection(req->smb_conn, nt_errstr(status));
talloc_free(req);
@@ -122,7 +122,7 @@ static void smb2srv_tdis_send(struct smb2srv_request *req)
return;
}
- status = smb2srv_setup_reply(req, 0x04, 0);
+ status = smb2srv_setup_reply(req, 0x04, False, 0);
if (!NT_STATUS_IS_OK(status)) {
smbsrv_terminate_connection(req->smb_conn, nt_errstr(status));
talloc_free(req);
diff --git a/source4/torture/smb2/scan.c b/source4/torture/smb2/scan.c
index 28e83541c7..8e339c4080 100644
--- a/source4/torture/smb2/scan.c
+++ b/source4/torture/smb2/scan.c
@@ -219,7 +219,7 @@ BOOL torture_smb2_scan(struct torture_context *torture)
tree->session->transport->options.timeout = 3;
for (opcode=0;opcode<1000;opcode++) {
- req = smb2_request_init_tree(tree, opcode, 2, 0);
+ req = smb2_request_init_tree(tree, opcode, 2, False, 0);
SSVAL(req->out.body, 0, 0);
smb2_transport_send(req);
if (!smb2_request_receive(req)) {