2 Unix SMB/CIFS implementation.
3 Inter-process communication and named pipe handling
4 Copyright (C) Andrew Tridgell 1992-1998
7 Copyright (C) John H Terpstra 1995-1998
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>.
23 This file handles the named pipe and mailslot calls
24 in the SMBtrans protocol
28 #include "smbd/smbd.h"
29 #include "smbd/globals.h"
30 #include "smbprofile.h"
31 #include "rpc_server/srv_pipe_hnd.h"
33 #define NERR_notsupported 50
35 static void api_no_reply(connection_struct *conn, struct smb_request *req);
37 /*******************************************************************
38 copies parameters and data, as needed, into the smb buffer
40 *both* the data and params sections should be aligned. this
41 is fudged in the rpc pipes by
42 at present, only the data section is. this may be a possible
43 cause of some of the ipc problems being experienced. lkcl26dec97
45 ******************************************************************/
47 static void copy_trans_params_and_data(char *outbuf, int align,
48 char *rparam, int param_offset, int param_len,
49 char *rdata, int data_offset, int data_len)
51 char *copy_into = smb_buf(outbuf);
59 DEBUG(5,("copy_trans_params_and_data: params[%d..%d] data[%d..%d] (align %d)\n",
60 param_offset, param_offset + param_len,
61 data_offset , data_offset + data_len,
69 memcpy(copy_into, &rparam[param_offset], param_len);
71 copy_into += param_len;
73 memset(copy_into, '\0', align);
79 memcpy(copy_into, &rdata[data_offset], data_len);
82 NTSTATUS nt_status_np_pipe(NTSTATUS status)
84 if (NT_STATUS_EQUAL(status, NT_STATUS_CONNECTION_DISCONNECTED)) {
85 status = NT_STATUS_PIPE_DISCONNECTED;
86 } else if (NT_STATUS_EQUAL(status, NT_STATUS_CONNECTION_RESET)) {
87 status = NT_STATUS_PIPE_BROKEN;
93 /****************************************************************************
95 ****************************************************************************/
97 void send_trans_reply(connection_struct *conn,
98 struct smb_request *req,
99 char *rparam, int rparam_len,
100 char *rdata, int rdata_len,
101 bool buffer_too_large)
103 int this_ldata,this_lparam;
104 int tot_data_sent = 0;
105 int tot_param_sent = 0;
108 int ldata = rdata ? rdata_len : 0;
109 int lparam = rparam ? rparam_len : 0;
110 struct smbd_server_connection *sconn = req->sconn;
111 int max_send = sconn->smb1.sessions.max_send;
113 if (buffer_too_large)
114 DEBUG(5,("send_trans_reply: buffer %d too large\n", ldata ));
116 this_lparam = MIN(lparam,max_send - 500); /* hack */
117 this_ldata = MIN(ldata,max_send - (500+this_lparam));
119 align = ((this_lparam)%4);
121 reply_outbuf(req, 10, 1+align+this_ldata+this_lparam);
124 * We might have SMBtranss in req which was transferred to the outbuf,
127 SCVAL(req->outbuf, smb_com, SMBtrans);
129 copy_trans_params_and_data((char *)req->outbuf, align,
130 rparam, tot_param_sent, this_lparam,
131 rdata, tot_data_sent, this_ldata);
133 SSVAL(req->outbuf,smb_vwv0,lparam);
134 SSVAL(req->outbuf,smb_vwv1,ldata);
135 SSVAL(req->outbuf,smb_vwv3,this_lparam);
136 SSVAL(req->outbuf,smb_vwv4,
137 smb_offset(smb_buf(req->outbuf)+1, req->outbuf));
138 SSVAL(req->outbuf,smb_vwv5,0);
139 SSVAL(req->outbuf,smb_vwv6,this_ldata);
140 SSVAL(req->outbuf,smb_vwv7,
141 smb_offset(smb_buf(req->outbuf)+1+this_lparam+align,
143 SSVAL(req->outbuf,smb_vwv8,0);
144 SSVAL(req->outbuf,smb_vwv9,0);
146 if (buffer_too_large) {
147 error_packet_set((char *)req->outbuf, ERRDOS, ERRmoredata,
148 STATUS_BUFFER_OVERFLOW, __LINE__, __FILE__);
151 show_msg((char *)req->outbuf);
152 if (!srv_send_smb(sconn, (char *)req->outbuf,
154 IS_CONN_ENCRYPTED(conn), &req->pcd)) {
155 exit_server_cleanly("send_trans_reply: srv_send_smb failed.");
158 TALLOC_FREE(req->outbuf);
160 tot_data_sent = this_ldata;
161 tot_param_sent = this_lparam;
163 while (tot_data_sent < ldata || tot_param_sent < lparam)
165 this_lparam = MIN(lparam-tot_param_sent,
166 max_send - 500); /* hack */
167 this_ldata = MIN(ldata -tot_data_sent,
168 max_send - (500+this_lparam));
176 align = (this_lparam%4);
178 reply_outbuf(req, 10, 1+align+this_ldata+this_lparam);
181 * We might have SMBtranss in req which was transferred to the
184 SCVAL(req->outbuf, smb_com, SMBtrans);
186 copy_trans_params_and_data((char *)req->outbuf, align,
187 rparam, tot_param_sent, this_lparam,
188 rdata, tot_data_sent, this_ldata);
190 SSVAL(req->outbuf,smb_vwv0,lparam);
191 SSVAL(req->outbuf,smb_vwv1,ldata);
193 SSVAL(req->outbuf,smb_vwv3,this_lparam);
194 SSVAL(req->outbuf,smb_vwv4,
195 smb_offset(smb_buf(req->outbuf)+1,req->outbuf));
196 SSVAL(req->outbuf,smb_vwv5,tot_param_sent);
197 SSVAL(req->outbuf,smb_vwv6,this_ldata);
198 SSVAL(req->outbuf,smb_vwv7,
199 smb_offset(smb_buf(req->outbuf)+1+this_lparam+align,
201 SSVAL(req->outbuf,smb_vwv8,tot_data_sent);
202 SSVAL(req->outbuf,smb_vwv9,0);
204 if (buffer_too_large) {
205 error_packet_set((char *)req->outbuf,
207 STATUS_BUFFER_OVERFLOW,
211 show_msg((char *)req->outbuf);
212 if (!srv_send_smb(sconn, (char *)req->outbuf,
214 IS_CONN_ENCRYPTED(conn), &req->pcd))
215 exit_server_cleanly("send_trans_reply: srv_send_smb "
218 tot_data_sent += this_ldata;
219 tot_param_sent += this_lparam;
220 TALLOC_FREE(req->outbuf);
224 /****************************************************************************
225 Start the first part of an RPC reply which began with an SMBtrans request.
226 ****************************************************************************/
228 struct dcerpc_cmd_state {
229 struct fake_file_handle *handle;
235 static void api_dcerpc_cmd_write_done(struct tevent_req *subreq);
236 static void api_dcerpc_cmd_read_done(struct tevent_req *subreq);
238 static void api_dcerpc_cmd(connection_struct *conn, struct smb_request *req,
239 files_struct *fsp, uint8_t *data, size_t length,
242 struct tevent_req *subreq;
243 struct dcerpc_cmd_state *state;
246 if (!fsp_is_np(fsp)) {
247 api_no_reply(conn, req);
252 * Trans requests are only allowed
253 * if no other Trans or Read is active
255 busy = np_read_in_progress(fsp->fake_file_handle);
257 reply_nterror(req, NT_STATUS_PIPE_BUSY);
261 state = talloc(req, struct dcerpc_cmd_state);
263 reply_nterror(req, NT_STATUS_NO_MEMORY);
266 req->async_priv = state;
268 state->handle = fsp->fake_file_handle;
271 * This memdup severely sucks. But doing it properly essentially means
272 * to rewrite lanman.c, something which I don't really want to do now.
274 state->data = (uint8_t *)talloc_memdup(state, data, length);
275 if (state->data == NULL) {
276 reply_nterror(req, NT_STATUS_NO_MEMORY);
279 state->num_data = length;
280 state->max_read = max_read;
282 subreq = np_write_send(state, req->sconn->ev_ctx, state->handle,
283 state->data, length);
284 if (subreq == NULL) {
286 reply_nterror(req, NT_STATUS_NO_MEMORY);
289 tevent_req_set_callback(subreq, api_dcerpc_cmd_write_done,
290 talloc_move(conn, &req));
293 static void api_dcerpc_cmd_write_done(struct tevent_req *subreq)
295 struct smb_request *req = tevent_req_callback_data(
296 subreq, struct smb_request);
297 struct dcerpc_cmd_state *state = talloc_get_type_abort(
298 req->async_priv, struct dcerpc_cmd_state);
300 ssize_t nwritten = -1;
302 status = np_write_recv(subreq, &nwritten);
304 if (!NT_STATUS_IS_OK(status) || (nwritten != state->num_data)) {
305 DEBUG(10, ("Could not write to pipe: %s (%d/%d)\n",
306 nt_errstr(status), (int)state->num_data,
308 reply_nterror(req, NT_STATUS_PIPE_NOT_AVAILABLE);
312 state->data = talloc_realloc(state, state->data, uint8_t,
314 if (state->data == NULL) {
315 reply_nterror(req, NT_STATUS_NO_MEMORY);
319 subreq = np_read_send(state, req->sconn->ev_ctx,
320 state->handle, state->data, state->max_read);
321 if (subreq == NULL) {
322 reply_nterror(req, NT_STATUS_NO_MEMORY);
325 tevent_req_set_callback(subreq, api_dcerpc_cmd_read_done, req);
330 req->sconn, (char *)req->outbuf,
332 IS_CONN_ENCRYPTED(req->conn) || req->encrypted,
334 exit_server_cleanly("api_dcerpc_cmd_write_done: "
335 "srv_send_smb failed.");
340 static void api_dcerpc_cmd_read_done(struct tevent_req *subreq)
342 struct smb_request *req = tevent_req_callback_data(
343 subreq, struct smb_request);
344 struct dcerpc_cmd_state *state = talloc_get_type_abort(
345 req->async_priv, struct dcerpc_cmd_state);
348 bool is_data_outstanding;
350 status = np_read_recv(subreq, &nread, &is_data_outstanding);
353 if (!NT_STATUS_IS_OK(status)) {
354 DEBUG(10, ("Could not read from to pipe: %s\n",
356 reply_nterror(req, status);
358 if (!srv_send_smb(req->sconn, (char *)req->outbuf,
360 IS_CONN_ENCRYPTED(req->conn)
361 ||req->encrypted, &req->pcd)) {
362 exit_server_cleanly("api_dcerpc_cmd_read_done: "
363 "srv_send_smb failed.");
369 send_trans_reply(req->conn, req, NULL, 0, (char *)state->data, nread,
370 is_data_outstanding);
374 /****************************************************************************
375 WaitNamedPipeHandleState
376 ****************************************************************************/
378 static void api_WNPHS(connection_struct *conn, struct smb_request *req,
379 struct files_struct *fsp, char *param, int param_len)
381 if (!param || param_len < 2) {
382 reply_nterror(req, NT_STATUS_INVALID_PARAMETER);
386 DEBUG(4,("WaitNamedPipeHandleState priority %x\n",
387 (int)SVAL(param,0)));
389 send_trans_reply(conn, req, NULL, 0, NULL, 0, False);
393 /****************************************************************************
394 SetNamedPipeHandleState
395 ****************************************************************************/
397 static void api_SNPHS(connection_struct *conn, struct smb_request *req,
398 struct files_struct *fsp, char *param, int param_len)
400 if (!param || param_len < 2) {
401 reply_nterror(req, NT_STATUS_INVALID_PARAMETER);
405 DEBUG(4,("SetNamedPipeHandleState to code %x\n", (int)SVAL(param,0)));
407 send_trans_reply(conn, req, NULL, 0, NULL, 0, False);
411 /****************************************************************************
412 When no reply is generated, indicate unsupported.
413 ****************************************************************************/
415 static void api_no_reply(connection_struct *conn, struct smb_request *req)
420 SSVAL(rparam,0,NERR_notsupported);
421 SSVAL(rparam,2,0); /* converter word */
423 DEBUG(3,("Unsupported API fd command\n"));
425 /* now send the reply */
426 send_trans_reply(conn, req, rparam, 4, NULL, 0, False);
431 /****************************************************************************
432 Handle remote api calls delivered to a named pipe already opened.
433 ****************************************************************************/
435 static void api_fd_reply(connection_struct *conn, uint16 vuid,
436 struct smb_request *req,
437 uint16 *setup, uint8_t *data, char *params,
438 int suwcnt, int tdscnt, int tpscnt,
439 int mdrcnt, int mprcnt)
441 struct files_struct *fsp;
445 DEBUG(5,("api_fd_reply\n"));
447 /* First find out the name of this file. */
449 DEBUG(0,("Unexpected named pipe transaction.\n"));
450 reply_nterror(req, NT_STATUS_INVALID_PARAMETER);
454 /* Get the file handle and hence the file name. */
456 * NB. The setup array has already been transformed
457 * via SVAL and so is in host byte order.
459 pnum = ((int)setup[1]) & 0xFFFF;
460 subcommand = ((int)setup[0]) & 0xFFFF;
462 fsp = file_fsp(req, pnum);
464 if (!fsp_is_np(fsp)) {
465 if (subcommand == TRANSACT_WAITNAMEDPIPEHANDLESTATE) {
466 /* Win9x does this call with a unicode pipe name, not a pnum. */
467 /* Just return success for now... */
468 DEBUG(3,("Got TRANSACT_WAITNAMEDPIPEHANDLESTATE on text pipe name\n"));
469 send_trans_reply(conn, req, NULL, 0, NULL, 0, False);
473 DEBUG(1,("api_fd_reply: INVALID PIPE HANDLE: %x\n", pnum));
474 reply_nterror(req, NT_STATUS_INVALID_HANDLE);
478 if (vuid != fsp->vuid) {
479 DEBUG(1, ("Got pipe request (pnum %x) using invalid VUID %d, "
480 "expected %d\n", pnum, vuid, fsp->vuid));
481 reply_nterror(req, NT_STATUS_INVALID_HANDLE);
485 DEBUG(3,("Got API command 0x%x on pipe \"%s\" (pnum %x)\n",
486 subcommand, fsp_str_dbg(fsp), pnum));
488 DEBUG(10, ("api_fd_reply: p:%p max_trans_reply: %d\n", fsp, mdrcnt));
490 switch (subcommand) {
491 case TRANSACT_DCERPCCMD: {
492 /* dce/rpc command */
493 api_dcerpc_cmd(conn, req, fsp, (uint8_t *)data, tdscnt,
497 case TRANSACT_WAITNAMEDPIPEHANDLESTATE:
498 /* Wait Named Pipe Handle state */
499 api_WNPHS(conn, req, fsp, params, tpscnt);
501 case TRANSACT_SETNAMEDPIPEHANDLESTATE:
502 /* Set Named Pipe Handle state */
503 api_SNPHS(conn, req, fsp, params, tpscnt);
506 reply_nterror(req, NT_STATUS_INVALID_PARAMETER);
511 /****************************************************************************
512 Handle named pipe commands.
513 ****************************************************************************/
515 static void named_pipe(connection_struct *conn, uint16 vuid,
516 struct smb_request *req,
517 const char *name, uint16 *setup,
518 char *data, char *params,
519 int suwcnt, int tdscnt,int tpscnt,
520 int msrcnt, int mdrcnt, int mprcnt)
522 DEBUG(3,("named pipe command on <%s> name\n", name));
524 if (strequal(name,"LANMAN")) {
525 api_reply(conn, vuid, req,
532 if (strequal(name,"WKSSVC") ||
533 strequal(name,"SRVSVC") ||
534 strequal(name,"WINREG") ||
535 strequal(name,"SAMR") ||
536 strequal(name,"LSARPC")) {
538 DEBUG(4,("named pipe command from Win95 (wow!)\n"));
540 api_fd_reply(conn, vuid, req,
541 setup, (uint8_t *)data, params,
542 suwcnt, tdscnt, tpscnt,
547 if (strlen(name) < 1) {
548 api_fd_reply(conn, vuid, req,
549 setup, (uint8_t *)data,
550 params, suwcnt, tdscnt,
551 tpscnt, mdrcnt, mprcnt);
556 DEBUG(3,("unknown named pipe: setup 0x%X setup1=%d\n",
557 (int)setup[0],(int)setup[1]));
559 reply_nterror(req, NT_STATUS_NOT_SUPPORTED);
563 static void handle_trans(connection_struct *conn, struct smb_request *req,
564 struct trans_state *state)
566 char *local_machine_name;
569 DEBUG(3,("trans <%s> data=%u params=%u setup=%u\n",
570 state->name,(unsigned int)state->total_data,(unsigned int)state->total_param,
571 (unsigned int)state->setup_count));
574 * WinCE wierdness....
577 local_machine_name = talloc_asprintf(state, "\\%s\\",
578 get_local_machine_name());
580 if (local_machine_name == NULL) {
581 reply_nterror(req, NT_STATUS_NO_MEMORY);
585 if (strnequal(state->name, local_machine_name,
586 strlen(local_machine_name))) {
587 name_offset = strlen(local_machine_name)-1;
590 if (!strnequal(&state->name[name_offset], "\\PIPE",
592 reply_nterror(req, NT_STATUS_NOT_SUPPORTED);
596 name_offset += strlen("\\PIPE");
598 /* Win9x weirdness. When talking to a unicode server Win9x
599 only sends \PIPE instead of \PIPE\ */
601 if (state->name[name_offset] == '\\')
604 DEBUG(5,("calling named_pipe\n"));
605 named_pipe(conn, state->vuid, req,
606 state->name+name_offset,
607 state->setup,state->data,
609 state->setup_count,state->total_data,
611 state->max_setup_return,
612 state->max_data_return,
613 state->max_param_return);
615 if (state->close_on_completion) {
616 close_cnum(conn,state->vuid);
623 /****************************************************************************
625 ****************************************************************************/
627 void reply_trans(struct smb_request *req)
629 connection_struct *conn = req->conn;
634 struct trans_state *state;
637 START_PROFILE(SMBtrans);
640 reply_nterror(req, NT_STATUS_INVALID_PARAMETER);
641 END_PROFILE(SMBtrans);
645 dsoff = SVAL(req->vwv+12, 0);
646 dscnt = SVAL(req->vwv+11, 0);
647 psoff = SVAL(req->vwv+10, 0);
648 pscnt = SVAL(req->vwv+9, 0);
650 result = allow_new_trans(conn->pending_trans, req->mid);
651 if (!NT_STATUS_IS_OK(result)) {
652 DEBUG(2, ("Got invalid trans request: %s\n",
654 reply_nterror(req, result);
655 END_PROFILE(SMBtrans);
659 if ((state = talloc(conn, struct trans_state)) == NULL) {
660 DEBUG(0, ("talloc failed\n"));
661 reply_nterror(req, NT_STATUS_NO_MEMORY);
662 END_PROFILE(SMBtrans);
666 state->cmd = SMBtrans;
668 state->mid = req->mid;
669 state->vuid = req->vuid;
670 state->setup_count = CVAL(req->vwv+13, 0);
672 state->total_param = SVAL(req->vwv+0, 0);
674 state->total_data = SVAL(req->vwv+1, 0);
676 state->max_param_return = SVAL(req->vwv+2, 0);
677 state->max_data_return = SVAL(req->vwv+3, 0);
678 state->max_setup_return = CVAL(req->vwv+4, 0);
679 state->close_on_completion = BITSETW(req->vwv+5, 0);
680 state->one_way = BITSETW(req->vwv+5, 1);
682 srvstr_pull_req_talloc(state, req, &state->name, req->buf,
685 if ((dscnt > state->total_data) || (pscnt > state->total_param) ||
689 if (state->total_data) {
691 if (trans_oob(state->total_data, 0, dscnt)
692 || trans_oob(smb_len(req->inbuf), dsoff, dscnt)) {
696 /* Can't use talloc here, the core routines do realloc on the
697 * params and data. Out of paranoia, 100 bytes too many. */
698 state->data = (char *)SMB_MALLOC(state->total_data+100);
699 if (state->data == NULL) {
700 DEBUG(0,("reply_trans: data malloc fail for %u "
701 "bytes !\n", (unsigned int)state->total_data));
703 reply_nterror(req, NT_STATUS_NO_MEMORY);
704 END_PROFILE(SMBtrans);
707 /* null-terminate the slack space */
708 memset(&state->data[state->total_data], 0, 100);
710 memcpy(state->data,smb_base(req->inbuf)+dsoff,dscnt);
713 if (state->total_param) {
715 if (trans_oob(state->total_param, 0, pscnt)
716 || trans_oob(smb_len(req->inbuf), psoff, pscnt)) {
720 /* Can't use talloc here, the core routines do realloc on the
721 * params and data. Out of paranoia, 100 bytes too many */
722 state->param = (char *)SMB_MALLOC(state->total_param+100);
723 if (state->param == NULL) {
724 DEBUG(0,("reply_trans: param malloc fail for %u "
725 "bytes !\n", (unsigned int)state->total_param));
726 SAFE_FREE(state->data);
728 reply_nterror(req, NT_STATUS_NO_MEMORY);
729 END_PROFILE(SMBtrans);
732 /* null-terminate the slack space */
733 memset(&state->param[state->total_param], 0, 100);
735 memcpy(state->param,smb_base(req->inbuf)+psoff,pscnt);
738 state->received_data = dscnt;
739 state->received_param = pscnt;
741 if (state->setup_count) {
745 * No overflow possible here, state->setup_count is an
746 * unsigned int, being filled by a single byte from
747 * CVAL(req->vwv+13, 0) above. The cast in the comparison
748 * below is not necessary, it's here to clarify things. The
749 * validity of req->vwv and req->wct has been checked in
750 * init_smb_request already.
752 if (state->setup_count + 14 > (unsigned int)req->wct) {
756 if((state->setup = talloc_array(
757 state, uint16, state->setup_count)) == NULL) {
758 DEBUG(0,("reply_trans: setup malloc fail for %u "
759 "bytes !\n", (unsigned int)
760 (state->setup_count * sizeof(uint16))));
761 SAFE_FREE(state->data);
762 SAFE_FREE(state->param);
764 reply_nterror(req, NT_STATUS_NO_MEMORY);
765 END_PROFILE(SMBtrans);
769 for (i=0;i<state->setup_count;i++) {
770 state->setup[i] = SVAL(req->vwv + 14 + i, 0);
774 state->received_param = pscnt;
776 if ((state->received_param != state->total_param) ||
777 (state->received_data != state->total_data)) {
778 DLIST_ADD(conn->pending_trans, state);
780 /* We need to send an interim response then receive the rest
781 of the parameter/data bytes */
782 reply_outbuf(req, 0, 0);
783 show_msg((char *)req->outbuf);
784 END_PROFILE(SMBtrans);
788 talloc_steal(talloc_tos(), state);
790 handle_trans(conn, req, state);
792 SAFE_FREE(state->data);
793 SAFE_FREE(state->param);
796 END_PROFILE(SMBtrans);
801 DEBUG(0,("reply_trans: invalid trans parameters\n"));
802 SAFE_FREE(state->data);
803 SAFE_FREE(state->param);
805 END_PROFILE(SMBtrans);
806 reply_nterror(req, NT_STATUS_INVALID_PARAMETER);
810 /****************************************************************************
811 Reply to a secondary SMBtrans.
812 ****************************************************************************/
814 void reply_transs(struct smb_request *req)
816 connection_struct *conn = req->conn;
817 unsigned int pcnt,poff,dcnt,doff,pdisp,ddisp;
818 struct trans_state *state;
820 START_PROFILE(SMBtranss);
822 show_msg((const char *)req->inbuf);
825 reply_nterror(req, NT_STATUS_INVALID_PARAMETER);
826 END_PROFILE(SMBtranss);
830 for (state = conn->pending_trans; state != NULL;
831 state = state->next) {
832 if (state->mid == req->mid) {
837 if ((state == NULL) || (state->cmd != SMBtrans)) {
838 reply_nterror(req, NT_STATUS_INVALID_PARAMETER);
839 END_PROFILE(SMBtranss);
843 /* Revise total_params and total_data in case they have changed
846 if (SVAL(req->vwv+0, 0) < state->total_param)
847 state->total_param = SVAL(req->vwv+0, 0);
848 if (SVAL(req->vwv+1, 0) < state->total_data)
849 state->total_data = SVAL(req->vwv+1, 0);
851 pcnt = SVAL(req->vwv+2, 0);
852 poff = SVAL(req->vwv+3, 0);
853 pdisp = SVAL(req->vwv+4, 0);
855 dcnt = SVAL(req->vwv+5, 0);
856 doff = SVAL(req->vwv+6, 0);
857 ddisp = SVAL(req->vwv+7, 0);
859 state->received_param += pcnt;
860 state->received_data += dcnt;
862 if ((state->received_data > state->total_data) ||
863 (state->received_param > state->total_param))
867 if (trans_oob(state->total_param, pdisp, pcnt)
868 || trans_oob(smb_len(req->inbuf), poff, pcnt)) {
871 memcpy(state->param+pdisp,smb_base(req->inbuf)+poff,pcnt);
875 if (trans_oob(state->total_data, ddisp, dcnt)
876 || trans_oob(smb_len(req->inbuf), doff, dcnt)) {
879 memcpy(state->data+ddisp, smb_base(req->inbuf)+doff,dcnt);
882 if ((state->received_param < state->total_param) ||
883 (state->received_data < state->total_data)) {
884 END_PROFILE(SMBtranss);
888 talloc_steal(talloc_tos(), state);
890 handle_trans(conn, req, state);
892 DLIST_REMOVE(conn->pending_trans, state);
893 SAFE_FREE(state->data);
894 SAFE_FREE(state->param);
897 END_PROFILE(SMBtranss);
902 DEBUG(0,("reply_transs: invalid trans parameters\n"));
903 DLIST_REMOVE(conn->pending_trans, state);
904 SAFE_FREE(state->data);
905 SAFE_FREE(state->param);
907 reply_nterror(req, NT_STATUS_INVALID_PARAMETER);
908 END_PROFILE(SMBtranss);