adding pack_type data representation. tested as-was (i.e. not against
authorLuke Leighton <lkcl@samba.org>
Mon, 28 Feb 2000 00:00:53 +0000 (00:00 +0000)
committerLuke Leighton <lkcl@samba.org>
Mon, 28 Feb 2000 00:00:53 +0000 (00:00 +0000)
a non-intel-byte-order m/c).

source/include/byteorder.h
source/include/lib_smb_proto.h
source/include/ntdomain.h
source/include/proto.h
source/include/rpc_dce.h
source/include/winbindd_proto.h
source/rpc_client/cli_pipe.c
source/rpc_parse/parse_prs.c
source/rpc_parse/parse_rpc.c
source/rpc_server/srv_pipe_srv.c

index a3b1437dc2569affa17ee3dc659faf986969e77a..8fff630a98e14b4993f1fe8d879b02b4cf58fbe8 100644 (file)
@@ -19,6 +19,9 @@
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
+#ifndef _BYTEORDER_H
+#define _BYTEORDER_H
+
 /*
    This file implements macros for machine independent short and 
    int manipulation
@@ -80,9 +83,12 @@ SSVALS(buf,pos,val) - signed version of SSVAL()
 SIVALS(buf,pos,val) - signed version of SIVAL()
 
 RSVAL(buf,pos) - like SVAL() but for NMB byte ordering
+RSVALS(buf,pos) - like SVALS() but for NMB byte ordering
 RIVAL(buf,pos) - like IVAL() but for NMB byte ordering
+RIVALS(buf,pos) - like IVALS() but for NMB byte ordering
 RSSVAL(buf,pos,val) - like SSVAL() but for NMB ordering
 RSIVAL(buf,pos,val) - like SIVAL() but for NMB ordering
+RSIVALS(buf,pos,val) - like SIVALS() but for NMB ordering
 
 it also defines lots of intermediate macros, just ignore those :-)
 
@@ -91,28 +97,28 @@ it also defines lots of intermediate macros, just ignore those :-)
 /* some switch macros that do both store and read to and from SMB buffers */
 
 #define RW_PCVAL(read,inbuf,outbuf,len) \
-                if (read) { PCVAL (inbuf,0,outbuf,len) } \
-                else      { PSCVAL(inbuf,0,outbuf,len) }
+       { if (read) { PCVAL (inbuf,0,outbuf,len); } \
+       else      { PSCVAL(inbuf,0,outbuf,len); } }
 
-#define RW_PIVAL(read,inbuf,outbuf,len) \
-                if (read) { PIVAL (inbuf,0,outbuf,len) } \
-                else      { PSIVAL(inbuf,0,outbuf,len) }
+#define RW_PIVAL(read,big_endian,inbuf,outbuf,len) \
+       { if (read) { if (big_endian) { RPIVAL(inbuf,0,outbuf,len); } else { PIVAL(inbuf,0,outbuf,len); } } \
+       else      { if (big_endian) { RPSIVAL(inbuf,0,outbuf,len); } else { PSIVAL(inbuf,0,outbuf,len); } } }
 
-#define RW_PSVAL(read,inbuf,outbuf,len) \
-                if (read) { PSVAL (inbuf,0,outbuf,len) } \
-                else      { PSSVAL(inbuf,0,outbuf,len) }
+#define RW_PSVAL(read,big_endian,inbuf,outbuf,len) \
+       { if (read) { if (big_endian) { RPSVAL(inbuf,0,outbuf,len); } else { PSVAL(inbuf,0,outbuf,len); } } \
+       else      { if (big_endian) { RPSSVAL(inbuf,0,outbuf,len); } else { PSSVAL(inbuf,0,outbuf,len); } } }
 
 #define RW_CVAL(read, inbuf, outbuf, offset) \
-                if (read) (outbuf) = CVAL (inbuf,offset); \
-                else                 SCVAL(inbuf,offset,outbuf);
+       { if (read) { (outbuf) = CVAL (inbuf,offset); } \
+       else      { SCVAL(inbuf,offset,outbuf); } }
 
