[SCM] Samba Shared Repository - branch master updated

Stefan Metzmacher metze at samba.org
Sat Sep 17 23:05:04 MDT 2011


The branch, master has been updated
       via  5f23776 s3:smb2cli: pass timeout to smb2cli_req_create/send()
       via  271f78a s3:smb2cli: pass an array of expected status/body_size pairs to smb2cli_req_recv()
       via  b6b767a s3:smb2cli: only use tevent_req_defer_callback() if we have more than one smb2 response
       via  46f64aa s3:smb2cli: ignore async interim responses and store the async_id
       via  eb46c7b s3:smb2cli: check the response has the SMB2_HDR_FLAG_REDIRECT flag
       via  8209157 s3:smb2cli: validate the opcode from the server is as expected
       via  270e88f s3:smb2cli: initialize status if we got an unexpected response
       via  2bb17dc s3:libsmb: return INTERNAL_ERROR if the request is in bad state when the caller ships it
       via  bbe78ca s3:libsmb: return if tevent_req_set_endtime() fails
       via  79043f8 s3:SMB2-BASIC: test smb2cli_flush()
       via  a0dcbf8 s3:smb2cli: SMB2_FLUSH responses have a body size of 4
      from  80d643f s3: Trim a debug to 80 chars

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 5f237763f89ce13240a6e47dddc4dff60e26fa7f
Author: Stefan Metzmacher <metze at samba.org>
Date:   Sat Sep 17 19:56:50 2011 +0200

    s3:smb2cli: pass timeout to smb2cli_req_create/send()
    
    metze
    
    Autobuild-User: Stefan Metzmacher <metze at samba.org>
    Autobuild-Date: Sun Sep 18 07:04:05 CEST 2011 on sn-devel-104

commit 271f78a9bb814ed10bcc8883a60d6609e1eef500
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Aug 31 00:40:06 2011 +0200

    s3:smb2cli: pass an array of expected status/body_size pairs to smb2cli_req_recv()
    
    This gives the caller more control and correctly reports unexpected
    errors to the caller, instead of return NT_STATUS_INVALID_NETWOR_RESPONSE
    
    metze

commit b6b767a2c47b26c1758520212b4f09ddb934c9f3
Author: Stefan Metzmacher <metze at samba.org>
Date:   Wed Sep 7 18:55:02 2011 +0200

    s3:smb2cli: only use tevent_req_defer_callback() if we have more than one smb2 response
    
    metze

commit 46f64aafcbb66adfe42d7f4b26709878acfd3648
Author: Stefan Metzmacher <metze at samba.org>
Date:   Sat Sep 17 21:17:18 2011 +0200

    s3:smb2cli: ignore async interim responses and store the async_id
    
    metze

commit eb46c7bff380b77b9f59c32a4918ad5b6c326dce
Author: Stefan Metzmacher <metze at samba.org>
Date:   Sat Sep 17 21:15:45 2011 +0200

    s3:smb2cli: check the response has the SMB2_HDR_FLAG_REDIRECT flag
    
    metze

commit 820915775886a7cfbac1f0c65cbf151d01d82146
Author: Stefan Metzmacher <metze at samba.org>
Date:   Sat Sep 17 21:13:58 2011 +0200

    s3:smb2cli: validate the opcode from the server is as expected
    
    metze

commit 270e88f4ff72ce1bd8dcd5e653df43d516951837
Author: Stefan Metzmacher <metze at samba.org>
Date:   Sat Sep 17 21:11:23 2011 +0200

    s3:smb2cli: initialize status if we got an unexpected response
    
    metze

commit 2bb17dc23ebbd0b89d39d6d827ed073b8bf2c65d
Author: Stefan Metzmacher <metze at samba.org>
Date:   Sat Sep 17 21:09:30 2011 +0200

    s3:libsmb: return INTERNAL_ERROR if the request is in bad state when the caller ships it
    
    metze

