summaryrefslogtreecommitdiff
path: root/source3/rpc_parse
diff options
context:
space:
mode:
Diffstat (limited to 'source3/rpc_parse')
-rw-r--r--source3/rpc_parse/parse_prs.c57
-rw-r--r--source3/rpc_parse/parse_reg.c16
-rw-r--r--source3/rpc_parse/parse_sec.c72
3 files changed, 104 insertions, 41 deletions
diff --git a/source3/rpc_parse/parse_prs.c b/source3/rpc_parse/parse_prs.c
index 873a689792..cc068778ac 100644
--- a/source3/rpc_parse/parse_prs.c
+++ b/source3/rpc_parse/parse_prs.c
@@ -303,14 +303,18 @@ BOOL prs_string(char *name, prs_struct *ps, int depth, char *str, uint16 len, ui
prs_uint16 wrapper. call this and it sets up a pointer to where the
uint16 should be stored, or gets the size if reading
********************************************************************/
-BOOL prs_uint16_pre(char *name, prs_struct *ps, int depth, uint16 *data16, uint32 *off_ptr)
+BOOL prs_uint16_pre(char *name, prs_struct *ps, int depth, uint16 *data16, uint32 *offset)
{
- (*off_ptr) = ps->offset;
+ (*offset) = ps->io;
if (ps->io)
{
/* reading. */
return prs_uint16(name, ps, depth, data16);
}
+ else
+ {
+ ps->offset += sizeof(uint16);
+ }
return True;
}
@@ -318,7 +322,7 @@ BOOL prs_uint16_pre(char *name, prs_struct *ps, int depth, uint16 *data16, uint3
prs_uint16 wrapper. call this and it retrospectively stores the size.
does nothing on reading, as that is already handled by ...._pre()
********************************************************************/
-BOOL prs_uint16_post(char *name, prs_struct *ps, int depth,
+BOOL prs_uint16_post(char *name, prs_struct *ps, int depth, uint16 *data16,
uint32 ptr_uint16, uint32 start_offset)
{
if (!ps->io)
@@ -331,6 +335,53 @@ BOOL prs_uint16_post(char *name, prs_struct *ps, int depth,
prs_uint16(name, ps, depth, &data_size);
ps->offset = old_offset;
}
+ else
+ {
+ ps->offset = start_offset + (*data16);
+ }
+ return True;
+}
+
+/*******************************************************************
+ prs_uint32 wrapper. call this and it sets up a pointer to where the
+ uint32 should be stored, or gets the size if reading
+ ********************************************************************/
+BOOL prs_uint32_pre(char *name, prs_struct *ps, int depth, uint32 *data32, uint32 *offset)
+{
+ (*offset) = ps->io;
+ if (ps->io)
+ {
+ /* reading. */
+ return prs_uint32(name, ps, depth, data32);
+ }
+ else
+ {
+ ps->offset += sizeof(uint32);
+ }
+ return True;
+}
+
+/*******************************************************************
+ prs_uint32 wrapper. call this and it retrospectively stores the size.
+ does nothing on reading, as that is already handled by ...._pre()
+ ********************************************************************/
+BOOL prs_uint32_post(char *name, prs_struct *ps, int depth, uint32 *data32,
+ uint32 ptr_uint32, uint32 start_offset)
+{
+ if (!ps->io)
+ {
+ /* storing: go back and do a retrospective job. i hate this */
+ uint32 data_size = ps->offset - start_offset;
+ uint32 old_offset = ps->offset;
+
+ ps->offset = ptr_uint32;
+ prs_uint32(name, ps, depth, &data_size);
+ ps->offset = old_offset;
+ }
+ else
+ {
+ ps->offset = start_offset + (*data32);
+ }
return True;
}
diff --git a/source3/rpc_parse/parse_reg.c b/source3/rpc_parse/parse_reg.c
index fa63717e5b..b650847b80 100644
--- a/source3/rpc_parse/parse_reg.c
+++ b/source3/rpc_parse/parse_reg.c
@@ -553,11 +553,17 @@ void make_reg_q_get_key_sec(REG_Q_GET_KEY_SEC *q_i, POLICY_HND *pol,
q_i->unknown = 0x7;
- q_i->ptr = 1;
+ q_i->ptr = sec_buf != NULL ? 1 : 0;
q_i->data = sec_buf;
- make_buf_hdr(&(q_i->hdr_sec), buf_len, 0);
- make_sec_desc_buf(q_i->data, buf_len, 0);
+ if (sec_buf != NULL)
+ {
+ make_buf_hdr(&(q_i->hdr_sec), buf_len, 0);
+ q_i->data->max_len = buf_len;
+ q_i->data->undoc = 0;
+ q_i->data->len = 0;
+ q_i->data->sec = NULL;
+ }
}
/*******************************************************************
@@ -586,10 +592,11 @@ void reg_io_q_get_key_sec(char *desc, REG_Q_GET_KEY_SEC *r_q, prs_struct *ps, i
}
}
+#if 0
/*******************************************************************
makes a structure.
********************************************************************/
-void make_reg_r_get_key_sec(REG_R_GET_KEY_SEC *r_i, POLICY_HND *pol,
+ void make_reg_r_get_key_sec(REG_R_GET_KEY_SEC *r_i, POLICY_HND *pol,
uint32 buf_len, uint8 *buf,
uint32 status)
{
@@ -601,6 +608,7 @@ void make_reg_r_get_key_sec(REG_R_GET_KEY_SEC *r_i, POLICY_HND *pol,
r_i->status = status; /* 0x0000 0000 or 0x0000 007a */
}
+#endif
/*******************************************************************
reads or writes a structure.
diff --git a/source3/rpc_parse/parse_sec.c b/source3/rpc_parse/parse_sec.c
index bedf042b7f..af5da93bfb 100644
--- a/source3/rpc_parse/parse_sec.c
+++ b/source3/rpc_parse/parse_sec.c
@@ -66,11 +66,7 @@ void sec_io_ace(char *desc, SEC_ACE *t, prs_struct *ps, int depth)
prs_align(ps);
smb_io_dom_sid("sid ", &t->sid , ps, depth);
- prs_uint16_post("ace_size ", ps, depth, offset_ace_size, old_offset);
- if (ps->io)
- {
- ps->offset = old_offset + t->ace_size;
- }
+ prs_uint16_post("ace_size ", ps, depth, &t->ace_size, offset_ace_size, old_offset);
}
/*******************************************************************
@@ -105,11 +101,7 @@ void sec_io_acl(char *desc, SEC_ACL *t, prs_struct *ps, int depth)
prs_align(ps);
- prs_uint16_post("acl_size ", ps, depth, offset_acl_size, old_offset);
- if (ps->io)
- {
- ps->offset = old_offset + t->acl_size;
- }
+ prs_uint16_post("acl_size ", ps, depth, &t->acl_size, offset_acl_size, old_offset);
}
@@ -118,6 +110,12 @@ reads or writes a structure.
********************************************************************/
void sec_io_desc(char *desc, SEC_DESC *t, prs_struct *ps, int depth)
{
+ uint32 off_owner_sid;
+ uint32 off_pnt_sid ;
+ uint32 off_unknown ;
+ uint32 off_acl ;
+ uint32 old_offset;
+
if (t == NULL) return;
prs_debug(ps, depth, desc, "sec_io_desc");
@@ -125,39 +123,39 @@ void sec_io_desc(char *desc, SEC_DESC *t, prs_struct *ps, int depth)
prs_align(ps);
- prs_uint16("unknown_1", ps, depth, &(t->unknown_1));
- prs_uint16("unknown_2", ps, depth, &(t->unknown_2));
+ /* start of security descriptor stored for back-calc offset purposes */
+ old_offset = ps->offset;
+
+ prs_uint32("unknown_1", ps, depth, &(t->unknown_1));
- prs_uint32("off_owner_sid", ps, depth, &(t->off_owner_sid));
- prs_uint32("off_pnt_sid ", ps, depth, &(t->off_pnt_sid ));
- prs_uint32("off_unknown ", ps, depth, &(t->off_unknown ));
- prs_uint32("off_acl ", ps, depth, &(t->off_acl ));
+ prs_uint32_pre("off_owner_sid", ps, depth, &(t->off_owner_sid), &off_owner_sid);
+ prs_uint32_pre("off_pnt_sid ", ps, depth, &(t->off_pnt_sid ), &off_pnt_sid );
+ prs_uint32_pre("off_unknown ", ps, depth, &(t->off_unknown ), &off_unknown );
+ prs_uint32_pre("off_acl ", ps, depth, &(t->off_acl ), &off_acl );
+ prs_uint32_post("off_acl ", ps, depth, &(t->off_acl ), off_acl , old_offset);
sec_io_acl ("acl" , &t->acl , ps, depth);
+ prs_align(ps);
+
+ prs_uint32_post("off_unknown ", ps, depth, &(t->off_unknown ), off_unknown , ps->offset);
+
+ prs_uint32_post("off_owner_sid", ps, depth, &(t->off_owner_sid), off_owner_sid, old_offset);
smb_io_dom_sid("owner_sid ", &t->owner_sid , ps, depth);
prs_align(ps);
+
+ prs_uint32_post("off_pnt_sid ", ps, depth, &(t->off_pnt_sid ), off_pnt_sid , old_offset);
smb_io_dom_sid("parent_sid", &t->parent_sid, ps, depth);
prs_align(ps);
}
/*******************************************************************
-creates a SEC_DESC_BUF structure.
-********************************************************************/
-void make_sec_desc_buf(SEC_DESC_BUF *buf, int len, uint32 buf_ptr)
-{
- ZERO_STRUCTP(buf);
-
- /* max buffer size (allocated size) */
- buf->max_len = len;
- buf->undoc = 0;
- buf->len = buf_ptr != 0 ? len : 0;
-}
-
-/*******************************************************************
reads or writes a SEC_DESC_BUF structure.
********************************************************************/
void sec_io_desc_buf(char *desc, SEC_DESC_BUF *sec, prs_struct *ps, int depth)
{
+ uint32 off_len;
+ uint32 old_offset;
+
if (sec == NULL) return;
prs_debug(ps, depth, desc, "sec_io_desc_buf");
@@ -165,12 +163,18 @@ void sec_io_desc_buf(char *desc, SEC_DESC_BUF *sec, prs_struct *ps, int depth)
prs_align(ps);
- prs_uint32("max_len", ps, depth, &(sec->max_len));
- prs_uint32("undoc ", ps, depth, &(sec->undoc ));
- prs_uint32("len ", ps, depth, &(sec->len ));
+ prs_uint32 ("max_len", ps, depth, &(sec->max_len));
+ prs_uint32 ("undoc ", ps, depth, &(sec->undoc ));
+ prs_uint32_pre("len ", ps, depth, &(sec->len ), &off_len);
+
+ old_offset = ps->offset;
- if (sec->len != 0)
+ /* reading, length is non-zero; writing, descriptor is non-NULL */
+ if ((sec->len != 0 || (!ps->io)) && sec->sec != NULL)
{
- sec_io_desc("sec ", &sec->sec, ps, depth);
+ sec_io_desc("sec ", sec->sec, ps, depth);
}
+
+ prs_uint32_post("len ", ps, depth, &(sec->len ), off_len , old_offset);
}
+