-#define RW_IVAL(read, inbuf, outbuf, offset) \
-                if (read) (outbuf)= IVAL (inbuf,offset); \
-                else                SIVAL(inbuf,offset,outbuf);
+#define RW_IVAL(read, big_endian, inbuf, outbuf, offset) \
+       { if (read) { (outbuf) = ((big_endian) ? RIVAL(inbuf,offset) : IVAL (inbuf,offset)); } \
+       else      { if (big_endian) { RSIVAL(inbuf,offset,outbuf); } else { SIVAL(inbuf,offset,outbuf); } } }
 
-#define RW_SVAL(read, inbuf, outbuf, offset) \
-                if (read) (outbuf)= SVAL (inbuf,offset); \
-                else                SSVAL(inbuf,offset,outbuf);
+#define RW_SVAL(read, big_endian, inbuf, outbuf, offset) \
+       { if (read) { (outbuf) = ((big_endian) ? RSVAL(inbuf,offset) : SVAL (inbuf,offset)); } \
+       else      { if (big_endian) { RSSVAL(inbuf,offset,outbuf); } else { SSVAL(inbuf,offset,outbuf); } } }
 
 #undef CAREFUL_ALIGNMENT
 
@@ -144,7 +150,7 @@ it also defines lots of intermediate macros, just ignore those :-)
 #define SSVALS(buf,pos,val) SSVALX((buf),(pos),((int16)(val)))
 #define SIVALS(buf,pos,val) SIVALX((buf),(pos),((int32)(val)))
 
-#else
+#else /* CAREFUL_ALIGNMENT */
 
 /* this handles things for architectures like the 386 that can handle
    alignment errors */
@@ -159,19 +165,18 @@ it also defines lots of intermediate macros, just ignore those :-)
 #define SVALS(buf,pos) (*(const int16 *)((const char *)(buf) + (pos)))
 #define IVALS(buf,pos) (*(const int32 *)((const char *)(buf) + (pos)))
 
+/* store single value in an SMB buffer */
 #define SVALMOD(buf,pos) (*(uint16 *)((char *)(buf) + (pos)))
 #define IVALMOD(buf,pos) (*(uint32 *)((char *)(buf) + (pos)))
-#define SVALMODS(buf,pos) (*(int16 *)((char *)(buf) + (pos)))
-#define IVALMODS(buf,pos) (*(int32 *)((char *)(buf) + (pos)))
+#define SVALSMOD(buf,pos) (*(int16 *)((char *)(buf) + (pos)))
+#define IVALSMOD(buf,pos) (*(int32 *)((char *)(buf) + (pos)))
 
-/* store single value in an SMB buffer */
 #define SSVAL(buf,pos,val) SVALMOD(buf,pos)=((uint16)(val))
 #define SIVAL(buf,pos,val) IVALMOD(buf,pos)=((uint32)(val))
-#define SSVALS(buf,pos,val) SVALMODS(buf,pos)=((int16)(val))
-#define SIVALS(buf,pos,val) IVALMODS(buf,pos)=((int32)(val))
-
-#endif
+#define SSVALS(buf,pos,val) SVALSMOD(buf,pos)=((int16)(val))
+#define SIVALS(buf,pos,val) IVALSMOD(buf,pos)=((int32)(val))
 
+#endif /* CAREFUL_ALIGNMENT */
 
 /* macros for reading / writing arrays */
 
@@ -203,46 +208,63 @@ it also defines lots of intermediate macros, just ignore those :-)
 #define IREV(x) ((SREV(x)<<16) | (SREV((x)>>16)))
 
 #define RSVAL(buf,pos) SREV(SVAL(buf,pos))
+#define RSVALS(buf,pos) SREV(SVALS(buf,pos))
 #define RIVAL(buf,pos) IREV(IVAL(buf,pos))
+#define RIVALS(buf,pos) IREV(IVALS(buf,pos))
 #define RSSVAL(buf,pos,val) SSVAL(buf,pos,SREV(val))
+#define RSSVALS(buf,pos,val) SSVALS(buf,pos,SREV(val))
 #define RSIVAL(buf,pos,val) SIVAL(buf,pos,IREV(val))