commit bbe78ca5a217eeba69a1e9189d8922c637d124f7
Author: Stefan Metzmacher <metze at samba.org>
Date:   Sat Sep 17 19:49:01 2011 +0200

    s3:libsmb: return if tevent_req_set_endtime() fails
    
    tevent_req_set_endtime() already calls tevent_req_nomem().
    
    metze

commit 79043f84d1916196fc163d4cacd10235301a3283
Author: Stefan Metzmacher <metze at samba.org>
Date:   Sat Sep 17 19:29:51 2011 +0200

    s3:SMB2-BASIC: test smb2cli_flush()
    
    metze

commit a0dcbf8d628ac19861648f914f576c1addce7b79
Author: Stefan Metzmacher <metze at samba.org>
Date:   Sat Sep 17 19:30:36 2011 +0200

    s3:smb2cli: SMB2_FLUSH responses have a body size of 4
    
    metze

-----------------------------------------------------------------------

Summary of changes:
 source3/libsmb/async_smb.c               |   14 +++-
 source3/libsmb/smb2cli_base.c            |  114 +++++++++++++++++++++++++++--
 source3/libsmb/smb2cli_base.h            |   12 +++-
 source3/libsmb/smb2cli_close.c           |   10 +++-
 source3/libsmb/smb2cli_create.c          |   10 +++-
 source3/libsmb/smb2cli_flush.c           |   10 +++-
 source3/libsmb/smb2cli_negprot.c         |   10 +++-
 source3/libsmb/smb2cli_query_directory.c |   10 +++-
 source3/libsmb/smb2cli_read.c            |   14 ++++-
 source3/libsmb/smb2cli_session.c         |   26 ++++++-
 source3/libsmb/smb2cli_tcon.c            |   20 +++++-
 source3/libsmb/smb2cli_write.c           |   10 +++-
 source3/torture/test_smb2.c              |    6 ++
 13 files changed, 243 insertions(+), 23 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/libsmb/async_smb.c b/source3/libsmb/async_smb.c
index 8966794..efeb328 100644
--- a/source3/libsmb/async_smb.c
+++ b/source3/libsmb/async_smb.c
@@ -420,7 +420,7 @@ struct tevent_req *cli_smb_req_create(TALLOC_CTX *mem_ctx,
 	if (cli->timeout) {
 		endtime = timeval_current_ofs_msec(cli->timeout);
 		if (!tevent_req_set_endtime(result, ev, endtime)) {
-			tevent_req_oom(result);
+			return result;
 		}
 	}
 
@@ -539,6 +539,10 @@ NTSTATUS cli_smb_req_send(struct tevent_req *req)
 	struct cli_smb_state *state = tevent_req_data(
 		req, struct cli_smb_state);
 
+	if (!tevent_req_is_in_progress(req)) {
+		return NT_STATUS_INTERNAL_ERROR;
+	}
+
 	return cli_smb_req_iov_send(req, state, state->iov, state->iov_count);
 }
 
