/*******************************************************************
reads or writes a DOM_SID structure.
********************************************************************/
-void smb_io_dom_sid(char *desc, DOM_SID *sid, prs_struct *ps, int depth)
+BOOL smb_io_dom_sid(char *desc, DOM_SID *sid, prs_struct *ps, int depth)
{
int i;
- if (sid == NULL) return;
+ if (sid == NULL) return False;
prs_debug(ps, depth, desc, "smb_io_dom_sid");
depth++;
if (sid->num_auths > MAXSUBAUTHS) sid->num_auths = MAXSUBAUTHS;
prs_uint32s(False, "sub_auths ", ps, depth, sid->sub_auths, sid->num_auths);
-}
-
-/*******************************************************************
-creates a DOM_SID structure.
-
-BIG NOTE: this function only does SIDS where the identauth is not >= 2^32
-identauth >= 2^32 can be detected because it will be specified in hex
-
-********************************************************************/
-void make_dom_sid(DOM_SID *sid, char *str_sid)
-{
- pstring domsid;
- int identauth;
- char *p;
-
- if (sid == NULL) return;
-
- if (domsid == NULL)
- {
- DEBUG(4,("netlogon domain SID: none\n"));
- sid->sid_rev_num = 0;
- sid->num_auths = 0;
- return;
- }
-
- pstrcpy(domsid, str_sid);
-
- DEBUG(4,("make_dom_sid %d SID: %s\n", __LINE__, domsid));
-
- /* assume, but should check, that domsid starts "S-" */
- p = strtok(domsid+2,"-");
- sid->sid_rev_num = atoi(p);
-
- /* identauth in decimal should be < 2^32 */
- /* identauth in hex should be >= 2^32 */
- identauth = atoi(strtok(0,"-"));
-
- DEBUG(4,("netlogon rev %d\n", sid->sid_rev_num));
- DEBUG(4,("netlogon %s ia %d\n", p, identauth));
- sid->id_auth[0] = 0;
- sid->id_auth[1] = 0;
- sid->id_auth[2] = (identauth & 0xff000000) >> 24;
- sid->id_auth[3] = (identauth & 0x00ff0000) >> 16;
- sid->id_auth[4] = (identauth & 0x0000ff00) >> 8;
- sid->id_auth[5] = (identauth & 0x000000ff);
-
- sid->num_auths = 0;
-
- while ((p = strtok(0, "-")) != NULL && sid->num_auths < MAXSUBAUTHS)
- {
- sid->sub_auths[sid->num_auths++] = atoi(p);
- }
-
- DEBUG(4,("make_dom_sid: %d SID: %s\n", __LINE__, domsid));
+ return True;
}
+
/*******************************************************************
creates a DOM_SID2 structure.
********************************************************************/
if (hdr->str_str_len > MAX_STRINGLEN) hdr->str_str_len = MAX_STRINGLEN;
}
+/*******************************************************************
+creates a STRHDR2 structure.
+********************************************************************/
+void make_strhdr2(STRHDR2 *hdr, uint32 max_len, uint32 len, uint32 buffer)
+{
+ hdr->str_max_len = max_len;
+ hdr->str_str_len = len;
+ hdr->buffer = buffer;
+}
+
+/*******************************************************************
+reads or writes a STRHDR2 structure.
+********************************************************************/
+void smb_io_strhdr2(char *desc, STRHDR2 *hdr, prs_struct *ps, int depth)
+{
+ if (hdr == NULL) return;
+
+ prs_debug(ps, depth, desc, "smb_io_strhdr");
+ depth++;
+
+ prs_align(ps);
+
+ prs_uint32("str_str_len", ps, depth, &(hdr->str_str_len));
+ prs_uint32("str_max_len", ps, depth, &(hdr->str_max_len));
+ prs_uint32("buffer ", ps, depth, &(hdr->buffer ));
+
+ /* oops! XXXX maybe issue a warning that this is happening... */
+ if (hdr->str_max_len > MAX_STRINGLEN) hdr->str_max_len = MAX_STRINGLEN;
+ if (hdr->str_str_len > MAX_STRINGLEN) hdr->str_str_len = MAX_STRINGLEN;
+}
+
/*******************************************************************
creates a UNIHDR structure.
********************************************************************/
hdr->buf_len = len;
}
+/*******************************************************************
+ prs_uint16 wrapper. call this and it sets up a pointer to where the
+ uint16 should be stored, or gets the size if reading
+ ********************************************************************/
+void smb_io_hdrbuf_pre(char *desc, BUFHDR *hdr, prs_struct *ps, int depth, uint32 *offset)
+{
+ (*offset) = ps->offset;
+ if (ps->io)
+ {
+ /* reading. */
+ smb_io_hdrbuf(desc, hdr, ps, depth);
+ }
+ else
+ {
+ ps->offset += sizeof(uint32) * 2;
+ }
+}
+
+/*******************************************************************
+ smb_io_hdrbuf wrapper. call this and it retrospectively stores the size.
+ does nothing on reading, as that is already handled by ...._pre()
+ ********************************************************************/
+void smb_io_hdrbuf_post(char *desc, BUFHDR *hdr, prs_struct *ps, int depth,
+ uint32 ptr_hdrbuf, uint32 max_len, uint32 len)
+{
+ if (!ps->io)
+ {
+ /* storing: go back and do a retrospective job. i hate this */
+ uint32 old_offset = ps->offset;
+
+ make_buf_hdr(hdr, max_len, len);
+ ps->offset = ptr_hdrbuf;
+ smb_io_hdrbuf(desc, hdr, ps, depth);
+ ps->offset = old_offset;
+ }
+}
/*******************************************************************
reads or writes a BUFHDR structure.
********************************************************************/
********************************************************************/
void make_unistr(UNISTR *str, char *buf)
{
- /* store the string (null-terminated copy) */
- struni2(str->buffer, buf);
+ ascii_to_unistr(str->buffer, buf, sizeof(str->buffer)-1);
}
/*******************************************************************
prs_debug(ps, depth, desc, "smb_io_unistr");
depth++;
- prs_align(ps);
prs_unistr("unistr", ps, depth, uni);
}
str->buf_max_len = len * 2;
str->buf_len = len * 2;
- /* store the string (null-terminated 8 bit chars into 16 bit chars) */
- struni2((uint16*)str->buffer, buf);
+ /* store the string (little endian buffer) */
+ ascii_to_unibuf(str->buffer, buf, str->buf_len);
}
/*******************************************************************
prs_align(ps);
- prs_uint32("uni_max_len", ps, depth, &(buf2->buf_max_len));
+ prs_uint32("buf_max_len", ps, depth, &(buf2->buf_max_len));
prs_uint32("undoc ", ps, depth, &(buf2->undoc ));
prs_uint32("buf_len ", ps, depth, &(buf2->buf_len));
/*******************************************************************
creates a UNISTR2 structure.
********************************************************************/
-void make_unistr2(UNISTR2 *str, char *buf, int len)
+void make_unistr2(UNISTR2 *str, const char *buf, int len)
{
ZERO_STRUCTP(str);
str->undoc = 0;
str->uni_str_len = len;
- /* store the string (null-terminated 8 bit chars into 16 bit chars) */
- struni2(str->buffer, buf);
+ /* store the string (wide chars) */
+ ascii_to_unistr(str->buffer, buf, len);
}
/*******************************************************************
/*******************************************************************
creates a DOM_RID2 structure.
********************************************************************/
-void make_dom_rid2(DOM_RID2 *rid2, uint32 rid, uint8 type)
+void make_dom_rid2(DOM_RID2 *rid2, uint32 rid, uint8 type, uint32 idx)
{
rid2->type = type;
- rid2->undoc = 0x5;
rid2->rid = rid;
- rid2->rid_idx = 0;
+ rid2->rid_idx = idx;
}
/*******************************************************************
prs_align(ps);
- /* should be value 5, so enforce it */
- rid2->type = 5;
-
- /* should be value 5, so enforce it */
- rid2->undoc = 5;
-
- prs_uint32("type ", ps, depth, &(rid2->type));
- prs_uint32("undoc ", ps, depth, &(rid2->undoc ));
+ prs_uint8("type ", ps, depth, &(rid2->type));
+ prs_align(ps);
prs_uint32("rid ", ps, depth, &(rid2->rid ));
prs_uint32("rid_idx", ps, depth, &(rid2->rid_idx ));
}
rid3->type1 = type;
rid3->ptr_type = 0x1; /* non-zero, basically. */
rid3->type2 = 0x1;
+ rid3->unk = type;
}
/*******************************************************************
prs_uint32("type1 ", ps, depth, &(rid3->type1 ));
prs_uint32("ptr_type", ps, depth, &(rid3->ptr_type));
prs_uint32("type2 ", ps, depth, &(rid3->type2 ));
+ prs_uint32("unk ", ps, depth, &(rid3->unk ));
}
/*******************************************************************
rid4->rid = rid;
}
-
/*******************************************************************
makes a DOM_CLNT_SRV structure.
********************************************************************/
/*******************************************************************
makes a DOM_LOG_INFO structure.
********************************************************************/
-void make_log_info(DOM_LOG_INFO *log, char *logon_srv, char *acct_name,
- uint16 sec_chan, char *comp_name)
+void make_log_info(DOM_LOG_INFO *log,
+ const char *logon_srv, const char *acct_name,
+ uint16 sec_chan, const char *comp_name)
{
if (log == NULL) return;
prs_unistr3(True, "unistr", name, ps, depth);
}
-