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
31 #define NERR_notsupported 50
33 extern int smb_read_error
;
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
)+1;
57 DEBUG(5,("copy_trans_params_and_data: params[%d..%d] data[%d..%d]\n",
58 param_offset
, param_offset
+ param_len
,
59 data_offset
, data_offset
+ data_len
));
62 memcpy(copy_into
, &rparam
[param_offset
], param_len
);
64 copy_into
+= param_len
+ align
;
67 memcpy(copy_into
, &rdata
[data_offset
], data_len
);
70 /****************************************************************************
72 ****************************************************************************/
74 void send_trans_reply(const char *inbuf
,
80 BOOL buffer_too_large
)
82 int this_ldata
,this_lparam
;
83 int tot_data_sent
= 0;
84 int tot_param_sent
= 0;
87 int ldata
= rdata
? rdata_len
: 0;
88 int lparam
= rparam
? rparam_len
: 0;
91 DEBUG(5,("send_trans_reply: buffer %d too large\n", ldata
));
93 this_lparam
= MIN(lparam
,max_send
- 500); /* hack */
94 this_ldata
= MIN(ldata
,max_send
- (500+this_lparam
));
96 align
= ((this_lparam
)%4);
98 if (buffer_too_large
) {
99 ERROR_BOTH(STATUS_BUFFER_OVERFLOW
,ERRDOS
,ERRmoredata
);
102 set_message(inbuf
,outbuf
,10,1+align
+this_ldata
+this_lparam
,True
);
104 copy_trans_params_and_data(outbuf
, align
,
105 rparam
, tot_param_sent
, this_lparam
,
106 rdata
, tot_data_sent
, this_ldata
);
108 SSVAL(outbuf
,smb_vwv0
,lparam
);
109 SSVAL(outbuf
,smb_vwv1
,ldata
);
110 SSVAL(outbuf
,smb_vwv3
,this_lparam
);
111 SSVAL(outbuf
,smb_vwv4
,smb_offset(smb_buf(outbuf
)+1,outbuf
));
112 SSVAL(outbuf
,smb_vwv5
,0);
113 SSVAL(outbuf
,smb_vwv6
,this_ldata
);
114 SSVAL(outbuf
,smb_vwv7
,smb_offset(smb_buf(outbuf
)+1+this_lparam
+align
,outbuf
));
115 SSVAL(outbuf
,smb_vwv8
,0);
116 SSVAL(outbuf
,smb_vwv9
,0);
119 if (!send_smb(smbd_server_fd(),outbuf
))
120 exit_server_cleanly("send_trans_reply: send_smb failed.");
122 tot_data_sent
= this_ldata
;
123 tot_param_sent
= this_lparam
;
125 while (tot_data_sent
< ldata
|| tot_param_sent
< lparam
)
127 this_lparam
= MIN(lparam
-tot_param_sent
, max_send
- 500); /* hack */
128 this_ldata
= MIN(ldata
-tot_data_sent
, max_send
- (500+this_lparam
));
136 align
= (this_lparam
%4);
138 set_message(inbuf
,outbuf
,10,1+this_ldata
+this_lparam
+align
,False
);
140 copy_trans_params_and_data(outbuf
, align
,
141 rparam
, tot_param_sent
, this_lparam
,
142 rdata
, tot_data_sent
, this_ldata
);
144 SSVAL(outbuf
,smb_vwv3
,this_lparam
);
145 SSVAL(outbuf
,smb_vwv4
,smb_offset(smb_buf(outbuf
)+1,outbuf
));
146 SSVAL(outbuf
,smb_vwv5
,tot_param_sent
);
147 SSVAL(outbuf
,smb_vwv6
,this_ldata
);
148 SSVAL(outbuf
,smb_vwv7
,smb_offset(smb_buf(outbuf
)+1+this_lparam
+align
,outbuf
));
149 SSVAL(outbuf
,smb_vwv8
,tot_data_sent
);
150 SSVAL(outbuf
,smb_vwv9
,0);
153 if (!send_smb(smbd_server_fd(),outbuf
))
154 exit_server_cleanly("send_trans_reply: send_smb failed.");
156 tot_data_sent
+= this_ldata
;
157 tot_param_sent
+= this_lparam
;
161 void send_trans_reply_new(struct smb_request
*req
,
162 char *rparam
, int rparam_len
,
163 char *rdata
, int rdata_len
,
164 BOOL buffer_too_large
)
166 char *inbuf
, *outbuf
;
169 if (!reply_prep_legacy(req
, &inbuf
, &outbuf
, &size
, &buflength
)) {
170 reply_nterror(req
, NT_STATUS_NO_MEMORY
);
174 send_trans_reply(inbuf
, outbuf
, rparam
, rparam_len
,
175 rdata
, rdata_len
, buffer_too_large
);
176 reply_post_legacy(req
, -1);
179 /****************************************************************************
180 Start the first part of an RPC reply which began with an SMBtrans request.
181 ****************************************************************************/
183 static BOOL
api_rpc_trans_reply(const char *inbuf
,
187 BOOL is_data_outstanding
;
188 char *rdata
= (char *)SMB_MALLOC(p
->max_trans_reply
);
192 DEBUG(0,("api_rpc_trans_reply: malloc fail.\n"));
196 if((data_len
= read_from_pipe( p
, rdata
, p
->max_trans_reply
,
197 &is_data_outstanding
)) < 0) {
202 send_trans_reply(inbuf
, outbuf
, NULL
, 0, rdata
, data_len
, is_data_outstanding
);
208 /****************************************************************************
209 WaitNamedPipeHandleState
210 ****************************************************************************/
212 static BOOL
api_WNPHS(const char *inbuf
,
220 if (!param
|| param_len
< 2)
223 priority
= SVAL(param
,0);
224 DEBUG(4,("WaitNamedPipeHandleState priority %x\n", priority
));
226 if (wait_rpc_pipe_hnd_state(p
, priority
)) {
227 /* now send the reply */
228 send_trans_reply(inbuf
, outbuf
, NULL
, 0, NULL
, 0, False
);
235 /****************************************************************************
236 SetNamedPipeHandleState
237 ****************************************************************************/
239 static BOOL
api_SNPHS(const char *inbuf
,
247 if (!param
|| param_len
< 2)
251 DEBUG(4,("SetNamedPipeHandleState to code %x\n", id
));
253 if (set_rpc_pipe_hnd_state(p
, id
)) {
254 /* now send the reply */
255 send_trans_reply(inbuf
, outbuf
, NULL
, 0, NULL
, 0, False
);
262 /****************************************************************************
263 When no reply is generated, indicate unsupported.
264 ****************************************************************************/
266 static void api_no_reply(struct smb_request
*req
)
271 SSVAL(rparam
,0,NERR_notsupported
);
272 SSVAL(rparam
,2,0); /* converter word */
274 DEBUG(3,("Unsupported API fd command\n"));
276 /* now send the reply */
277 send_trans_reply_new(req
, rparam
, 4, NULL
, 0, False
);
282 /****************************************************************************
283 Handle remote api calls delivered to a named pipe already opened.
284 ****************************************************************************/
286 static void api_fd_reply(connection_struct
*conn
, uint16 vuid
,
287 struct smb_request
*req
,
288 uint16
*setup
, char *data
, char *params
,
289 int suwcnt
, int tdscnt
, int tpscnt
,
290 int mdrcnt
, int mprcnt
)
293 smb_np_struct
*p
= NULL
;
297 DEBUG(5,("api_fd_reply\n"));
299 /* First find out the name of this file. */
301 DEBUG(0,("Unexpected named pipe transaction.\n"));
302 reply_nterror(req
, NT_STATUS_INVALID_PARAMETER
);
306 /* Get the file handle and hence the file name. */
308 * NB. The setup array has already been transformed
309 * via SVAL and so is in gost byte order.
311 pnum
= ((int)setup
[1]) & 0xFFFF;
312 subcommand
= ((int)setup
[0]) & 0xFFFF;
314 if(!(p
= get_rpc_pipe(pnum
))) {
315 if (subcommand
== TRANSACT_WAITNAMEDPIPEHANDLESTATE
) {
316 /* Win9x does this call with a unicode pipe name, not a pnum. */
317 /* Just return success for now... */
318 DEBUG(3,("Got TRANSACT_WAITNAMEDPIPEHANDLESTATE on text pipe name\n"));
319 send_trans_reply_new(req
, NULL
, 0, NULL
, 0, False
);
323 DEBUG(1,("api_fd_reply: INVALID PIPE HANDLE: %x\n", pnum
));
324 reply_nterror(req
, NT_STATUS_INVALID_HANDLE
);
328 if (vuid
!= p
->vuid
) {
329 DEBUG(1, ("Got pipe request (pnum %x) using invalid VUID %d, "
330 "expected %d\n", pnum
, vuid
, p
->vuid
));
331 reply_nterror(req
, NT_STATUS_INVALID_HANDLE
);
335 DEBUG(3,("Got API command 0x%x on pipe \"%s\" (pnum %x)\n", subcommand
, p
->name
, pnum
));
337 /* record maximum data length that can be transmitted in an SMBtrans */
338 p
->max_trans_reply
= mdrcnt
;
340 DEBUG(10,("api_fd_reply: p:%p max_trans_reply: %d\n", p
, p
->max_trans_reply
));
342 switch (subcommand
) {
343 case TRANSACT_DCERPCCMD
: {
345 char *inbuf
, *outbuf
;
348 if (!reply_prep_legacy(req
, &inbuf
, &outbuf
, &size
,
350 reply_nterror(req
, NT_STATUS_NO_MEMORY
);
354 /* dce/rpc command */
355 reply
= write_to_pipe(p
, data
, tdscnt
);
357 reply
= api_rpc_trans_reply(inbuf
, outbuf
, p
);
363 reply_post_legacy(req
, -1);
366 case TRANSACT_WAITNAMEDPIPEHANDLESTATE
: {
368 char *inbuf
, *outbuf
;
371 if (!reply_prep_legacy(req
, &inbuf
, &outbuf
, &size
,
373 reply_nterror(req
, NT_STATUS_NO_MEMORY
);
377 /* Wait Named Pipe Handle state */
378 if (!api_WNPHS(inbuf
, outbuf
, p
, params
, tpscnt
)) {
383 reply_post_legacy(req
, -1);
386 case TRANSACT_SETNAMEDPIPEHANDLESTATE
: {
388 char *inbuf
, *outbuf
;
391 if (!reply_prep_legacy(req
, &inbuf
, &outbuf
, &size
,
393 reply_nterror(req
, NT_STATUS_NO_MEMORY
);
397 /* Set Named Pipe Handle state */
398 if (!api_SNPHS(inbuf
, outbuf
, p
, params
, tpscnt
)) {
403 reply_post_legacy(req
, -1);
407 reply_nterror(req
, NT_STATUS_INVALID_PARAMETER
);
412 /****************************************************************************
413 Handle named pipe commands.
414 ****************************************************************************/
416 static void named_pipe(connection_struct
*conn
, uint16 vuid
,
417 struct smb_request
*req
,
418 char *name
, uint16
*setup
,
419 char *data
, char *params
,
420 int suwcnt
, int tdscnt
,int tpscnt
,
421 int msrcnt
, int mdrcnt
, int mprcnt
)
423 DEBUG(3,("named pipe command on <%s> name\n", name
));
425 if (strequal(name
,"LANMAN")) {
426 char *inbuf
, *outbuf
;
429 if (!reply_prep_legacy(req
, &inbuf
, &outbuf
, &size
, &bufsize
)) {
430 reply_nterror(req
, NT_STATUS_NO_MEMORY
);
436 api_reply(conn
, vuid
, inbuf
, outbuf
,
443 if (strequal(name
,"WKSSVC") ||
444 strequal(name
,"SRVSVC") ||
445 strequal(name
,"WINREG") ||
446 strequal(name
,"SAMR") ||
447 strequal(name
,"LSARPC")) {
449 DEBUG(4,("named pipe command from Win95 (wow!)\n"));
451 api_fd_reply(conn
, vuid
, req
,
453 suwcnt
, tdscnt
, tpscnt
,
458 if (strlen(name
) < 1) {
459 api_fd_reply(conn
, vuid
, req
,
461 params
, suwcnt
, tdscnt
,
462 tpscnt
, mdrcnt
, mprcnt
);
467 DEBUG(3,("unknown named pipe: setup 0x%X setup1=%d\n",
468 (int)setup
[0],(int)setup
[1]));
470 reply_nterror(req
, NT_STATUS_NOT_SUPPORTED
);
474 static void handle_trans(connection_struct
*conn
, struct smb_request
*req
,
475 struct trans_state
*state
)
477 char *local_machine_name
;
480 DEBUG(3,("trans <%s> data=%u params=%u setup=%u\n",
481 state
->name
,(unsigned int)state
->total_data
,(unsigned int)state
->total_param
,
482 (unsigned int)state
->setup_count
));
485 * WinCE wierdness....
488 local_machine_name
= talloc_asprintf(state
, "\\%s\\",
489 get_local_machine_name());
491 if (local_machine_name
== NULL
) {
492 reply_nterror(req
, NT_STATUS_NO_MEMORY
);
496 if (strnequal(state
->name
, local_machine_name
,
497 strlen(local_machine_name
))) {
498 name_offset
= strlen(local_machine_name
)-1;
501 if (!strnequal(&state
->name
[name_offset
], "\\PIPE",
503 reply_nterror(req
, NT_STATUS_NOT_SUPPORTED
);
507 name_offset
+= strlen("\\PIPE");
509 /* Win9x weirdness. When talking to a unicode server Win9x
510 only sends \PIPE instead of \PIPE\ */
512 if (state
->name
[name_offset
] == '\\')
515 DEBUG(5,("calling named_pipe\n"));
516 named_pipe(conn
, state
->vuid
, req
,
517 state
->name
+name_offset
,
518 state
->setup
,state
->data
,
520 state
->setup_count
,state
->total_data
,
522 state
->max_setup_return
,
523 state
->max_data_return
,
524 state
->max_param_return
);
526 if (state
->close_on_completion
)
527 close_cnum(conn
,state
->vuid
);
532 /****************************************************************************
534 ****************************************************************************/
536 void reply_trans(connection_struct
*conn
, struct smb_request
*req
)
542 struct trans_state
*state
;
546 START_PROFILE(SMBtrans
);
548 if (SVAL(req
->inbuf
, smb_wct
) < 10) {
549 reply_nterror(req
, NT_STATUS_INVALID_PARAMETER
);
550 END_PROFILE(SMBtrans
);
554 size
= smb_len(req
->inbuf
) + 4;
555 dsoff
= SVAL(req
->inbuf
, smb_dsoff
);
556 dscnt
= SVAL(req
->inbuf
, smb_dscnt
);
557 psoff
= SVAL(req
->inbuf
, smb_psoff
);
558 pscnt
= SVAL(req
->inbuf
, smb_pscnt
);
560 result
= allow_new_trans(conn
->pending_trans
, req
->mid
);
561 if (!NT_STATUS_IS_OK(result
)) {
562 DEBUG(2, ("Got invalid trans request: %s\n",
564 reply_nterror(req
, result
);
565 END_PROFILE(SMBtrans
);
569 if ((state
= TALLOC_P(conn
->mem_ctx
, struct trans_state
)) == NULL
) {
570 DEBUG(0, ("talloc failed\n"));
571 reply_nterror(req
, NT_STATUS_NO_MEMORY
);
572 END_PROFILE(SMBtrans
);
576 state
->cmd
= SMBtrans
;
578 state
->mid
= req
->mid
;
579 state
->vuid
= req
->vuid
;
580 state
->setup_count
= CVAL(req
->inbuf
, smb_suwcnt
);
582 state
->total_param
= SVAL(req
->inbuf
, smb_tpscnt
);
584 state
->total_data
= SVAL(req
->inbuf
, smb_tdscnt
);
586 state
->max_param_return
= SVAL(req
->inbuf
, smb_mprcnt
);
587 state
->max_data_return
= SVAL(req
->inbuf
, smb_mdrcnt
);
588 state
->max_setup_return
= CVAL(req
->inbuf
, smb_msrcnt
);
589 state
->close_on_completion
= BITSETW(req
->inbuf
+smb_vwv5
,0);
590 state
->one_way
= BITSETW(req
->inbuf
+smb_vwv5
,1);
592 memset(state
->name
, '\0',sizeof(state
->name
));
593 srvstr_pull_buf(req
->inbuf
, req
->flags2
, state
->name
,
594 smb_buf(req
->inbuf
), sizeof(state
->name
),
597 if ((dscnt
> state
->total_data
) || (pscnt
> state
->total_param
))
600 if (state
->total_data
) {
601 /* Can't use talloc here, the core routines do realloc on the
602 * params and data. Out of paranoia, 100 bytes too many. */
603 state
->data
= (char *)SMB_MALLOC(state
->total_data
+100);
604 if (state
->data
== NULL
) {
605 DEBUG(0,("reply_trans: data malloc fail for %u "
606 "bytes !\n", (unsigned int)state
->total_data
));
608 reply_nterror(req
, NT_STATUS_NO_MEMORY
);
609 END_PROFILE(SMBtrans
);
612 /* null-terminate the slack space */
613 memset(&state
->data
[state
->total_data
], 0, 100);
614 if ((dsoff
+dscnt
< dsoff
) || (dsoff
+dscnt
< dscnt
))
616 if ((smb_base(req
->inbuf
)+dsoff
+dscnt
617 > (char *)req
->inbuf
+ size
) ||
618 (smb_base(req
->inbuf
)+dsoff
+dscnt
< smb_base(req
->inbuf
)))
621 memcpy(state
->data
,smb_base(req
->inbuf
)+dsoff
,dscnt
);
624 if (state
->total_param
) {
625 /* Can't use talloc here, the core routines do realloc on the
626 * params and data. Out of paranoia, 100 bytes too many */
627 state
->param
= (char *)SMB_MALLOC(state
->total_param
+100);
628 if (state
->param
== NULL
) {
629 DEBUG(0,("reply_trans: param malloc fail for %u "
630 "bytes !\n", (unsigned int)state
->total_param
));
631 SAFE_FREE(state
->data
);
633 reply_nterror(req
, NT_STATUS_NO_MEMORY
);
634 END_PROFILE(SMBtrans
);
637 /* null-terminate the slack space */
638 memset(&state
->param
[state
->total_param
], 0, 100);
639 if ((psoff
+pscnt
< psoff
) || (psoff
+pscnt
< pscnt
))
641 if ((smb_base(req
->inbuf
)+psoff
+pscnt
642 > (char *)req
->inbuf
+ size
) ||
643 (smb_base(req
->inbuf
)+psoff
+pscnt
< smb_base(req
->inbuf
)))
646 memcpy(state
->param
,smb_base(req
->inbuf
)+psoff
,pscnt
);
649 state
->received_data
= dscnt
;
650 state
->received_param
= pscnt
;
652 if (state
->setup_count
) {
654 if((state
->setup
= TALLOC_ARRAY(
655 state
, uint16
, state
->setup_count
)) == NULL
) {
656 DEBUG(0,("reply_trans: setup malloc fail for %u "
657 "bytes !\n", (unsigned int)
658 (state
->setup_count
* sizeof(uint16
))));
659 SAFE_FREE(state
->data
);
660 SAFE_FREE(state
->param
);
662 reply_nterror(req
, NT_STATUS_NO_MEMORY
);
663 END_PROFILE(SMBtrans
);
666 if (req
->inbuf
+smb_vwv14
+(state
->setup_count
*SIZEOFWORD
) >
669 if ((smb_vwv14
+(state
->setup_count
*SIZEOFWORD
) < smb_vwv14
) ||
670 (smb_vwv14
+(state
->setup_count
*SIZEOFWORD
) <
671 (state
->setup_count
*SIZEOFWORD
)))
674 for (i
=0;i
<state
->setup_count
;i
++)
675 state
->setup
[i
] = SVAL(req
->inbuf
,
676 smb_vwv14
+i
*SIZEOFWORD
);
679 state
->received_param
= pscnt
;
681 if ((state
->received_param
!= state
->total_param
) ||
682 (state
->received_data
!= state
->total_data
)) {
683 DLIST_ADD(conn
->pending_trans
, state
);
685 /* We need to send an interim response then receive the rest
686 of the parameter/data bytes */
687 reply_outbuf(req
, 0, 0);
688 show_msg((char *)req
->outbuf
);
689 END_PROFILE(SMBtrans
);
693 handle_trans(conn
, req
, state
);
695 SAFE_FREE(state
->data
);
696 SAFE_FREE(state
->param
);
699 END_PROFILE(SMBtrans
);
704 DEBUG(0,("reply_trans: invalid trans parameters\n"));
705 SAFE_FREE(state
->data
);
706 SAFE_FREE(state
->param
);
708 END_PROFILE(SMBtrans
);
709 reply_nterror(req
, NT_STATUS_INVALID_PARAMETER
);
713 /****************************************************************************
714 Reply to a secondary SMBtrans.
715 ****************************************************************************/
717 void reply_transs(connection_struct
*conn
, struct smb_request
*req
)
719 unsigned int pcnt
,poff
,dcnt
,doff
,pdisp
,ddisp
;
720 struct trans_state
*state
;
723 START_PROFILE(SMBtranss
);
725 show_msg((char *)req
->inbuf
);
728 reply_nterror(req
, NT_STATUS_INVALID_PARAMETER
);
729 END_PROFILE(SMBtranss
);
733 for (state
= conn
->pending_trans
; state
!= NULL
;
734 state
= state
->next
) {
735 if (state
->mid
== req
->mid
) {
740 if ((state
== NULL
) || (state
->cmd
!= SMBtrans
)) {
741 reply_nterror(req
, NT_STATUS_INVALID_PARAMETER
);
742 END_PROFILE(SMBtranss
);
746 /* Revise total_params and total_data in case they have changed
749 if (SVAL(req
->inbuf
, smb_vwv0
) < state
->total_param
)
750 state
->total_param
= SVAL(req
->inbuf
,smb_vwv0
);
751 if (SVAL(req
->inbuf
, smb_vwv1
) < state
->total_data
)
752 state
->total_data
= SVAL(req
->inbuf
,smb_vwv1
);
754 size
= smb_len(req
->inbuf
) + 4;
756 pcnt
= SVAL(req
->inbuf
, smb_spscnt
);
757 poff
= SVAL(req
->inbuf
, smb_spsoff
);
758 pdisp
= SVAL(req
->inbuf
, smb_spsdisp
);
760 dcnt
= SVAL(req
->inbuf
, smb_sdscnt
);
761 doff
= SVAL(req
->inbuf
, smb_sdsoff
);
762 ddisp
= SVAL(req
->inbuf
, smb_sdsdisp
);
764 state
->received_param
+= pcnt
;
765 state
->received_data
+= dcnt
;
767 if ((state
->received_data
> state
->total_data
) ||
768 (state
->received_param
> state
->total_param
))
772 if (pdisp
+pcnt
> state
->total_param
)
774 if ((pdisp
+pcnt
< pdisp
) || (pdisp
+pcnt
< pcnt
))
776 if (pdisp
> state
->total_param
)
778 if ((smb_base(req
->inbuf
) + poff
+ pcnt
779 > (char *)req
->inbuf
+ size
) ||
780 (smb_base(req
->inbuf
) + poff
+ pcnt
781 < smb_base(req
->inbuf
)))
783 if (state
->param
+ pdisp
< state
->param
)
786 memcpy(state
->param
+pdisp
,smb_base(req
->inbuf
)+poff
,
791 if (ddisp
+dcnt
> state
->total_data
)
793 if ((ddisp
+dcnt
< ddisp
) || (ddisp
+dcnt
< dcnt
))
795 if (ddisp
> state
->total_data
)
797 if ((smb_base(req
->inbuf
) + doff
+ dcnt
798 > (char *)req
->inbuf
+ size
) ||
799 (smb_base(req
->inbuf
) + doff
+ dcnt
800 < smb_base(req
->inbuf
)))
802 if (state
->data
+ ddisp
< state
->data
)
805 memcpy(state
->data
+ddisp
, smb_base(req
->inbuf
)+doff
,
809 if ((state
->received_param
< state
->total_param
) ||
810 (state
->received_data
< state
->total_data
)) {
811 END_PROFILE(SMBtranss
);
815 /* construct_reply_common has done us the favor to pre-fill the
816 * command field with SMBtranss which is wrong :-)
818 SCVAL(req
->outbuf
,smb_com
,SMBtrans
);
820 handle_trans(conn
, req
, state
);
822 DLIST_REMOVE(conn
->pending_trans
, state
);
823 SAFE_FREE(state
->data
);
824 SAFE_FREE(state
->param
);
827 END_PROFILE(SMBtranss
);
832 DEBUG(0,("reply_transs: invalid trans parameters\n"));
833 DLIST_REMOVE(conn
->pending_trans
, state
);
834 SAFE_FREE(state
->data
);
835 SAFE_FREE(state
->param
);
837 reply_nterror(req
, NT_STATUS_INVALID_PARAMETER
);
838 END_PROFILE(SMBtranss
);