smbXcli: rebuild smb1.recv_iov array if we expect more than one response
authorStefan Metzmacher <metze@samba.org>
Mon, 28 Nov 2011 16:48:44 +0000 (17:48 +0100)
committerStefan Metzmacher <metze@samba.org>
Tue, 29 Nov 2011 15:00:07 +0000 (16:00 +0100)
metze

libcli/smb/smbXcli_base.c

index b8be9c143fb2add0ef14df4188d098d2a3ca37e9..e49a989095973049f57174290e87902b0dae28f5 100644 (file)
@@ -1677,6 +1677,20 @@ static NTSTATUS smb1cli_conn_dispatch_incoming(struct smbXcli_conn *conn,
 
                smbXcli_req_unset_pending(req);
 
+               if (state->smb1.recv_iov == NULL) {
+                       /*
+                        * For requests with more than
+                        * one response, we have to readd the
+                        * recv_iov array.
+                        */
+                       state->smb1.recv_iov = talloc_zero_array(state,
+                                                                struct iovec,
+                                                                3);
+                       if (tevent_req_nomem(state->smb1.recv_iov, req)) {
+                               return NT_STATUS_OK;
+                       }
+               }
+
                state->smb1.recv_cmd = cmd;
                state->smb1.recv_status = status;
                state->inbuf = talloc_move(state->smb1.recv_iov, &inbuf);
@@ -1725,6 +1739,20 @@ static NTSTATUS smb1cli_conn_dispatch_incoming(struct smbXcli_conn *conn,
                        continue;
                }
 
+               if (state->smb1.recv_iov == NULL) {
+                       /*
+                        * For requests with more than
+                        * one response, we have to readd the
+                        * recv_iov array.
+                        */
+                       state->smb1.recv_iov = talloc_zero_array(state,
+                                                                struct iovec,
+                                                                3);
+                       if (tevent_req_nomem(state->smb1.recv_iov, req)) {
+                               continue;
+                       }
+               }
+
                state->smb1.recv_cmd = cmd;
 
                if (i == (num_responses - 1)) {
@@ -1819,6 +1847,7 @@ NTSTATUS smb1cli_req_recv(struct tevent_req *req,
 
        if (state->inbuf != NULL) {
                recv_iov = state->smb1.recv_iov;
+               state->smb1.recv_iov = NULL;
                hdr = (uint8_t *)recv_iov[0].iov_base;
                wct = recv_iov[1].iov_len/2;
                vwv = (uint16_t *)recv_iov[1].iov_base;