+#define RSIVALS(buf,pos,val) SIVALS(buf,pos,IREV(val))
+
+/* reads multiple data from an SMB buffer (big-endian) */
+#define RPSVAL(buf,pos,val,len) SMBMACRO(RSVAL,buf,pos,val,len,2)
+#define RPIVAL(buf,pos,val,len) SMBMACRO(RIVAL,buf,pos,val,len,4)
+#define RPSVALS(buf,pos,val,len) SMBMACRO(RSVALS,buf,pos,val,len,2)
+#define RPIVALS(buf,pos,val,len) SMBMACRO(RIVALS,buf,pos,val,len,4)
+
+/* stores multiple data in an SMB buffer (big-endian) */
+#define RPSSVAL(buf,pos,val,len) SSMBMACRO(RSSVAL,buf,pos,val,len,2)
+#define RPSIVAL(buf,pos,val,len) SSMBMACRO(RSIVAL,buf,pos,val,len,4)
+#define RPSSVALS(buf,pos,val,len) SSMBMACRO(RSSVALS,buf,pos,val,len,2)
+#define RPSIVALS(buf,pos,val,len) SSMBMACRO(RSIVALS,buf,pos,val,len,4)
 
 #define DBG_RW_PCVAL(charmode,string,depth,base,read,inbuf,outbuf,len) \
