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"
31 #define NERR_notsupported 50
33 static void api_no_reply(connection_struct *conn, struct smb_request *req);
35 /*******************************************************************
36 copies parameters and data, as needed, into the smb buffer
38 *both* the data and params sections should be aligned. this
39 is fudged in the rpc pipes by
40 at present, only the data section is. this may be a possible
41 cause of some of the ipc problems being experienced. lkcl26dec97
43 ******************************************************************/
45 static void copy_trans_params_and_data(char *outbuf, int align,
46 char *rparam, int param_offset, int param_len,
47 char *rdata, int data_offset, int data_len)
49 char *copy_into = smb_buf(outbuf);
57 DEBUG(5,("copy_trans_params_and_data: params[%d..%d] data[%d..%d] (align %d)\n",
58 param_offset, param_offset + param_len,
59 data_offset , data_offset + data_len,
67 memcpy(copy_into, &rparam[param_offset], param_len);
69 copy_into += param_len;
71 memset(copy_into, '\0', align);
77 memcpy(copy_into, &rdata[data_offset], data_len);
80 /****************************************************************************
82 ****************************************************************************/
84 void send_trans_reply(connection_struct *conn,
85 struct smb_request *req,
86 char *rparam, int rparam_len,
87 char *rdata, int rdata_len,
88 bool buffer_too_large)
90 int this_ldata,this_lparam;
91 int tot_data_sent = 0;
92 int tot_param_sent = 0;
95 int ldata = rdata ? rdata_len : 0;
96 int lparam = rparam ? rparam_len : 0;
97 struct smbd_server_connection *sconn = req->sconn;
98 int max_send = sconn->smb1.sessions.max_send;
100 if (buffer_too_large)
101 DEBUG(5,("send_trans_reply: buffer %d too large\n", ldata ));
103 this_lparam = MIN(lparam,max_send - 500); /* hack */
104 this_ldata = MIN(ldata,max_send - (500+this_lparam));
106 align = ((this_lparam)%4);
108 reply_outbuf(req, 10, 1+align+this_ldata+this_lparam);
111 * We might have SMBtranss in req which was transferred to the outbuf,
114 SCVAL(req->outbuf, smb_com, SMBtrans);
116 copy_trans_params_and_data((char *)req->outbuf, align,
117 rparam, tot_param_sent, this_lparam,
118 rdata, tot_data_sent, this_ldata);
120 SSVAL(req->outbuf,smb_vwv0,lparam);
121 SSVAL(req->outbuf,smb_vwv1,ldata);
122 SSVAL(req->outbuf,smb_vwv3,this_lparam);
123 SSVAL(req->outbuf,smb_vwv4,
124 smb_offset(smb_buf(req->outbuf)+1, req->outbuf));
125 SSVAL(req->outbuf,smb_vwv5,0);
126 SSVAL(req->outbuf,smb_vwv6,this_ldata);
127 SSVAL(req->outbuf,smb_vwv7,
128 smb_offset(smb_buf(req->outbuf)+1+this_lparam+align,
130 SSVAL(req->outbuf,smb_vwv8,0);
131 SSVAL(req->outbuf,smb_vwv9,0);
133 if (buffer_too_large) {
134 error_packet_set((char *)req->outbuf, ERRDOS, ERRmoredata,
135 STATUS_BUFFER_OVERFLOW, __LINE__, __FILE__);
138 show_msg((char *)req->outbuf);
139 if (!srv_send_smb(sconn, (char *)req->outbuf,
141 IS_CONN_ENCRYPTED(conn), &req->pcd)) {
142 exit_server_cleanly("send_trans_reply: srv_send_smb failed.");
145 TALLOC_FREE(req->outbuf);
147 tot_data_sent = this_ldata;
148 tot_param_sent = this_lparam;
150 while (tot_data_sent < ldata || tot_param_sent < lparam)
152 this_lparam = MIN(lparam-tot_param_sent,
153 max_send - 500); /* hack */
154 this_ldata = MIN(ldata -tot_data_sent,
155 max_send - (500+this_lparam));
163 align = (this_lparam%4);
165 reply_outbuf(req, 10, 1+align+this_ldata+this_lparam);
168 * We might have SMBtranss in req which was transferred to the
171 SCVAL(req->outbuf, smb_com, SMBtrans);
173 copy_trans_params_and_data((char *)req->outbuf, align,
174 rparam, tot_param_sent, this_lparam,
175 rdata, tot_data_sent, this_ldata);
177 SSVAL(req->outbuf,smb_vwv0,lparam);
178 SSVAL(req->outbuf,smb_vwv1,ldata);
180 SSVAL(req->outbuf,smb_vwv3,this_lparam);
181 SSVAL(req->outbuf,smb_vwv4,
182 smb_offset(smb_buf(req->outbuf)+1,req->outbuf));
183 SSVAL(req->outbuf,smb_vwv5,tot_param_sent);
184 SSVAL(req->outbuf,smb_vwv6,this_ldata);
185 SSVAL(req->outbuf,smb_vwv7,
186 smb_offset(smb_buf(req->outbuf)+1+this_lparam+align,
188 SSVAL(req->outbuf,smb_vwv8,tot_data_sent);
189 SSVAL(req->outbuf,smb_vwv9,0);
191 if (buffer_too_large) {
192 error_packet_set((char *)req->outbuf,
194 STATUS_BUFFER_OVERFLOW,
198 show_msg((char *)req->outbuf);
199 if (!srv_send_smb(sconn, (char *)req->outbuf,
201 IS_CONN_ENCRYPTED(conn), &req->pcd))
202 exit_server_cleanly("send_trans_reply: srv_send_smb "
205 tot_data_sent += this_ldata;
206 tot_param_sent += this_lparam;
207 TALLOC_FREE(req->outbuf);
211 /****************************************************************************
212 Start the first part of an RPC reply which began with an SMBtrans request.
213 ****************************************************************************/
215 struct dcerpc_cmd_state {
216 struct fake_file_handle *handle;
222 static void api_dcerpc_cmd_write_done(struct tevent_req *subreq);
223 static void api_dcerpc_cmd_read_done(struct tevent_req *subreq);
225 static void api_dcerpc_cmd(connection_struct *conn, struct smb_request *req,
226 files_struct *fsp, uint8_t *data, size_t length,
229 struct tevent_req *subreq;
230 struct dcerpc_cmd_state *state;
233 if (!fsp_is_np(fsp)) {
234 api_no_reply(conn, req);
239 * Trans requests are only allowed
240 * if no other Trans or Read is active
242 busy = np_read_in_progress(fsp->fake_file_handle);
244 reply_nterror(req, NT_STATUS_PIPE_BUSY);
248 state = talloc(req, struct dcerpc_cmd_state);
250 reply_nterror(req, NT_STATUS_NO_MEMORY);
253 req->async_priv = state;
255 state->handle = fsp->fake_file_handle;
258 * This memdup severely sucks. But doing it properly essentially means
259 * to rewrite lanman.c, something which I don't really want to do now.
261 state->data = (uint8_t *)talloc_memdup(state, data, length);
262 if (state->data == NULL) {
263 reply_nterror(req, NT_STATUS_NO_MEMORY);
266 state->num_data = length;
267 state->max_read = max_read;
269 subreq = np_write_send(state, smbd_event_context(), state->handle,
270 state->data, length);
271 if (subreq == NULL) {
273 reply_nterror(req, NT_STATUS_NO_MEMORY);
276 tevent_req_set_callback(subreq, api_dcerpc_cmd_write_done,
277 talloc_move(conn, &req));
280 static void api_dcerpc_cmd_write_done(struct tevent_req *subreq)
282 struct smb_request *req = tevent_req_callback_data(
283 subreq, struct smb_request);
284 struct dcerpc_cmd_state *state = talloc_get_type_abort(
285 req->async_priv, struct dcerpc_cmd_state);
287 ssize_t nwritten = -1;
289 status = np_write_recv(subreq, &nwritten);
291 if (!NT_STATUS_IS_OK(status) || (nwritten != state->num_data)) {
292 DEBUG(10, ("Could not write to pipe: %s (%d/%d)\n",
293 nt_errstr(status), (int)state->num_data,
295 reply_nterror(req, NT_STATUS_PIPE_NOT_AVAILABLE);
299 state->data = TALLOC_REALLOC_ARRAY(state, state->data, uint8_t,
301 if (state->data == NULL) {
302 reply_nterror(req, NT_STATUS_NO_MEMORY);
306 subreq = np_read_send(req->conn, smbd_event_context(),
307 state->handle, state->data, state->max_read);
308 if (subreq == NULL) {
309 reply_nterror(req, NT_STATUS_NO_MEMORY);
312 tevent_req_set_callback(subreq, api_dcerpc_cmd_read_done, req);
317 req->sconn, (char *)req->outbuf,
319 IS_CONN_ENCRYPTED(req->conn) || req->encrypted,
321 exit_server_cleanly("api_dcerpc_cmd_write_done: "
322 "srv_send_smb failed.");
327 static void api_dcerpc_cmd_read_done(struct tevent_req *subreq)
329 struct smb_request *req = tevent_req_callback_data(
330 subreq, struct smb_request);
331 struct dcerpc_cmd_state *state = talloc_get_type_abort(
332 req->async_priv, struct dcerpc_cmd_state);
335 bool is_data_outstanding;
337 status = np_read_recv(subreq, &nread, &is_data_outstanding);
340 if (!NT_STATUS_IS_OK(status)) {
341 DEBUG(10, ("Could not read from to pipe: %s\n",
343 reply_nterror(req, status);
345 if (!srv_send_smb(req->sconn, (char *)req->outbuf,
347 IS_CONN_ENCRYPTED(req->conn)
348 ||req->encrypted, &req->pcd)) {
349 exit_server_cleanly("api_dcerpc_cmd_read_done: "
350 "srv_send_smb failed.");
356 send_trans_reply(req->conn, req, NULL, 0, (char *)state->data, nread,
357 is_data_outstanding);
361 /****************************************************************************
362 WaitNamedPipeHandleState
363 ****************************************************************************/
365 static void api_WNPHS(connection_struct *conn, struct smb_request *req,
366 struct files_struct *fsp, char *param, int param_len)
368 if (!param || param_len < 2) {
369 reply_nterror(req, NT_STATUS_INVALID_PARAMETER);
373 DEBUG(4,("WaitNamedPipeHandleState priority %x\n",
374 (int)SVAL(param,0)));
376 send_trans_reply(conn, req, NULL, 0, NULL, 0, False);
380 /****************************************************************************
381 SetNamedPipeHandleState
382 ****************************************************************************/
384 static void api_SNPHS(connection_struct *conn, struct smb_request *req,
385 struct files_struct *fsp, char *param, int param_len)
387 if (!param || param_len < 2) {
388 reply_nterror(req, NT_STATUS_INVALID_PARAMETER);
392 DEBUG(4,("SetNamedPipeHandleState to code %x\n", (int)SVAL(param,0)));
394 send_trans_reply(conn, req, NULL, 0, NULL, 0, False);
398 /****************************************************************************
399 When no reply is generated, indicate unsupported.
400 ****************************************************************************/
402 static void api_no_reply(connection_struct *conn, struct smb_request *req)
407 SSVAL(rparam,0,NERR_notsupported);
408 SSVAL(rparam,2,0); /* converter word */
410 DEBUG(3,("Unsupported API fd command\n"));
412 /* now send the reply */
413 send_trans_reply(conn, req, rparam, 4, NULL, 0, False);
418 /****************************************************************************
419 Handle remote api calls delivered to a named pipe already opened.
420 ****************************************************************************/
422 static void api_fd_reply(connection_struct *conn, uint16 vuid,
423 struct smb_request *req,
424 uint16 *setup, uint8_t *data, char *params,
425 int suwcnt, int tdscnt, int tpscnt,
426 int mdrcnt, int mprcnt)
428 struct files_struct *fsp;
432 DEBUG(5,("api_fd_reply\n"));
434 /* First find out the name of this file. */
436 DEBUG(0,("Unexpected named pipe transaction.\n"));
437 reply_nterror(req, NT_STATUS_INVALID_PARAMETER);
441 /* Get the file handle and hence the file name. */
443 * NB. The setup array has already been transformed
444 * via SVAL and so is in host byte order.
446 pnum = ((int)setup[1]) & 0xFFFF;
447 subcommand = ((int)setup[0]) & 0xFFFF;
449 fsp = file_fsp(req, pnum);
451 if (!fsp_is_np(fsp)) {
452 if (subcommand == TRANSACT_WAITNAMEDPIPEHANDLESTATE) {
453 /* Win9x does this call with a unicode pipe name, not a pnum. */
454 /* Just return success for now... */
455 DEBUG(3,("Got TRANSACT_WAITNAMEDPIPEHANDLESTATE on text pipe name\n"));
456 send_trans_reply(conn, req, NULL, 0, NULL, 0, False);
460 DEBUG(1,("api_fd_reply: INVALID PIPE HANDLE: %x\n", pnum));
461 reply_nterror(req, NT_STATUS_INVALID_HANDLE);
465 if (vuid != fsp->vuid) {
466 DEBUG(1, ("Got pipe request (pnum %x) using invalid VUID %d, "
467 "expected %d\n", pnum, vuid, fsp->vuid));
468 reply_nterror(req, NT_STATUS_INVALID_HANDLE);
472 DEBUG(3,("Got API command 0x%x on pipe \"%s\" (pnum %x)\n",
473 subcommand, fsp_str_dbg(fsp), pnum));
475 DEBUG(10, ("api_fd_reply: p:%p max_trans_reply: %d\n", fsp, mdrcnt));
477 switch (subcommand) {
478 case TRANSACT_DCERPCCMD: {
479 /* dce/rpc command */
480 api_dcerpc_cmd(conn, req, fsp, (uint8_t *)data, tdscnt,
484 case TRANSACT_WAITNAMEDPIPEHANDLESTATE:
485 /* Wait Named Pipe Handle state */
486 api_WNPHS(conn, req, fsp, params, tpscnt);
488 case TRANSACT_SETNAMEDPIPEHANDLESTATE:
489 /* Set Named Pipe Handle state */
490 api_SNPHS(conn, req, fsp, params, tpscnt);
493 reply_nterror(req, NT_STATUS_INVALID_PARAMETER);
498 /****************************************************************************
499 Handle named pipe commands.
500 ****************************************************************************/
502 static void named_pipe(connection_struct *conn, uint16 vuid,
503 struct smb_request *req,
504 const char *name, uint16 *setup,
505 char *data, char *params,
506 int suwcnt, int tdscnt,int tpscnt,
507 int msrcnt, int mdrcnt, int mprcnt)
509 DEBUG(3,("named pipe command on <%s> name\n", name));
511 if (strequal(name,"LANMAN")) {
512 api_reply(conn, vuid, req,
519 if (strequal(name,"WKSSVC") ||
520 strequal(name,"SRVSVC") ||
521 strequal(name,"WINREG") ||
522 strequal(name,"SAMR") ||
523 strequal(name,"LSARPC")) {
525 DEBUG(4,("named pipe command from Win95 (wow!)\n"));
527 api_fd_reply(conn, vuid, req,
528 setup, (uint8_t *)data, params,
529 suwcnt, tdscnt, tpscnt,
534 if (strlen(name) < 1) {
535 api_fd_reply(conn, vuid, req,
536 setup, (uint8_t *)data,
537 params, suwcnt, tdscnt,
538 tpscnt, mdrcnt, mprcnt);
543 DEBUG(3,("unknown named pipe: setup 0x%X setup1=%d\n",
544 (int)setup[0],(int)setup[1]));
546 reply_nterror(req, NT_STATUS_NOT_SUPPORTED);
550 static void handle_trans(connection_struct *conn, struct smb_request *req,
551 struct trans_state *state)
553 char *local_machine_name;
556 DEBUG(3,("trans <%s> data=%u params=%u setup=%u\n",
557 state->name,(unsigned int)state->total_data,(unsigned int)state->total_param,
558 (unsigned int)state->setup_count));
561 * WinCE wierdness....
564 local_machine_name = talloc_asprintf(state, "\\%s\\",
565 get_local_machine_name());
567 if (local_machine_name == NULL) {
568 reply_nterror(req, NT_STATUS_NO_MEMORY);
572 if (strnequal(state->name, local_machine_name,
573 strlen(local_machine_name))) {
574 name_offset = strlen(local_machine_name)-1;
577 if (!strnequal(&state->name[name_offset], "\\PIPE",
579 reply_nterror(req, NT_STATUS_NOT_SUPPORTED);
583 name_offset += strlen("\\PIPE");
585 /* Win9x weirdness. When talking to a unicode server Win9x
586 only sends \PIPE instead of \PIPE\ */
588 if (state->name[name_offset] == '\\')
591 DEBUG(5,("calling named_pipe\n"));
592 named_pipe(conn, state->vuid, req,
593 state->name+name_offset,
594 state->setup,state->data,
596 state->setup_count,state->total_data,
598 state->max_setup_return,
599 state->max_data_return,
600 state->max_param_return);
602 if (state->close_on_completion) {
603 close_cnum(conn,state->vuid);
610 /****************************************************************************
612 ****************************************************************************/
614 void reply_trans(struct smb_request *req)
616 connection_struct *conn = req->conn;
621 struct trans_state *state;
624 START_PROFILE(SMBtrans);
627 reply_nterror(req, NT_STATUS_INVALID_PARAMETER);
628 END_PROFILE(SMBtrans);
632 dsoff = SVAL(req->vwv+12, 0);
633 dscnt = SVAL(req->vwv+11, 0);
634 psoff = SVAL(req->vwv+10, 0);
635 pscnt = SVAL(req->vwv+9, 0);
637 result = allow_new_trans(conn->pending_trans, req->mid);
638 if (!NT_STATUS_IS_OK(result)) {
639 DEBUG(2, ("Got invalid trans request: %s\n",
641 reply_nterror(req, result);
642 END_PROFILE(SMBtrans);
646 if ((state = TALLOC_P(conn, struct trans_state)) == NULL) {
647 DEBUG(0, ("talloc failed\n"));
648 reply_nterror(req, NT_STATUS_NO_MEMORY);
649 END_PROFILE(SMBtrans);
653 state->cmd = SMBtrans;
655 state->mid = req->mid;
656 state->vuid = req->vuid;
657 state->setup_count = CVAL(req->vwv+13, 0);
659 state->total_param = SVAL(req->vwv+0, 0);
661 state->total_data = SVAL(req->vwv+1, 0);
663 state->max_param_return = SVAL(req->vwv+2, 0);
664 state->max_data_return = SVAL(req->vwv+3, 0);
665 state->max_setup_return = CVAL(req->vwv+4, 0);
666 state->close_on_completion = BITSETW(req->vwv+5, 0);
667 state->one_way = BITSETW(req->vwv+5, 1);
669 srvstr_pull_req_talloc(state, req, &state->name, req->buf,
672 if ((dscnt > state->total_data) || (pscnt > state->total_param) ||
676 if (state->total_data) {
678 if (trans_oob(state->total_data, 0, dscnt)
679 || trans_oob(smb_len(req->inbuf), dsoff, dscnt)) {
683 /* Can't use talloc here, the core routines do realloc on the
684 * params and data. Out of paranoia, 100 bytes too many. */
685 state->data = (char *)SMB_MALLOC(state->total_data+100);
686 if (state->data == NULL) {
687 DEBUG(0,("reply_trans: data malloc fail for %u "
688 "bytes !\n", (unsigned int)state->total_data));
690 reply_nterror(req, NT_STATUS_NO_MEMORY);
691 END_PROFILE(SMBtrans);
694 /* null-terminate the slack space */
695 memset(&state->data[state->total_data], 0, 100);
697 memcpy(state->data,smb_base(req->inbuf)+dsoff,dscnt);
700 if (state->total_param) {
702 if (trans_oob(state->total_param, 0, pscnt)
703 || trans_oob(smb_len(req->inbuf), psoff, pscnt)) {
707 /* Can't use talloc here, the core routines do realloc on the
708 * params and data. Out of paranoia, 100 bytes too many */
709 state->param = (char *)SMB_MALLOC(state->total_param+100);
710 if (state->param == NULL) {
711 DEBUG(0,("reply_trans: param malloc fail for %u "
712 "bytes !\n", (unsigned int)state->total_param));
713 SAFE_FREE(state->data);
715 reply_nterror(req, NT_STATUS_NO_MEMORY);
716 END_PROFILE(SMBtrans);
719 /* null-terminate the slack space */
720 memset(&state->param[state->total_param], 0, 100);
722 memcpy(state->param,smb_base(req->inbuf)+psoff,pscnt);
725 state->received_data = dscnt;
726 state->received_param = pscnt;
728 if (state->setup_count) {
732 * No overflow possible here, state->setup_count is an
733 * unsigned int, being filled by a single byte from
734 * CVAL(req->vwv+13, 0) above. The cast in the comparison
735 * below is not necessary, it's here to clarify things. The
736 * validity of req->vwv and req->wct has been checked in
737 * init_smb_request already.
739 if (state->setup_count + 14 > (unsigned int)req->wct) {
743 if((state->setup = TALLOC_ARRAY(
744 state, uint16, state->setup_count)) == NULL) {
745 DEBUG(0,("reply_trans: setup malloc fail for %u "
746 "bytes !\n", (unsigned int)
747 (state->setup_count * sizeof(uint16))));
748 SAFE_FREE(state->data);
749 SAFE_FREE(state->param);
751 reply_nterror(req, NT_STATUS_NO_MEMORY);
752 END_PROFILE(SMBtrans);
756 for (i=0;i<state->setup_count;i++) {
757 state->setup[i] = SVAL(req->vwv + 14 + i, 0);
761 state->received_param = pscnt;
763 if ((state->received_param != state->total_param) ||
764 (state->received_data != state->total_data)) {
765 DLIST_ADD(conn->pending_trans, state);
767 /* We need to send an interim response then receive the rest
768 of the parameter/data bytes */
769 reply_outbuf(req, 0, 0);
770 show_msg((char *)req->outbuf);
771 END_PROFILE(SMBtrans);
775 talloc_steal(talloc_tos(), state);
777 handle_trans(conn, req, state);
779 SAFE_FREE(state->data);
780 SAFE_FREE(state->param);
783 END_PROFILE(SMBtrans);
788 DEBUG(0,("reply_trans: invalid trans parameters\n"));
789 SAFE_FREE(state->data);
790 SAFE_FREE(state->param);
792 END_PROFILE(SMBtrans);
793 reply_nterror(req, NT_STATUS_INVALID_PARAMETER);
797 /****************************************************************************
798 Reply to a secondary SMBtrans.
799 ****************************************************************************/
801 void reply_transs(struct smb_request *req)
803 connection_struct *conn = req->conn;
804 unsigned int pcnt,poff,dcnt,doff,pdisp,ddisp;
805 struct trans_state *state;
807 START_PROFILE(SMBtranss);
809 show_msg((char *)req->inbuf);
812 reply_nterror(req, NT_STATUS_INVALID_PARAMETER);
813 END_PROFILE(SMBtranss);
817 for (state = conn->pending_trans; state != NULL;
818 state = state->next) {
819 if (state->mid == req->mid) {
824 if ((state == NULL) || (state->cmd != SMBtrans)) {
825 reply_nterror(req, NT_STATUS_INVALID_PARAMETER);
826 END_PROFILE(SMBtranss);
830 /* Revise total_params and total_data in case they have changed
833 if (SVAL(req->vwv+0, 0) < state->total_param)
834 state->total_param = SVAL(req->vwv+0, 0);
835 if (SVAL(req->vwv+1, 0) < state->total_data)
836 state->total_data = SVAL(req->vwv+1, 0);
838 pcnt = SVAL(req->vwv+2, 0);
839 poff = SVAL(req->vwv+3, 0);
840 pdisp = SVAL(req->vwv+4, 0);
842 dcnt = SVAL(req->vwv+5, 0);
843 doff = SVAL(req->vwv+6, 0);
844 ddisp = SVAL(req->vwv+7, 0);
846 state->received_param += pcnt;
847 state->received_data += dcnt;
849 if ((state->received_data > state->total_data) ||
850 (state->received_param > state->total_param))
854 if (trans_oob(state->total_param, pdisp, pcnt)
855 || trans_oob(smb_len(req->inbuf), poff, pcnt)) {
858 memcpy(state->param+pdisp,smb_base(req->inbuf)+poff,pcnt);
862 if (trans_oob(state->total_data, ddisp, dcnt)
863 || trans_oob(smb_len(req->inbuf), doff, dcnt)) {
866 memcpy(state->data+ddisp, smb_base(req->inbuf)+doff,dcnt);
869 if ((state->received_param < state->total_param) ||
870 (state->received_data < state->total_data)) {
871 END_PROFILE(SMBtranss);
875 talloc_steal(talloc_tos(), state);
877 handle_trans(conn, req, state);
879 DLIST_REMOVE(conn->pending_trans, state);
880 SAFE_FREE(state->data);
881 SAFE_FREE(state->param);
884 END_PROFILE(SMBtranss);
889 DEBUG(0,("reply_transs: invalid trans parameters\n"));
890 DLIST_REMOVE(conn->pending_trans, state);
891 SAFE_FREE(state->data);
892 SAFE_FREE(state->param);
894 reply_nterror(req, NT_STATUS_INVALID_PARAMETER);
895 END_PROFILE(SMBtranss);