@@ -563,7 +567,9 @@ struct tevent_req *cli_smb_send(TALLOC_CTX *mem_ctx,
 	if (req == NULL) {
 		return NULL;
 	}
-
+	if (!tevent_req_is_in_progress(req)) {
+		return tevent_req_post(req, ev);
+	}
 	status = cli_smb_req_send(req);
 	if (!NT_STATUS_IS_OK(status)) {
 		tevent_req_nterror(req, status);
@@ -991,6 +997,10 @@ NTSTATUS cli_smb_chain_send(struct tevent_req **reqs, int num_reqs)
 
 	iovlen = 0;
 	for (i=0; i<num_reqs; i++) {
+		if (!tevent_req_is_in_progress(reqs[i])) {
+			return NT_STATUS_INTERNAL_ERROR;
+		}
+
 		state = tevent_req_data(reqs[i], struct cli_smb_state);
 		iovlen += state->iov_count;
 	}
diff --git a/source3/libsmb/smb2cli_base.c b/source3/libsmb/smb2cli_base.c
index 5089aa9..f8b2f6e 100644
--- a/source3/libsmb/smb2cli_base.c
+++ b/source3/libsmb/smb2cli_base.c
@@ -178,6 +178,7 @@ struct tevent_req *smb2cli_req_create(TALLOC_CTX *mem_ctx,
 				      uint16_t cmd,
 				      uint32_t additional_flags,
 				      uint32_t clear_flags,
+				      unsigned int timeout,
 				      uint32_t pid,
 				      uint32_t tid,
 				      uint64_t uid,
@@ -223,6 +224,15 @@ struct tevent_req *smb2cli_req_create(TALLOC_CTX *mem_ctx,
 	SIVAL(state->hdr, SMB2_HDR_TID,		tid);
 	SBVAL(state->hdr, SMB2_HDR_SESSION_ID,	uid);
 
+	if (timeout > 0) {
+		struct timeval endtime;
+
+		endtime = timeval_current_ofs_msec(timeout);
+		if (!tevent_req_set_endtime(req, ev, endtime)) {
+			return req;
+		}
+	}
+
 	return req;
 }
 
@@ -333,6 +343,7 @@ struct tevent_req *smb2cli_req_send(TALLOC_CTX *mem_ctx,
 				    uint16_t cmd,
 				    uint32_t additional_flags,
 				    uint32_t clear_flags,
+				    unsigned int timeout,
 				    uint32_t pid,
 				    uint32_t tid,
 				    uint64_t uid,
@@ -346,6 +357,7 @@ struct tevent_req *smb2cli_req_send(TALLOC_CTX *mem_ctx,
 
 	req = smb2cli_req_create(mem_ctx, ev, cli, cmd,
 				 additional_flags, clear_flags,
+				 timeout,
 				 pid, tid, uid,
 				 fixed, fixed_len, dyn, dyn_len);
 	if (req == NULL) {
@@ -515,6 +527,7 @@ static void smb2cli_inbuf_received(struct tevent_req *subreq)
 	ssize_t received;
 	int err;
 	size_t num_pending;
+	bool defer = true;
 
 	received = read_smb_recv(subreq, frame, &inbuf, &err);
 	TALLOC_FREE(subreq);
@@ -547,9 +560,12 @@ static void smb2cli_inbuf_received(struct tevent_req *subreq)
 		uint8_t *inbuf_ref = NULL;
 		struct iovec *cur = &iov[i];
 		uint8_t *inhdr = (uint8_t *)cur[0].iov_base;
+		uint16_t opcode = SVAL(inhdr, SMB2_HDR_OPCODE);
+		uint32_t flags = IVAL(inhdr, SMB2_HDR_FLAGS);
+		uint64_t mid = BVAL(inhdr, SMB2_HDR_MESSAGE_ID);
+		uint16_t req_opcode;
 
-		req = cli_smb2_find_pending(
-			cli, BVAL(inhdr, SMB2_HDR_MESSAGE_ID));
+		req = cli_smb2_find_pending(cli, mid);
 		if (req == NULL) {
 			/*
 			 * TODO: handle oplock breaks and async responses
@@ -559,18 +575,53 @@ static void smb2cli_inbuf_received(struct tevent_req *subreq)
 			 * We need to close the connection and notify
 			 * all pending requests.
 			 */
+			status = NT_STATUS_INVALID_NETWORK_RESPONSE;
 			smb2cli_notify_pending(cli, status);
 			TALLOC_FREE(frame);
 			return;
 		}
-		smb2cli_req_unset_pending(req);
 		state = tevent_req_data(req, struct smb2cli_req_state);
 
+		req_opcode = SVAL(state->hdr, SMB2_HDR_OPCODE);
+		if (opcode != req_opcode) {
+			status = NT_STATUS_INVALID_NETWORK_RESPONSE;
+			smb2cli_notify_pending(cli, status);
+			TALLOC_FREE(frame);
+			return;
+		}
+
+		if (!(flags & SMB2_HDR_FLAG_REDIRECT)) {
+			status = NT_STATUS_INVALID_NETWORK_RESPONSE;
+			smb2cli_notify_pending(cli, status);
+			TALLOC_FREE(frame);
+			return;
+		}
+
+		status = NT_STATUS(IVAL(inhdr, SMB2_HDR_STATUS));
+		if ((flags & SMB2_HDR_FLAG_ASYNC) &&
+		    NT_STATUS_EQUAL(status, STATUS_PENDING)) {
+			uint32_t req_flags = IVAL(state->hdr, SMB2_HDR_FLAGS);
+			uint64_t async_id = BVAL(inhdr, SMB2_HDR_ASYNC_ID);
+
+			req_flags |= SMB2_HDR_FLAG_ASYNC;
+			SBVAL(state->hdr, SMB2_HDR_FLAGS, req_flags);
+			SBVAL(state->hdr, SMB2_HDR_ASYNC_ID, async_id);
+			continue;
+		}
+
+		smb2cli_req_unset_pending(req);
+
 		/*
 		 * There might be more than one response
 		 * we need to defer the notifications
 		 */
-		tevent_req_defer_callback(req, state->ev);
+		if ((num_iov == 4) && (talloc_array_length(cli->conn.pending) == 0)) {
+			defer = false;
+		}
+
+		if (defer) {
+			tevent_req_defer_callback(req, state->ev);
+		}
 
 		/*
 		 * Note: here we use talloc_reference() in a way
@@ -591,6 +642,10 @@ static void smb2cli_inbuf_received(struct tevent_req *subreq)
 
 	TALLOC_FREE(frame);
 
+	if (!defer) {
+		return;
+	}
+
 	num_pending = talloc_array_length(cli->conn.pending);
 	if (num_pending == 0) {
 		if (state->cli->smb2.mid < UINT64_MAX) {
@@ -622,24 +677,67 @@ static void smb2cli_inbuf_received(struct tevent_req *subreq)
 }
 
 NTSTATUS smb2cli_req_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
-			  struct iovec **piov, int body_size)
+			  struct iovec **piov,
+			  const struct smb2cli_req_expected_response *expected,
+			  size_t num_expected)
 {
 	struct smb2cli_req_state *state =
 		tevent_req_data(req,
 		struct smb2cli_req_state);
 	NTSTATUS status;
+	size_t body_size;
+	bool found_status = false;
+	bool found_size = false;
+	size_t i;
+
+	if (num_expected == 0) {
+		found_status = true;
+		found_size = true;
+	}
 
 	if (tevent_req_is_nterror(req, &status)) {
+		for (i=0; i < num_expected; i++) {
+			if (NT_STATUS_EQUAL(status, expected[i].status)) {
+				found_status = true;
+				break;
+			}
+		}
+
+		if (found_status) {
+			return NT_STATUS_UNEXPECTED_NETWORK_ERROR;
+		}
+
 		return status;
 	}
 
 	status = NT_STATUS(IVAL(state->recv_iov[0].iov_base, SMB2_HDR_STATUS));
+	body_size = SVAL(state->recv_iov[1].iov_base, 0);
+
+	for (i=0; i < num_expected; i++) {
+		if (!NT_STATUS_EQUAL(status, expected[i].status)) {
+			continue;
+		}
+
+		found_status = true;
+		if (expected[i].body_size == 0) {
+			found_size = true;
+			break;
+		}
 
-	if (body_size != 0) {
-		if (body_size != SVAL(state->recv_iov[1].iov_base, 0)) {
-			return NT_STATUS_INVALID_NETWORK_RESPONSE;
+		if (expected[i].body_size == body_size) {
+			found_size = true;
+			break;
 		}
 	}
+
+	if (!found_status) {
+		return status;
+	}
+
+	if (!found_size) {
+		return NT_STATUS_INVALID_NETWORK_RESPONSE;
+	}
+
 	if (piov != NULL) {
 		*piov = talloc_move(mem_ctx, &state->recv_iov);
 	}
diff --git a/source3/libsmb/smb2cli_base.h b/source3/libsmb/smb2cli_base.h
index 348f842..105f8eb 100644
--- a/source3/libsmb/smb2cli_base.h
+++ b/source3/libsmb/smb2cli_base.h
@@ -26,6 +26,7 @@ struct tevent_req *smb2cli_req_create(TALLOC_CTX *mem_ctx,
 				      uint16_t cmd,
 				      uint32_t additional_flags,
 				      uint32_t clear_flags,
+				      unsigned int timeout,
 				      uint32_t pid,
 				      uint32_t tid,
 				      uint64_t uid,
@@ -35,12 +36,19 @@ struct tevent_req *smb2cli_req_create(TALLOC_CTX *mem_ctx,
 				      uint32_t dyn_len);
 NTSTATUS smb2cli_req_compound_submit(struct tevent_req **reqs,
 				     int num_reqs);
+
+struct smb2cli_req_expected_response {
+	NTSTATUS status;
+	uint16_t body_size;
+};
+
 struct tevent_req *smb2cli_req_send(TALLOC_CTX *mem_ctx,
 				    struct tevent_context *ev,
 				    struct cli_state *cli,
 				    uint16_t cmd,
 				    uint32_t additional_flags,
 				    uint32_t clear_flags,
+				    unsigned int timeout,
 				    uint32_t pid,
 				    uint32_t tid,
 				    uint64_t uid,
@@ -49,6 +57,8 @@ struct tevent_req *smb2cli_req_send(TALLOC_CTX *mem_ctx,
 				    const uint8_t *dyn,
 				    uint32_t dyn_len);
 NTSTATUS smb2cli_req_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
-			  struct iovec **piov, int body_size);
+			  struct iovec **piov,
+			  const struct smb2cli_req_expected_response *expected,
+			  size_t num_expected);
 
 #endif
diff --git a/source3/libsmb/smb2cli_close.c b/source3/libsmb/smb2cli_close.c
index 3c6ad9f..ccd96ea 100644
--- a/source3/libsmb/smb2cli_close.c
+++ b/source3/libsmb/smb2cli_close.c
@@ -55,6 +55,7 @@ struct tevent_req *smb2cli_close_send(TALLOC_CTX *mem_ctx,
 
 	subreq = smb2cli_req_send(state, ev, cli, SMB2_OP_CLOSE,
 				  0, 0, /* flags */
+				  cli->timeout,
 				  cli->smb2.pid,
 				  cli->smb2.tid,
 				  cli->smb2.uid,
@@ -74,8 +75,15 @@ static void smb2cli_close_done(struct tevent_req *subreq)
 		struct tevent_req);
 	NTSTATUS status;
 	struct iovec *iov;
+	static const struct smb2cli_req_expected_response expected[] = {
+	{
+		.status = NT_STATUS_OK,
+		.body_size = 0x3C
+	}
+	};
 
-	status = smb2cli_req_recv(subreq, talloc_tos(), &iov, 60);
+	status = smb2cli_req_recv(subreq, talloc_tos(), &iov,
+				  expected, ARRAY_SIZE(expected));
 	if (tevent_req_nterror(req, status)) {
 		return;
 	}
diff --git a/source3/libsmb/smb2cli_create.c b/source3/libsmb/smb2cli_create.c
index 2145ce2..a0df7da 100644
--- a/source3/libsmb/smb2cli_create.c
+++ b/source3/libsmb/smb2cli_create.c
@@ -138,6 +138,7 @@ struct tevent_req *smb2cli_create_send(
 
 	subreq = smb2cli_req_send(state, ev, cli, SMB2_OP_CREATE,
 				  0, 0, /* flags */
+				  cli->timeout,
 				  cli->smb2.pid,
 				  cli->smb2.tid,
 				  cli->smb2.uid,
@@ -162,8 +163,15 @@ static void smb2cli_create_done(struct tevent_req *subreq)
 	struct iovec *iov;
 	uint8_t *body;
 	uint32_t offset, length;
+	static const struct smb2cli_req_expected_response expected[] = {
+	{
+		.status = NT_STATUS_OK,
+		.body_size = 0x59
+	}
+	};
 
-	status = smb2cli_req_recv(subreq, talloc_tos(), &iov, 89);
+	status = smb2cli_req_recv(subreq, talloc_tos(), &iov,
+				  expected, ARRAY_SIZE(expected));
 	if (tevent_req_nterror(req, status)) {
 		return;
 	}
diff --git a/source3/libsmb/smb2cli_flush.c b/source3/libsmb/smb2cli_flush.c
index 6fe7178..ea15f25 100644
--- a/source3/libsmb/smb2cli_flush.c
+++ b/source3/libsmb/smb2cli_flush.c
@@ -53,6 +53,7 @@ struct tevent_req *smb2cli_flush_send(TALLOC_CTX *mem_ctx,
 
 	subreq = smb2cli_req_send(state, ev, cli, SMB2_OP_FLUSH,
 				  0, 0, /* flags */
+				  cli->timeout,
 				  cli->smb2.pid,
 				  cli->smb2.tid,
 				  cli->smb2.uid,
@@ -72,8 +73,15 @@ static void smb2cli_flush_done(struct tevent_req *subreq)
 		struct tevent_req);
 	NTSTATUS status;
 	struct iovec *iov;
+	static const struct smb2cli_req_expected_response expected[] = {
+	{
+		.status = NT_STATUS_OK,
+		.body_size = 0x04
+	}
+	};
 
-	status = smb2cli_req_recv(subreq, talloc_tos(), &iov, 60);
+	status = smb2cli_req_recv(subreq, talloc_tos(), &iov,
+				  expected, ARRAY_SIZE(expected));
 	if (tevent_req_nterror(req, status)) {
 		return;
 	}
diff --git a/source3/libsmb/smb2cli_negprot.c b/source3/libsmb/smb2cli_negprot.c
index df35225..dec6c4c 100644
--- a/source3/libsmb/smb2cli_negprot.c
+++ b/source3/libsmb/smb2cli_negprot.c
@@ -68,6 +68,7 @@ struct tevent_req *smb2cli_negprot_send(TALLOC_CTX *mem_ctx,
 
 	subreq = smb2cli_req_send(state, ev, cli, SMB2_OP_NEGPROT,
 				  0, 0, /* flags */
+				  cli->timeout,
 				  cli->smb2.pid,
 				  0, 0, /* tid, uid */
 				  state->fixed, sizeof(state->fixed),
@@ -93,8 +94,15 @@ static void smb2cli_negprot_done(struct tevent_req *subreq)
 	NTSTATUS status;
 	struct iovec *iov;
 	uint8_t *body;
+	static const struct smb2cli_req_expected_response expected[] = {
+	{
+		.status = NT_STATUS_OK,
+		.body_size = 0x41
+	}
+	};
 
-	status = smb2cli_req_recv(subreq, talloc_tos(), &iov, 65);
+	status = smb2cli_req_recv(subreq, talloc_tos(), &iov,
+				  expected, ARRAY_SIZE(expected));
 	if (!NT_STATUS_IS_OK(status)) {
 		TALLOC_FREE(subreq);
 		tevent_req_nterror(req, status);
diff --git a/source3/libsmb/smb2cli_query_directory.c b/source3/libsmb/smb2cli_query_directory.c
index 4a0e69b..2d2c465 100644
--- a/source3/libsmb/smb2cli_query_directory.c
+++ b/source3/libsmb/smb2cli_query_directory.c
@@ -88,6 +88,7 @@ struct tevent_req *smb2cli_query_directory_send(TALLOC_CTX *mem_ctx,
 
 	subreq = smb2cli_req_send(state, ev, cli, SMB2_OP_FIND,
 				  0, 0, /* flags */
+				  cli->timeout,
 				  cli->smb2.pid,
 				  cli->smb2.tid,
 				  cli->smb2.uid,
@@ -111,8 +112,15 @@ static void smb2cli_query_directory_done(struct tevent_req *subreq)
 	NTSTATUS status;
 	struct iovec *iov;
 	uint16_t data_offset;
+	static const struct smb2cli_req_expected_response expected[] = {
+	{
+		.status = NT_STATUS_OK,
+		.body_size = 0x09
+	}
+	};
 
-	status = smb2cli_req_recv(subreq, state, &iov, 9);
+	status = smb2cli_req_recv(subreq, state, &iov,
+				  expected, ARRAY_SIZE(expected));
 	if (tevent_req_nterror(req, status)) {
 		return;
 	}
diff --git a/source3/libsmb/smb2cli_read.c b/source3/libsmb/smb2cli_read.c
index e45a75f..75754fe 100644
--- a/source3/libsmb/smb2cli_read.c
+++ b/source3/libsmb/smb2cli_read.c
@@ -67,6 +67,7 @@ struct tevent_req *smb2cli_read_send(TALLOC_CTX *mem_ctx,
 
 	subreq = smb2cli_req_send(state, ev, cli, SMB2_OP_READ,
 				  0, 0, /* flags */
+				  cli->timeout,
 				  cli->smb2.pid,
 				  cli->smb2.tid,
 				  cli->smb2.uid,
@@ -89,8 +90,19 @@ static void smb2cli_read_done(struct tevent_req *subreq)
 	NTSTATUS status;
 	struct iovec *iov;
 	uint8_t data_offset;
+	static const struct smb2cli_req_expected_response expected[] = {
+	{
+		.status = STATUS_BUFFER_OVERFLOW,
+		.body_size = 0x11
+	},
+	{
+		.status = NT_STATUS_OK,
+		.body_size = 0x11
+	}
+	};
 
-	status = smb2cli_req_recv(subreq, state, &iov, 17);
+	status = smb2cli_req_recv(subreq, state, &iov,
+				  expected, ARRAY_SIZE(expected));
 	if (tevent_req_nterror(req, status)) {
 		return;
 	}
diff --git a/source3/libsmb/smb2cli_session.c b/source3/libsmb/smb2cli_session.c
index 4ffdf13..28b8f91 100644
--- a/source3/libsmb/smb2cli_session.c
+++ b/source3/libsmb/smb2cli_session.c
@@ -75,6 +75,7 @@ static struct tevent_req *smb2cli_sesssetup_blob_send(TALLOC_CTX *mem_ctx,
 
 	subreq = smb2cli_req_send(state, ev, cli, SMB2_OP_SESSSETUP,
 				  0, 0, /* flags */
+				  cli->timeout,
 				  cli->smb2.pid,
 				  0, /* tid */
 				  cli->smb2.uid,
@@ -98,8 +99,19 @@ static void smb2cli_sesssetup_blob_done(struct tevent_req *subreq)
 	NTSTATUS status;
 	struct iovec *iov;
 	uint16_t offset, length;
-
-	status = smb2cli_req_recv(subreq, talloc_tos(), &iov, 9);
+	static const struct smb2cli_req_expected_response expected[] = {
+	{
+		.status = NT_STATUS_MORE_PROCESSING_REQUIRED,
+		.body_size = 0x09
+	},
+	{
+		.status = NT_STATUS_OK,
+		.body_size = 0x09
+	}
+	};


-- 
Samba Shared Repository


More information about the samba-cvs mailing list