-       RW_PCVAL(read,inbuf,outbuf,len) \
-       DEBUG(10,("%s%04x %s: ", \
+       RW_PCVAL(read,inbuf,outbuf,len) \
+       DEBUG(5,("%s%04x %s: ", \
              tab_depth(depth), base,string)); \
-    if (charmode) print_asc(10, (unsigned char*)(outbuf), (len)); else \
-       { uint32 idx; for (idx = 0; idx < (uint32)(len); idx++) { DEBUGADD(10,("%02x ", (outbuf)[idx])); } } \
-       DEBUG(10,("\n"));
+    if (charmode) print_asc(5, (unsigned char*)(outbuf), (len)); else \
+       { uint32 idx; for (idx = 0; idx < len; idx++) { DEBUG(5,("%02x ", (outbuf)[idx])); } } \
+       DEBUG(5,("\n")); } 
 
-#define DBG_RW_PSVAL(charmode,string,depth,base,read,inbuf,outbuf,len) \
-       RW_PSVAL(read,inbuf,outbuf,len) \
-       DEBUG(10,("%s%04x %s: ", \
+#define DBG_RW_PSVAL(charmode,string,depth,base,read,big_endian,inbuf,outbuf,len) \
+       { RW_PSVAL(read,big_endian,inbuf,outbuf,len) \
+       DEBUG(5,("%s%04x %s: ", \
              tab_depth(depth), base,string)); \
-    if (charmode) print_asc(10, (unsigned char*)(outbuf), 2*(len)); else \
-       { uint32 idx; for (idx = 0; idx < (uint32)(len); idx++) { DEBUGADD(10,("%04x ", (outbuf)[idx])); } } \
-       DEBUG(10,("\n"));
+    if (charmode) print_asc(5, (unsigned char*)(outbuf), 2*(len)); else \
+       { uint32 idx; for (idx = 0; idx < len; idx++) { DEBUG(5,("%04x ", (outbuf)[idx])); } } \
+       DEBUG(5,("\n")); }
 
-#define DBG_RW_PIVAL(charmode,string,depth,base,read,inbuf,outbuf,len) \
-       RW_PIVAL(read,inbuf,outbuf,len) \
-       DEBUG(10,("%s%04x %s: ", \
+#define DBG_RW_PIVAL(charmode,string,depth,base,read,big_endian,inbuf,outbuf,len) \
+       { RW_PIVAL(read,big_endian,inbuf,outbuf,len) \
+       DEBUG(5,("%s%04x %s: ", \
              tab_depth(depth), base,string)); \
-    if (charmode) print_asc(10, (unsigned char*)(outbuf), 4*(len)); else \
-       { uint32 idx; for (idx = 0; idx < (uint32)(len); idx++) { DEBUGADD(10,("%08x ", (outbuf)[idx])); } } \
-       DEBUG(10,("\n"));
+    if (charmode) print_asc(5, (unsigned char*)(outbuf), 4*(len)); else \
+       { uint32 idx; for (idx = 0; idx < len; idx++) { DEBUG(5,("%08x ", (outbuf)[idx])); } } \
+       DEBUG(5,("\n")); }
 
 #define DBG_RW_CVAL(string,depth,base,read,inbuf,outbuf) \
-       RW_CVAL(read,inbuf,outbuf,0) \
-       DEBUG(10,("%s%04x %s: %02x\n", \
-             tab_depth(depth), base, string, outbuf));
+       RW_CVAL(read,inbuf,outbuf,0) \
+       DEBUG(5,("%s%04x %s: %02x\n", \
+             tab_depth(depth), base, string, outbuf)); }
 
-#define DBG_RW_SVAL(string,depth,base,read,inbuf,outbuf) \
-       RW_SVAL(read,inbuf,outbuf,0) \
-       DEBUG(10,("%s%04x %s: %04x\n", \
-             tab_depth(depth), base, string, outbuf));
+#define DBG_RW_SVAL(string,depth,base,read,big_endian,inbuf,outbuf) \
+       { RW_SVAL(read,big_endian,inbuf,outbuf,0) \
+       DEBUG(5,("%s%04x %s: %04x\n", \
+             tab_depth(depth), base, string, outbuf)); }
 
-#define DBG_RW_IVAL(string,depth,base,read,inbuf,outbuf) \
-       RW_IVAL(read,inbuf,outbuf,0) \
-       DEBUG(10,("%s%04x %s: %08x\n", \
-             tab_depth(depth), base, string, outbuf));
+#define DBG_RW_IVAL(string,depth,base,read,big_endian,inbuf,outbuf) \
+       { RW_IVAL(read,big_endian,inbuf,outbuf,0) \
+       DEBUG(5,("%s%04x %s: %08x\n", \
+             tab_depth(depth), base, string, outbuf)); }
 
+#endif /* _BYTEORDER_H */
index b343266106fd339fca1d1ec0419f5cde2da6fc7f..2a19b45afa786301183a04c5996d9834b7e12657 100644 (file)
@@ -625,6 +625,7 @@ BOOL smb_io_rpc_auth_ntlmssp_chk(char *desc, RPC_AUTH_NTLMSSP_CHK *chk, prs_stru
 void prs_debug(prs_struct *ps, int depth, const char *desc, const char *fn_name);
 void prs_debug_out(const prs_struct *ps, char *msg, int level);
 void prs_init(prs_struct *ps, uint32 size, uint8 align,  BOOL io);
+void prs_set_packtype(prs_struct *ps, const uint8 *pack_type);
 void prs_create(prs_struct *ps, char *data, uint32 size, uint8 align, BOOL io);
 BOOL prs_copy(prs_struct *ps, const prs_struct *from);
 BOOL prs_alloc_data(prs_struct *buf, int size);
index 4fb0e7c8dbd9d3e03d6a949b053575e415994c5e..7925ab50ae83bfc51d9397d0c9c5c24562f238dc 100644 (file)
@@ -82,6 +82,7 @@ typedef struct parse_struct
        uint8 align;            /* data alignment */
        BOOL io;                /* parsing in or out of data stream */
        BOOL error;             /* error occurred while parsing (out of memory bounds) */
+       BOOL bigendian;         /* big-endian data */
 
        struct parse_struct *next;
 
index fe33b910d47af10250db3e6aa72608bc85ff6f9f..5dde2fb45a201388ed54227ad062ec3a66b26c74 100644 (file)
@@ -3147,6 +3147,7 @@ BOOL smb_io_rpc_auth_ntlmssp_chk(char *desc, RPC_AUTH_NTLMSSP_CHK *chk, prs_stru
 void prs_debug(prs_struct *ps, int depth, const char *desc, const char *fn_name);
 void prs_debug_out(const prs_struct *ps, char *msg, int level);
 void prs_init(prs_struct *ps, uint32 size, uint8 align,  BOOL io);
+void prs_set_packtype(prs_struct *ps, const uint8 *pack_type);
 void prs_create(prs_struct *ps, char *data, uint32 size, uint8 align, BOOL io);
 BOOL prs_copy(prs_struct *ps, const prs_struct *from);
 BOOL prs_alloc_data(prs_struct *buf, int size);
index d8a43f266973393db6acbf50ce406a5f9afdea29..2f996efd3e8135f84f236701f29dd33324d8d10a 100644 (file)
@@ -71,7 +71,7 @@ typedef struct rpc_hdr_info
   uint8  minor; /* 0 - RPC minor version */
   uint8  pkt_type; /* RPC_PKT_TYPE - RPC response packet */
   uint8  flags; /* DCE/RPC flags */
-  uint32 pack_type; /* 0x1000 0000 - packed data representation */
+  uint8  pack_type[4]; /* 0x10 00 00 00 - packed data representation */
   uint16 frag_len; /* fragment length - data size (bytes) inc header and tail. */
   uint16 auth_len; /* 0 - authentication length  */
   uint32 call_id; /* call identifier.  matches 12th uint32 of incoming RPC data. */
index 82e397e6e6abfd5e50a1d9b58b1364083c8d3ebe..0ad5fd1746b5deb47f9499296f1ea60d19963af6 100644 (file)
@@ -2056,6 +2056,7 @@ BOOL smb_io_rpc_auth_ntlmssp_chk(char *desc, RPC_AUTH_NTLMSSP_CHK *chk, prs_stru
 void prs_debug(prs_struct *ps, int depth, const char *desc, const char *fn_name);
 void prs_debug_out(const prs_struct *ps, char *msg, int level);
 void prs_init(prs_struct *ps, uint32 size, uint8 align,  BOOL io);
+void prs_set_packtype(prs_struct *ps, const uint8 *pack_type);
 void prs_create(prs_struct *ps, char *data, uint32 size, uint8 align, BOOL io);
 BOOL prs_copy(prs_struct *ps, const prs_struct *from);
 BOOL prs_alloc_data(prs_struct *buf, int size);
index ba4fdfc602a0b9b304b0475ab0bf9d235adeb6aa..c1fedbdf149c47f4b259dfd95e69e134b2d14076 100644 (file)
@@ -220,6 +220,8 @@ static BOOL rpc_api_pipe_bind(struct cli_connection *con, prs_struct * data,
                return False;
        }
 
+       prs_set_packtype(rdata, rhdr.pack_type);
+
        if (rhdr.pkt_type != RPC_BINDACK)
        {
                return False;
@@ -232,30 +234,9 @@ static BOOL rpc_api_pipe_bind(struct cli_connection *con, prs_struct * data,
                last = True;
        }
 
-#if 0
-       if (rhdr.auth_len != 0)
-       {
-               cli_auth_fns *auth = cli_conn_get_authfns(con);
-               DEBUG(10,
-                     ("rpc_api_pipe_bind: auth_len: %d\n", rhdr.auth_len));
-               if (auth->cli_decode_pdu == NULL)
-               {
-                       return False;
-               }
-               if (!auth->cli_decode_pdu
-                   (con, &rpdu, rhdr.frag_len, rhdr.auth_len))
-               {
-                       return False;
-               }
-       }
-#endif
-
-       {
-               prs_append_data(rdata,
-                               prs_data(&rpdu, rpdu.offset),
+       prs_append_data(rdata, prs_data(&rpdu, rpdu.offset),
                                rhdr.frag_len - rpdu.offset);
-               prs_free_data(&rpdu);
-       }
+       prs_free_data(&rpdu);
 
        /* only one rpc fragment, and it has been read */
        if (!first || !last)
@@ -360,6 +341,8 @@ BOOL rpc_api_pipe_req(struct cli_connection *con, uint8 opnum,
                return False;
        }
 
+       prs_set_packtype(rdata, rhdr.pack_type);
+
        if (rhdr.pkt_type == RPC_BINDACK)
        {
                if (!last && !first)
@@ -574,6 +557,8 @@ BOOL cli_send_and_rcv_pdu_trans(struct cli_connection *con,
                return False;
        }
 
+       prs_set_packtype(rdata, rhdr.pack_type);
+
        if (rhdr.pkt_type == RPC_BINDACK)
        {
                if (!last && !first)
@@ -683,6 +668,8 @@ BOOL cli_send_and_rcv_pdu_rw(struct cli_connection *con,
                return False;
        }
 
+       prs_set_packtype(rdata, rhdr.pack_type);
+
        if (rhdr.pkt_type == RPC_BINDACK)
        {
                if (!last && !first)
@@ -769,6 +756,8 @@ BOOL cli_rcv_pdu(struct cli_connection *con,
                return False;
        }
 
+       prs_set_packtype(rdata, rhdr.pack_type);
+
        smb_io_rpc_hdr_resp("rpc_hdr_resp", &rhdr_resp, rdata, 0);
 
        if (!rpc_read(cli, fnum, rdata, len, rdata->data_size, False))
index 156fc27c3dfcca1dfa3ede00892e6a1b80227cf8..49481f7f2e7bc313f357317c6060786b7ee64336 100644 (file)
@@ -60,16 +60,18 @@ void prs_init(prs_struct *ps, uint32 size, uint8 align,  BOOL io)
        ps->align = align;
        ps->offset = 0;
        ps->error = False;
+       ps->bigendian = False;
 
        ps->data = NULL;
        ps->data_size = 0;
-       ps->struct_end = 0xdcdcdcdc;
 
        ps->start = 0;
        ps->end   = 0;
 
        ps->next = NULL;
 
+       ps->struct_end = 0xdcdcdcdc;
+
        if (size != 0)
        {
                prs_realloc_data(ps, size);
@@ -79,6 +81,15 @@ void prs_init(prs_struct *ps, uint32 size, uint8 align,  BOOL io)
        CHECK_STRUCT(ps);
 }
 
+/*******************************************************************
+ set the packed data representation type in a parse structure
+ ********************************************************************/
+void prs_set_packtype(prs_struct *ps, const uint8 *pack_type)
+{
+       CHECK_STRUCT(ps);
+       ps->bigendian = pack_type[0] == 0x0;
+}
+
 /*******************************************************************
  create a parse structure
  ********************************************************************/
@@ -104,6 +115,7 @@ BOOL prs_copy(prs_struct *ps, const prs_struct *from)
        CHECK_STRUCT(ps);
        CHECK_STRUCT(from);
        prs_init(ps, len, from->align, from->io);
+       ps->bigendian = from->bigendian;
        if (len != 0)
        {
                if (ps->data == NULL)
@@ -560,7 +572,7 @@ BOOL _prs_uint16(char *name, prs_struct *ps, int depth, uint16 *data16)
                return False;
        }
 
-       DBG_RW_SVAL(name, depth, ps->offset, ps->io, q, *data16)
+       DBG_RW_SVAL(name, depth, ps->offset, ps->io, ps->bigendian, q, *data16)
        ps->offset += 2;
 
        return True;
@@ -614,7 +626,7 @@ BOOL _prs_uint32(char *name, prs_struct *ps, int depth, uint32 *data32)
                return False;
        }
 
-       DBG_RW_IVAL(name, depth, ps->offset, ps->io, q, *data32)
+       DBG_RW_IVAL(name, depth, ps->offset, ps->io, ps->bigendian, q, *data32)
        ps->offset += 4;
 
        return True;
@@ -683,7 +695,7 @@ BOOL _prs_uint16s(BOOL charmode, char *name, prs_struct *ps, int depth, uint16 *
                return False;
        }
 
-       DBG_RW_PSVAL(charmode, name, depth, ps->offset, ps->io, q, data16s, len)
+       DBG_RW_PSVAL(charmode, name, depth, ps->offset, ps->io, ps->bigendian, q, data16s, len)
        ps->offset = end_offset;
 
        return True;
@@ -717,7 +729,7 @@ BOOL _prs_uint32s(BOOL charmode, char *name, prs_struct *ps, int depth, uint32 *
                return False;
        }
 
-       DBG_RW_PIVAL(charmode, name, depth, ps->offset, ps->io, q, data32s, len)
+       DBG_RW_PIVAL(charmode, name, depth, ps->offset, ps->io, ps->bigendian, q, data32s, len)
        ps->offset = end_offset;
 
        return True;
@@ -822,7 +834,7 @@ BOOL _prs_unistr2(BOOL charmode, char *name, prs_struct *ps, int depth, UNISTR2
                return False;
        }
 
-       DBG_RW_PSVAL(charmode, name, depth, ps->offset, ps->io, q, str->buffer, str->uni_str_len)
+       DBG_RW_PSVAL(charmode, name, depth, ps->offset, ps->io, ps->bigendian, q, str->buffer, str->uni_str_len)
        ps->offset = end_offset;
 
        return True;
@@ -857,7 +869,7 @@ BOOL _prs_unistr3(BOOL charmode, char *name, UNISTR3 *str, prs_struct *ps, int d
                return False;
        }
 
-       DBG_RW_PSVAL(charmode, name, depth, ps->offset, ps->io, q, str->str.buffer, str->uni_str_len)
+       DBG_RW_PSVAL(charmode, name, depth, ps->offset, ps->io, ps->bigendian, q, str->str.buffer, str->uni_str_len)
        ps->offset = end_offset;
 
        return True;
@@ -886,7 +898,7 @@ BOOL _prs_unistr(char *name, prs_struct *ps, int depth, UNISTR *str)
                        prs_debug_out(ps, "_prs_unistr error", 5);
                        return False;
                }
-               RW_SVAL(ps->io, q, str->buffer[i],0);
+               RW_SVAL(ps->io, ps->bigendian, q, str->buffer[i],0);
        }
        while ((((size_t)i) < sizeof(str->buffer) / sizeof(str->buffer[0])) &&
                     (str->buffer[i] != 0));
index f4782d24ba94ca94f69a073098704db7fa0bb869..18ba14a0630d24337f32e2a1b7627827c0cfa808 100644 (file)
@@ -202,7 +202,10 @@ BOOL make_rpc_hdr(RPC_HDR *hdr, enum RPC_PKT_TYPE pkt_type, uint8 flags,
        hdr->minor        = 0;               /* minor version 0 */
        hdr->pkt_type     = pkt_type;        /* RPC packet type */
        hdr->flags        = flags;           /* dce/rpc flags */
-       hdr->pack_type    = 0x10;            /* packed data representation */
+       hdr->pack_type[0] = 0x10;            /* packed data - intel-endian */
+       hdr->pack_type[1] = 0x0;             /* packed data representation */
+       hdr->pack_type[2] = 0x0;             /* packed data representation */
+       hdr->pack_type[3] = 0x0;             /* packed data representation */
        hdr->frag_len     = data_len;        /* fragment length, fill in later */
        hdr->auth_len     = auth_len;        /* authentication length */
        hdr->call_id      = call_id;         /* call identifier - match incoming RPC */
@@ -220,14 +223,21 @@ BOOL smb_io_rpc_hdr(char *desc,  RPC_HDR *rpc, prs_struct *ps, int depth)
        prs_debug(ps, depth, desc, "smb_io_rpc_hdr");
        depth++;
 
-       prs_uint8 ("major     ", ps, depth, &(rpc->major));
-       prs_uint8 ("minor     ", ps, depth, &(rpc->minor));
-       prs_uint8 ("pkt_type  ", ps, depth, &(rpc->pkt_type));
-       prs_uint8 ("flags     ", ps, depth, &(rpc->flags));
-       prs_uint32("pack_type ", ps, depth, &(rpc->pack_type));
-       prs_uint16("frag_len  ", ps, depth, &(rpc->frag_len));
-       prs_uint16("auth_len  ", ps, depth, &(rpc->auth_len));
-       prs_uint32("call_id   ", ps, depth, &(rpc->call_id));
+       prs_uint8 ("major     ", ps, depth, &rpc->major);
+       prs_uint8 ("minor     ", ps, depth, &rpc->minor);
+       prs_uint8 ("pkt_type  ", ps, depth, &rpc->pkt_type);
+       prs_uint8 ("flags     ", ps, depth, &rpc->flags);
+       prs_uint8s(False, "pack_type ", ps, depth, rpc->pack_type,
+                                                  sizeof(rpc->pack_type));
+       if (ps->io)
+       {
+               /* reading - set packed data representation type */
+               prs_set_packtype(ps, rpc->pack_type);
+       }
+
+       prs_uint16("frag_len  ", ps, depth, &rpc->frag_len);
+       prs_uint16("auth_len  ", ps, depth, &rpc->auth_len);
+       prs_uint32("call_id   ", ps, depth, &rpc->call_id);
 
        return True;
 }
index 35bd79dc6e86539aca545eecb25a29e131d865e8..a2340e5c04d6ff0249b737eae4a0fb33ffd234d0 100644 (file)
@@ -515,6 +515,7 @@ static BOOL rpc_redir_local(rpcsrv_struct * l, prs_struct * req,
        if (first)
        {
                prs_init(&l->data_i, 0, 4, True);
+               prs_set_packtype(&l->data_i, l->hdr.pack_type);
        }
        if (last)
        {