corrections to get data stream for 2nd and subsequent pdus copied from
authorLuke Leighton <lkcl@samba.org>
Wed, 3 Feb 1999 01:58:52 +0000 (01:58 +0000)
committerLuke Leighton <lkcl@samba.org>
Wed, 3 Feb 1999 01:58:52 +0000 (01:58 +0000)
right place (forgot to subtract 0x18 header bytes)

source/include/ntdomain.h
source/rpc_server/srv_pipe.c
source/rpc_server/srv_pipe_hnd.c

index 5eeeb1fd0e1f35a6d2b56723561d09e954c2884b..5592a59eaa240f5871bd645cff98194020af4c04 100644 (file)
@@ -101,7 +101,6 @@ typedef struct pipes_struct
        uint32 file_offset;
        uint32 prev_pdu_file_offset;
        uint32 hdr_offsets;
-       uint32 next_frag_start;
 
 } pipes_struct;
 
index 9e03188af5dc11515da2019fb43d46c52cc7a01f..f8d882cd0c85a6717b7c4e9f5a32e78878eb7913 100644 (file)
@@ -202,9 +202,6 @@ BOOL create_rpc_reply(pipes_struct *p,
                prs_link(&p->rhdr, &p->rdata_i, NULL       );
        }
 
-       /* indicate to subsequent data reads where we are up to */
-       p->next_frag_start = p->hdr.frag_len; 
-       
        return p->rhdr.data != NULL && p->rhdr.offset == 0x18;
 }
 
index e29e1ee8db7702524abd54ceb007cf6890672cfe..ca5dde18d25a07d8b2ed9661800feea59412245f 100644 (file)
@@ -135,7 +135,6 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name,
        p->file_offset     = 0;
        p->prev_pdu_file_offset = 0;
        p->hdr_offsets     = 0;
-       p->next_frag_start = 0;
        
        p->ntlmssp_validated = False;
        p->ntlmssp_auth      = False;
@@ -203,10 +202,11 @@ ssize_t write_pipe(pipes_struct *p, char *data, size_t n)
 int read_pipe(pipes_struct *p, char *data, uint32 pos, int n)
 {
        int num = 0;
-       int len = 0;
+       int pdu_len = 0;
        uint32 hdr_num = 0;
-       int data_hdr_pos;
-       int data_pos;
+       int pdu_data_sent; /* amount of current pdu already sent */
+       int data_pos; /* entire rpc data sent - no headers, no auth verifiers */
+       int this_pdu_data_pos;
 
        DEBUG(6,("read_pipe: %x", p->pnum));
 
@@ -230,37 +230,37 @@ int read_pipe(pipes_struct *p, char *data, uint32 pos, int n)
 
        DEBUG(6,("read_pipe: p: %p file_offset: %d file_pos: %d\n",
                 p, p->file_offset, n));
-       DEBUG(6,("read_pipe: next_frag_start: %d\n",
-                p->next_frag_start));
 
        /* the read request starts from where the SMBtrans2 left off. */
-       data_hdr_pos = p->file_offset - p->prev_pdu_file_offset;
-       data_pos     = data_hdr_pos - p->hdr_offsets;
+       data_pos = p->file_offset - p->hdr_offsets;
+       this_pdu_data_pos = data_pos - p->prev_pdu_file_offset;
+       pdu_data_sent = p->file_offset - p->prev_pdu_file_offset;
 
        if (!IS_BITS_SET_ALL(p->hdr.flags, RPC_FLG_LAST))
        {
                /* intermediate fragment - possibility of another header */
                
-               DEBUG(5,("read_pipe: frag_len: %d data_pos: %d data_hdr_pos: %d\n",
-                        p->hdr.frag_len, data_pos, data_hdr_pos));
+               DEBUG(5,("read_pipe: frag_len: %d data_pos: %d pdu_data_sent: %d\n",
+                        p->hdr.frag_len, data_pos, pdu_data_sent));
                
-               if (data_hdr_pos == 0)
+               if (pdu_data_sent == 0)
                {
                        DEBUG(6,("read_pipe: next fragment header\n"));
 
                        /* this is subtracted from the total data bytes, later */
                        hdr_num = 0x18;
                        p->hdr_offsets += 0x18;
+                       data_pos -= 0x18;
 
                        /* create and copy in a new header. */
-                       create_rpc_reply(p, p->file_offset - p->hdr_offsets, p->rdata.offset);
+                       create_rpc_reply(p, data_pos, p->rdata.offset);
                }                       
        }
        
-       len = mem_buf_len(p->rhdr.data);
-       num = len - (int)data_pos;
+       pdu_len = mem_buf_len(p->rhdr.data);
+       num = pdu_len - (int)this_pdu_data_pos;
        
-       DEBUG(6,("read_pipe: len: %d num: %d n: %d\n", len, num, n));
+       DEBUG(6,("read_pipe: pdu_len: %d num: %d n: %d\n", pdu_len, num, n));
        
        if (num > n) num = n;
        if (num <= 0)
@@ -274,17 +274,17 @@ int read_pipe(pipes_struct *p, char *data, uint32 pos, int n)
                DEBUG(5,("read_pipe: warning - data read only part of a header\n"));
        }
 
-       mem_buf_copy(data, p->rhdr.data, data_pos, num);
+       mem_buf_copy(data, p->rhdr.data, pdu_data_sent, num);
        
-       data_pos += num;
-       data_hdr_pos += num;
        p->file_offset  += num;
+       pdu_data_sent  += num;
        
        if (hdr_num == 0x18 && num == 0x18)
        {
                DEBUG(6,("read_pipe: just header read\n"));
        }
-       else if (data_hdr_pos == p->next_frag_start)
+
+       if (pdu_data_sent == p->hdr.frag_len)
        {
                DEBUG(6,("read_pipe: next fragment expected\n"));
                p->prev_pdu_file_offset = p->file_offset;