summaryrefslogtreecommitdiff
path: root/source3/rpc_parse
diff options
context:
space:
mode:
Diffstat (limited to 'source3/rpc_parse')
-rw-r--r--source3/rpc_parse/parse_dfs.c20
-rw-r--r--source3/rpc_parse/parse_ds.c6
-rw-r--r--source3/rpc_parse/parse_lsa.c39
-rw-r--r--source3/rpc_parse/parse_misc.c98
-rw-r--r--source3/rpc_parse/parse_net.c108
-rw-r--r--source3/rpc_parse/parse_reg.c64
-rw-r--r--source3/rpc_parse/parse_samr.c416
-rw-r--r--source3/rpc_parse/parse_spoolss.c79
-rw-r--r--source3/rpc_parse/parse_srv.c74
9 files changed, 367 insertions, 537 deletions
diff --git a/source3/rpc_parse/parse_dfs.c b/source3/rpc_parse/parse_dfs.c
index 6f13500359..0d0ce557b2 100644
--- a/source3/rpc_parse/parse_dfs.c
+++ b/source3/rpc_parse/parse_dfs.c
@@ -80,9 +80,9 @@ BOOL init_dfs_q_dfs_remove(DFS_Q_DFS_REMOVE *q_d, const char *entrypath,
const char *servername, const char *sharename)
{
DEBUG(5,("init_dfs_q_dfs_remove\n"));
- init_unistr2(&q_d->DfsEntryPath, entrypath, strlen(entrypath)+1);
- init_unistr2(&q_d->ServerName, servername, strlen(servername)+1);
- init_unistr2(&q_d->ShareName, sharename, strlen(sharename)+1);
+ init_unistr2(&q_d->DfsEntryPath, entrypath, UNI_STR_TERMINATE);
+ init_unistr2(&q_d->ServerName, servername, UNI_STR_TERMINATE);
+ init_unistr2(&q_d->ShareName, sharename, UNI_STR_TERMINATE);
q_d->ptr_ServerName = q_d->ptr_ShareName = 1;
return True;
}
@@ -155,11 +155,11 @@ BOOL init_dfs_q_dfs_add(DFS_Q_DFS_ADD *q_d, const char *entrypath,
{
DEBUG(5,("init_dfs_q_dfs_add\n"));
q_d->ptr_DfsEntryPath = q_d->ptr_ServerName = q_d->ptr_ShareName = 1;
- init_unistr2(&q_d->DfsEntryPath, entrypath, strlen(entrypath)+1);
- init_unistr2(&q_d->ServerName, servername, strlen(servername)+1);
- init_unistr2(&q_d->ShareName, sharename, strlen(sharename)+1);
+ init_unistr2(&q_d->DfsEntryPath, entrypath, UNI_STR_TERMINATE);
+ init_unistr2(&q_d->ServerName, servername, UNI_STR_TERMINATE);
+ init_unistr2(&q_d->ShareName, sharename, UNI_STR_TERMINATE);
if(comment != NULL) {
- init_unistr2(&q_d->Comment, comment, strlen(comment)+1);
+ init_unistr2(&q_d->Comment, comment,UNI_STR_TERMINATE);
q_d->ptr_Comment = 1;
} else {
q_d->ptr_Comment = 0;
@@ -237,9 +237,9 @@ BOOL init_dfs_q_dfs_get_info(DFS_Q_DFS_GET_INFO *q_d, const char *entrypath,
uint32 info_level)
{
DEBUG(5,("init_dfs_q2_get_info\n"));
- init_unistr2(&q_d->uni_path, entrypath, strlen(entrypath)+1);
- init_unistr2(&q_d->uni_server, servername, strlen(servername)+1);
- init_unistr2(&q_d->uni_share, sharename, strlen(sharename)+1);
+ init_unistr2(&q_d->uni_path, entrypath, UNI_STR_TERMINATE);
+ init_unistr2(&q_d->uni_server, servername, UNI_STR_TERMINATE);
+ init_unistr2(&q_d->uni_share, sharename, UNI_STR_TERMINATE);
q_d->level = info_level;
q_d->ptr_server = q_d->ptr_share = 1;
return True;
diff --git a/source3/rpc_parse/parse_ds.c b/source3/rpc_parse/parse_ds.c
index f954806036..26dcdb34b8 100644
--- a/source3/rpc_parse/parse_ds.c
+++ b/source3/rpc_parse/parse_ds.c
@@ -138,8 +138,6 @@ BOOL ds_io_r_getprimdominfo( const char *desc, prs_struct *ps, int depth, DS_R_G
BOOL init_q_ds_enum_domain_trusts( DS_Q_ENUM_DOM_TRUSTS *q, const char *server,
uint32 flags )
{
- int len;
-
q->flags = flags;
if ( server && *server )
@@ -147,9 +145,7 @@ BOOL init_q_ds_enum_domain_trusts( DS_Q_ENUM_DOM_TRUSTS *q, const char *server,
else
q->server_ptr = 0;
- len = q->server_ptr ? strlen(server)+1 : 0;
-
- init_unistr2( &q->server, server, len );
+ init_unistr2( &q->server, server, UNI_STR_TERMINATE);
return True;
}
diff --git a/source3/rpc_parse/parse_lsa.c b/source3/rpc_parse/parse_lsa.c
index 07b0da7e9c..3a5b232dc3 100644
--- a/source3/rpc_parse/parse_lsa.c
+++ b/source3/rpc_parse/parse_lsa.c
@@ -36,14 +36,9 @@ static BOOL lsa_io_trans_names(const char *desc, LSA_TRANS_NAME_ENUM *trn, prs_s
void init_lsa_trans_name(LSA_TRANS_NAME *trn, UNISTR2 *uni_name,
uint16 sid_name_use, const char *name, uint32 idx)
{
- int len_name = strlen(name);
-
- if(len_name == 0)
- len_name = 1;
-
trn->sid_name_use = sid_name_use;
- init_uni_hdr(&trn->hdr_name, len_name);
- init_unistr2(uni_name, name, len_name);
+ init_unistr2(uni_name, name, UNI_FLAGS_NONE);
+ init_uni_hdr(&trn->hdr_name, uni_name);
trn->domain_idx = idx;
}
@@ -346,8 +341,7 @@ void init_q_open_pol2(LSA_Q_OPEN_POL2 *r_q, const char *server_name,
r_q->des_access = desired_access;
- init_unistr2(&r_q->uni_server_name, server_name,
- strlen(server_name) + 1);
+ init_unistr2(&r_q->uni_server_name, server_name, UNI_STR_TERMINATE);
init_lsa_obj_attr(&r_q->attr, attributes, qos);
}
@@ -566,10 +560,10 @@ void init_r_enum_trust_dom(TALLOC_CTX *ctx, LSA_R_ENUM_TRUST_DOM *r_e, uint32 en
/* don't know what actually is this for */
r_e->ptr_enum_domains = 1;
- init_uni_hdr2(&r_e->hdr_domain_name[i], strlen_w((td[i])->name));
init_dom_sid2(&r_e->domain_sid[i], &(td[i])->sid);
init_unistr2_w(ctx, &r_e->uni_domain_name[i], (td[i])->name);
+ init_uni_hdr2(&r_e->hdr_domain_name[i], &r_e->uni_domain_name[i]);
};
}
@@ -1087,11 +1081,8 @@ void init_q_lookup_names(TALLOC_CTX *mem_ctx, LSA_Q_LOOKUP_NAMES *q_l,
}
for (i = 0; i < num_names; i++) {
- int len;
- len = strlen(names[i]);
-
- init_uni_hdr(&q_l->hdr_name[i], len);
- init_unistr2(&q_l->uni_name[i], names[i], len);
+ init_unistr2(&q_l->uni_name[i], names[i], UNI_FLAGS_NONE);
+ init_uni_hdr(&q_l->hdr_name[i], &q_l->uni_name[i]);
}
}
@@ -1436,15 +1427,10 @@ BOOL lsa_io_r_enum_privs(const char *desc, LSA_R_ENUM_PRIVS *r_q, prs_struct *ps
void init_lsa_priv_get_dispname(LSA_Q_PRIV_GET_DISPNAME *trn, POLICY_HND *hnd, const char *name, uint16 lang_id, uint16 lang_id_sys)
{
- int len_name = strlen(name);
-
- if(len_name == 0)
- len_name = 1;
-
memcpy(&trn->pol, hnd, sizeof(trn->pol));
- init_uni_hdr(&trn->hdr_name, len_name);
- init_unistr2(&trn->name, name, len_name);
+ init_unistr2(&trn->name, name, UNI_FLAGS_NONE);
+ init_uni_hdr(&trn->hdr_name, &trn->name);
trn->lang_id = lang_id;
trn->lang_id_sys = lang_id_sys;
}
@@ -1954,14 +1940,9 @@ BOOL lsa_io_r_setsystemaccount(const char *desc, LSA_R_SETSYSTEMACCOUNT *r_c, p
void init_lsa_q_lookupprivvalue(LSA_Q_LOOKUPPRIVVALUE *trn, POLICY_HND *hnd, const char *name)
{
- int len_name = strlen(name);
memcpy(&trn->pol, hnd, sizeof(trn->pol));
-
- if(len_name == 0)
- len_name = 1;
-
- init_uni_hdr(&trn->hdr_right, len_name);
- init_unistr2(&trn->uni2_right, name, len_name);
+ init_unistr2(&trn->uni2_right, name, UNI_FLAGS_NONE);
+ init_uni_hdr(&trn->hdr_right, &trn->uni2_right);
}
/*******************************************************************
diff --git a/source3/rpc_parse/parse_misc.c b/source3/rpc_parse/parse_misc.c
index 17a96fff80..e182535532 100644
--- a/source3/rpc_parse/parse_misc.c
+++ b/source3/rpc_parse/parse_misc.c
@@ -361,11 +361,11 @@ BOOL smb_io_strhdr(const char *desc, STRHDR *hdr, prs_struct *ps, int depth)
Inits a UNIHDR structure.
********************************************************************/
-void init_uni_hdr(UNIHDR *hdr, int len)
+void init_uni_hdr(UNIHDR *hdr, UNISTR2 *str2)
{
- hdr->uni_str_len = 2 * len;
- hdr->uni_max_len = 2 * len;
- hdr->buffer = len != 0 ? 1 : 0;
+ hdr->uni_str_len = 2 * (str2->uni_str_len);
+ hdr->uni_max_len = 2 * (str2->uni_max_len);
+ hdr->buffer = (str2->uni_str_len != 0) ? 1 : 0;
}
/*******************************************************************
@@ -482,10 +482,10 @@ BOOL smb_io_hdrbuf(const char *desc, BUFHDR *hdr, prs_struct *ps, int depth)
creates a UNIHDR2 structure.
********************************************************************/
-void init_uni_hdr2(UNIHDR2 *hdr, int len)
+void init_uni_hdr2(UNIHDR2 *hdr, UNISTR2 *str2)
{
- init_uni_hdr(&hdr->unihdr, len);
- hdr->buffer = (len > 0) ? 1 : 0;
+ init_uni_hdr(&hdr->unihdr, str2);
+ hdr->buffer = (str2->uni_str_len > 0) ? 1 : 0;
}
/*******************************************************************
@@ -703,7 +703,7 @@ void init_buffer2(BUFFER2 *str, const uint8 *buf, size_t len)
/* max buffer size (allocated size) */
str->buf_max_len = len;
- str->undoc = 0;
+ str->offset = 0;
str->buf_len = buf != NULL ? len : 0;
if (buf != NULL) {
@@ -737,7 +737,7 @@ BOOL smb_io_buffer2(const char *desc, BUFFER2 *buf2, uint32 buffer, prs_struct *
if(!prs_uint32("uni_max_len", ps, depth, &buf2->buf_max_len))
return False;
- if(!prs_uint32("undoc ", ps, depth, &buf2->undoc))
+ if(!prs_uint32("offset ", ps, depth, &buf2->offset))
return False;
if(!prs_uint32("buf_len ", ps, depth, &buf2->buf_len))
return False;
@@ -765,14 +765,11 @@ creates a UNISTR2 structure: sets up the buffer, too
void init_buf_unistr2(UNISTR2 *str, uint32 *ptr, const char *buf)
{
if (buf != NULL) {
-
*ptr = 1;
- init_unistr2(str, buf, strlen(buf)+1);
-
+ init_unistr2(str, buf, UNI_STR_TERMINATE);
} else {
-
*ptr = 0;
- init_unistr2(str, "", 0);
+ init_unistr2(str, NULL, UNI_FLAGS_NONE);
}
}
@@ -783,10 +780,8 @@ void init_buf_unistr2(UNISTR2 *str, uint32 *ptr, const char *buf)
void copy_unistr2(UNISTR2 *str, const UNISTR2 *from)
{
-
- /* set up string lengths. add one if string is not null-terminated */
str->uni_max_len = from->uni_max_len;
- str->undoc = from->undoc;
+ str->offset = from->offset;
str->uni_str_len = from->uni_str_len;
if (from->buffer == NULL)
@@ -803,8 +798,7 @@ void copy_unistr2(UNISTR2 *str, const UNISTR2 *from)
len *= sizeof(uint16);
str->buffer = (uint16 *)talloc_zero(get_talloc_ctx(), len);
- if ((str->buffer == NULL) && (len > 0 ))
- {
+ if ((str->buffer == NULL) && (len > 0 )) {
smb_panic("copy_unistr2: talloc fail\n");
return;
}
@@ -824,7 +818,7 @@ void init_string2(STRING2 *str, const char *buf, int max_len, int str_len)
/* set up string lengths. */
str->str_max_len = max_len;
- str->undoc = 0;
+ str->offset = 0;
str->str_str_len = str_len;
/* store the string */
@@ -835,7 +829,7 @@ void init_string2(STRING2 *str, const char *buf, int max_len, int str_len)
if (str->buffer == NULL)
smb_panic("init_string2: malloc fail\n");
memcpy(str->buffer, buf, str_len);
- }
+ }
}
/*******************************************************************
@@ -860,7 +854,7 @@ BOOL smb_io_string2(const char *desc, STRING2 *str2, uint32 buffer, prs_struct *
if(!prs_uint32("str_max_len", ps, depth, &str2->str_max_len))
return False;
- if(!prs_uint32("undoc ", ps, depth, &str2->undoc))
+ if(!prs_uint32("offset ", ps, depth, &str2->offset))
return False;
if(!prs_uint32("str_str_len", ps, depth, &str2->str_str_len))
return False;
@@ -885,34 +879,43 @@ BOOL smb_io_string2(const char *desc, STRING2 *str2, uint32 buffer, prs_struct *
Inits a UNISTR2 structure.
********************************************************************/
-void init_unistr2(UNISTR2 *str, const char *buf, size_t len)
+void init_unistr2(UNISTR2 *str, const char *buf, enum unistr2_term_codes flags)
{
- ZERO_STRUCTP(str);
+ size_t len = 0;
+ uint32 num_chars = 0;
- /* set up string lengths. */
- str->uni_max_len = (uint32)len;
- str->undoc = 0;
- str->uni_str_len = (uint32)len;
+ if (buf) {
+ /* We always null terminate the copy. */
+ len = strlen(buf) + 1;
+ }
if (len < MAX_UNISTRLEN)
len = MAX_UNISTRLEN;
len *= sizeof(uint16);
str->buffer = (uint16 *)talloc_zero(get_talloc_ctx(), len);
- if ((str->buffer == NULL) && (len > 0))
- {
+ if ((str->buffer == NULL) && (len > 0)) {
smb_panic("init_unistr2: malloc fail\n");
return;
}
/*
- * don't move this test above ! The UNISTR2 must be initialized !!!
+ * The UNISTR2 must be initialized !!!
* jfm, 7/7/2001.
*/
- if (buf==NULL)
- return;
+ if (buf) {
+ rpcstr_push((char *)str->buffer, buf, len, STR_TERMINATE);
+ num_chars = strlen_w(str->buffer);
+ if (flags == STR_TERMINATE || flags == UNI_MAXLEN_TERMINATE) {
+ num_chars++;
+ }
+ }
- rpcstr_push((char *)str->buffer, buf, len, STR_TERMINATE);
+ str->uni_max_len = num_chars;
+ str->offset = 0;
+ str->uni_str_len = num_chars;
+ if (num_chars && (flags == UNI_MAXLEN_TERMINATE))
+ str->uni_max_len++;
}
/**
@@ -932,7 +935,7 @@ void init_unistr2_w(TALLOC_CTX *ctx, UNISTR2 *str, const smb_ucs2_t *buf)
/* set up string lengths. */
str->uni_max_len = len;
- str->undoc = 0;
+ str->offset = 0;
str->uni_str_len = len;
if (max_len < MAX_UNISTRLEN)
@@ -941,8 +944,7 @@ void init_unistr2_w(TALLOC_CTX *ctx, UNISTR2 *str, const smb_ucs2_t *buf)
alloc_len = (max_len + 1) * sizeof(uint16);
str->buffer = (uint16 *)talloc_zero(ctx, alloc_len);
- if ((str->buffer == NULL) && (alloc_len > 0))
- {
+ if ((str->buffer == NULL) && (alloc_len > 0)) {
smb_panic("init_unistr2_w: malloc fail\n");
return;
}
@@ -963,9 +965,9 @@ void init_unistr2_w(TALLOC_CTX *ctx, UNISTR2 *str, const smb_ucs2_t *buf)
/*******************************************************************
Inits a UNISTR2 structure from a UNISTR
********************************************************************/
-void init_unistr2_from_unistr (UNISTR2 *to, const UNISTR *from)
-{
+void init_unistr2_from_unistr(UNISTR2 *to, const UNISTR *from)
+{
uint32 i;
/* the destination UNISTR2 should never be NULL.
@@ -987,7 +989,7 @@ void init_unistr2_from_unistr (UNISTR2 *to, const UNISTR *from)
/* set up string lengths; uni_max_len is set to i+1
because we need to account for the final NULL termination */
to->uni_max_len = i;
- to->undoc = 0;
+ to->offset = 0;
to->uni_str_len = i;
/* allocate the space and copy the string buffer */
@@ -995,11 +997,9 @@ void init_unistr2_from_unistr (UNISTR2 *to, const UNISTR *from)
if (to->buffer == NULL)
smb_panic("init_unistr2_from_unistr: malloc fail\n");
memcpy(to->buffer, from->buffer, to->uni_max_len*sizeof(uint16));
-
return;
}
-
/*******************************************************************
Reads or writes a UNISTR2 structure.
XXXX NOTE: UNISTR2 structures need NOT be null-terminated.
@@ -1022,7 +1022,7 @@ BOOL smb_io_unistr2(const char *desc, UNISTR2 *uni2, uint32 buffer, prs_struct *
if(!prs_uint32("uni_max_len", ps, depth, &uni2->uni_max_len))
return False;
- if(!prs_uint32("undoc ", ps, depth, &uni2->undoc))
+ if(!prs_uint32("offset ", ps, depth, &uni2->offset))
return False;
if(!prs_uint32("uni_str_len", ps, depth, &uni2->uni_str_len))
return False;
@@ -1064,7 +1064,7 @@ BOOL init_unistr2_array(UNISTR2_ARRAY *array,
}
for (i=0;i<count;i++) {
- init_unistr2(&array->strings[i].string, strings[i], strlen(strings[i]));
+ init_unistr2(&array->strings[i].string, strings[i], UNI_FLAGS_NONE);
array->strings[i].size = array->strings[i].string.uni_max_len*2;
array->strings[i].length = array->strings[i].size;
array->strings[i].ref_id = 1;
@@ -1223,14 +1223,14 @@ static void init_clnt_srv(DOM_CLNT_SRV *logcln, const char *logon_srv, const cha
if (logon_srv != NULL) {
logcln->undoc_buffer = 1;
- init_unistr2(&logcln->uni_logon_srv, logon_srv, strlen(logon_srv)+1);
+ init_unistr2(&logcln->uni_logon_srv, logon_srv, UNI_STR_TERMINATE);
} else {
logcln->undoc_buffer = 0;
}
if (comp_name != NULL) {
logcln->undoc_buffer2 = 1;
- init_unistr2(&logcln->uni_comp_name, comp_name, strlen(comp_name)+1);
+ init_unistr2(&logcln->uni_comp_name, comp_name, UNI_STR_TERMINATE);
} else {
logcln->undoc_buffer2 = 0;
}
@@ -1284,12 +1284,12 @@ void init_log_info(DOM_LOG_INFO *loginfo, const char *logon_srv, const char *acc
loginfo->undoc_buffer = 1;
- init_unistr2(&loginfo->uni_logon_srv, logon_srv, strlen(logon_srv)+1);
- init_unistr2(&loginfo->uni_acct_name, acct_name, strlen(acct_name)+1);
+ init_unistr2(&loginfo->uni_logon_srv, logon_srv, UNI_STR_TERMINATE);
+ init_unistr2(&loginfo->uni_acct_name, acct_name, UNI_STR_TERMINATE);
loginfo->sec_chan = sec_chan;
- init_unistr2(&loginfo->uni_comp_name, comp_name, strlen(comp_name)+1);
+ init_unistr2(&loginfo->uni_comp_name, comp_name, UNI_STR_TERMINATE);
}
/*******************************************************************
diff --git a/source3/rpc_parse/parse_net.c b/source3/rpc_parse/parse_net.c
index dd319df5a0..3b096e088a 100644
--- a/source3/rpc_parse/parse_net.c
+++ b/source3/rpc_parse/parse_net.c
@@ -136,16 +136,15 @@ static BOOL net_io_netinfo_1(const char *desc, NETLOGON_INFO_1 *info, prs_struct
static void init_netinfo_2(NETLOGON_INFO_2 *info, uint32 flags, uint32 pdc_status,
uint32 tc_status, const char *trusted_dc_name)
{
- int len_dc_name = strlen(trusted_dc_name);
info->flags = flags;
info->pdc_status = pdc_status;
info->ptr_trusted_dc_name = 1;
info->tc_status = tc_status;
if (trusted_dc_name != NULL)
- init_unistr2(&info->uni_trusted_dc_name, trusted_dc_name, len_dc_name+1);
+ init_unistr2(&info->uni_trusted_dc_name, trusted_dc_name, UNI_STR_TERMINATE);
else
- init_unistr2(&info->uni_trusted_dc_name, "", 1);
+ init_unistr2(&info->uni_trusted_dc_name, "", UNI_STR_TERMINATE);
}
/*******************************************************************
@@ -230,7 +229,7 @@ void init_net_q_logon_ctrl2(NET_Q_LOGON_CTRL2 *q_l, const char *srv_name,
q_l->query_level = query_level;
q_l->switch_value = 0x01;
- init_unistr2(&q_l->uni_server_name, srv_name, strlen(srv_name) + 1);
+ init_unistr2(&q_l->uni_server_name, srv_name, UNI_STR_TERMINATE);
}
/*******************************************************************
@@ -360,7 +359,7 @@ void init_net_q_logon_ctrl(NET_Q_LOGON_CTRL *q_l, const char *srv_name,
q_l->function_code = 0x01; /* ??? */
q_l->query_level = query_level;
- init_unistr2(&q_l->uni_server_name, srv_name, strlen(srv_name) + 1);
+ init_unistr2(&q_l->uni_server_name, srv_name, UNI_STR_TERMINATE);
}
/*******************************************************************
@@ -447,9 +446,9 @@ void init_r_trust_dom(NET_R_TRUST_DOM_LIST *r_t,
fstring domain_name;
fstrcpy(domain_name, dom_name);
strupper_m(domain_name);
- init_unistr2(&r_t->uni_trust_dom_name[i], domain_name, strlen(domain_name)+1);
+ init_unistr2(&r_t->uni_trust_dom_name[i], domain_name, UNI_STR_TERMINATE);
/* the use of UNISTR2 here is non-standard. */
- r_t->uni_trust_dom_name[i].undoc = 0x1;
+ r_t->uni_trust_dom_name[i].offset = 0x1;
}
r_t->status = NT_STATUS_OK;
@@ -539,8 +538,8 @@ void init_q_req_chal(NET_Q_REQ_CHAL *q_c,
q_c->undoc_buffer = 1; /* don't know what this buffer is */
- init_unistr2(&q_c->uni_logon_srv, logon_srv , strlen(logon_srv )+1);
- init_unistr2(&q_c->uni_logon_clnt, logon_clnt, strlen(logon_clnt)+1);
+ init_unistr2(&q_c->uni_logon_srv, logon_srv , UNI_STR_TERMINATE);
+ init_unistr2(&q_c->uni_logon_clnt, logon_clnt, UNI_STR_TERMINATE);
memcpy(q_c->clnt_chal.data, clnt_chal->data, sizeof(clnt_chal->data));
@@ -910,10 +909,6 @@ void init_id_info1(NET_ID_INFO_1 *id, const char *domain_name,
const char *sess_key,
unsigned char lm_cypher[16], unsigned char nt_cypher[16])
{
- int len_domain_name = strlen(domain_name);
- int len_user_name = strlen(user_name );
- int len_wksta_name = strlen(wksta_name );
-
unsigned char lm_owf[16];
unsigned char nt_owf[16];
@@ -921,13 +916,9 @@ void init_id_info1(NET_ID_INFO_1 *id, const char *domain_name,
id->ptr_id_info1 = 1;
- init_uni_hdr(&id->hdr_domain_name, len_domain_name);
-
id->param_ctrl = param_ctrl;
init_logon_id(&id->logon_id, log_id_low, log_id_high);
- init_uni_hdr(&id->hdr_user_name, len_user_name);
- init_uni_hdr(&id->hdr_wksta_name, len_wksta_name);
if (lm_cypher && nt_cypher) {
unsigned char key[16];
@@ -962,9 +953,12 @@ void init_id_info1(NET_ID_INFO_1 *id, const char *domain_name,
init_owf_info(&id->lm_owf, lm_cypher);
init_owf_info(&id->nt_owf, nt_cypher);
- init_unistr2(&id->uni_domain_name, domain_name, len_domain_name);
- init_unistr2(&id->uni_user_name, user_name, len_user_name);
- init_unistr2(&id->uni_wksta_name, wksta_name, len_wksta_name);
+ init_unistr2(&id->uni_domain_name, domain_name, UNI_FLAGS_NONE);
+ init_uni_hdr(&id->hdr_domain_name, &id->uni_domain_name);
+ init_unistr2(&id->uni_user_name, user_name, UNI_FLAGS_NONE);
+ init_uni_hdr(&id->hdr_user_name, &id->uni_user_name);
+ init_unistr2(&id->uni_wksta_name, wksta_name, UNI_FLAGS_NONE);
+ init_uni_hdr(&id->hdr_wksta_name, &id->uni_wksta_name);
}
/*******************************************************************
@@ -1041,9 +1035,6 @@ void init_id_info2(NET_ID_INFO_2 * id, const char *domain_name,
const uchar * lm_chal_resp, size_t lm_chal_resp_len,
const uchar * nt_chal_resp, size_t nt_chal_resp_len)
{
- size_t len_domain_name = strlen(domain_name);
- size_t len_user_name = strlen(user_name );
- size_t len_wksta_name = strlen(wksta_name );
unsigned char lm_owf[24];
unsigned char nt_owf[128];
@@ -1051,14 +1042,10 @@ void init_id_info2(NET_ID_INFO_2 * id, const char *domain_name,
id->ptr_id_info2 = 1;
- init_uni_hdr(&id->hdr_domain_name, len_domain_name);
id->param_ctrl = param_ctrl;
init_logon_id(&id->logon_id, log_id_low, log_id_high);
- init_uni_hdr(&id->hdr_user_name, len_user_name);
- init_uni_hdr(&id->hdr_wksta_name, len_wksta_name);
-
if (nt_chal_resp) {
/* oops. can only send what-ever-it-is direct */
memcpy(nt_owf, nt_chal_resp, MIN(sizeof(nt_owf), nt_chal_resp_len));
@@ -1074,9 +1061,12 @@ void init_id_info2(NET_ID_INFO_2 * id, const char *domain_name,
init_str_hdr(&id->hdr_nt_chal_resp, nt_chal_resp_len, nt_chal_resp_len, (nt_chal_resp != NULL) ? 1 : 0);
init_str_hdr(&id->hdr_lm_chal_resp, lm_chal_resp_len, lm_chal_resp_len, (lm_chal_resp != NULL) ? 1 : 0);
- init_unistr2(&id->uni_domain_name, domain_name, len_domain_name);
- init_unistr2(&id->uni_user_name, user_name, len_user_name);
- init_unistr2(&id->uni_wksta_name, wksta_name, len_wksta_name);
+ init_unistr2(&id->uni_domain_name, domain_name, UNI_FLAGS_NONE);
+ init_uni_hdr(&id->hdr_domain_name, &id->uni_domain_name);
+ init_unistr2(&id->uni_user_name, user_name, UNI_FLAGS_NONE);
+ init_uni_hdr(&id->hdr_user_name, &id->uni_user_name);
+ init_unistr2(&id->uni_wksta_name, wksta_name, UNI_FLAGS_NONE);
+ init_uni_hdr(&id->hdr_wksta_name, &id->uni_wksta_name);
init_string2(&id->nt_chal_resp, (const char *)nt_chal_resp, nt_chal_resp_len, nt_chal_resp_len);
init_string2(&id->lm_chal_resp, (const char *)lm_chal_resp, lm_chal_resp_len, lm_chal_resp_len);
@@ -1288,26 +1278,10 @@ void init_net_user_info3(TALLOC_CTX *ctx, NET_USER_INFO_3 *usr,
pass_last_set_time, pass_can_change_time,
pass_must_change_time;
- int len_user_name, len_full_name, len_home_dir,
- len_dir_drive, len_logon_script, len_profile_path;
-
- int len_logon_srv = strlen(logon_srv);
- int len_logon_dom = strlen(logon_dom);
-
- len_user_name = strlen(user_name );
- len_full_name = strlen(full_name );
- len_home_dir = strlen(home_dir );
- len_dir_drive = strlen(dir_drive );
- len_logon_script = strlen(logon_script);
- len_profile_path = strlen(profile_path);
-
-
ZERO_STRUCTP(usr);
usr->ptr_user_info = 1; /* yes, we're bothering to put USER_INFO data here */
-
-
/* Create NTTIME structs */
unix_to_nt_time (&logon_time, unix_logon_time);
unix_to_nt_time (&logoff_time, unix_logoff_time);
@@ -1323,13 +1297,6 @@ void init_net_user_info3(TALLOC_CTX *ctx, NET_USER_INFO_3 *usr,
usr->pass_can_change_time = pass_can_change_time;
usr->pass_must_change_time = pass_must_change_time;
- init_uni_hdr(&usr->hdr_user_name, len_user_name);
- init_uni_hdr(&usr->hdr_full_name, len_full_name);
- init_uni_hdr(&usr->hdr_logon_script, len_logon_script);
- init_uni_hdr(&usr->hdr_profile_path, len_profile_path);
- init_uni_hdr(&usr->hdr_home_dir, len_home_dir);
- init_uni_hdr(&usr->hdr_dir_drive, len_dir_drive);
-
usr->logon_count = logon_count;
usr->bad_pw_count = bad_pw_count;
@@ -1345,9 +1312,6 @@ void init_net_user_info3(TALLOC_CTX *ctx, NET_USER_INFO_3 *usr,
else
memset((char *)usr->user_sess_key, '\0', sizeof(usr->user_sess_key));
- init_uni_hdr(&usr->hdr_logon_srv, len_logon_srv);
- init_uni_hdr(&usr->hdr_logon_dom, len_logon_dom);
-
usr->buffer_dom_id = dom_sid ? 1 : 0; /* yes, we're bothering to put a domain SID in */
memset((char *)usr->padding, '\0', sizeof(usr->padding));
@@ -1357,12 +1321,18 @@ void init_net_user_info3(TALLOC_CTX *ctx, NET_USER_INFO_3 *usr,
usr->num_other_sids = num_other_sids;
usr->buffer_other_sids = (num_other_sids != 0) ? 1 : 0;
- init_unistr2(&usr->uni_user_name, user_name, len_user_name);
- init_unistr2(&usr->uni_full_name, full_name, len_full_name);
- init_unistr2(&usr->uni_logon_script, logon_script, len_logon_script);
- init_unistr2(&usr->uni_profile_path, profile_path, len_profile_path);
- init_unistr2(&usr->uni_home_dir, home_dir, len_home_dir);
- init_unistr2(&usr->uni_dir_drive, dir_drive, len_dir_drive);
+ init_unistr2(&usr->uni_user_name, user_name, UNI_FLAGS_NONE);
+ init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
+ init_unistr2(&usr->uni_full_name, full_name, UNI_FLAGS_NONE);
+ init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
+ init_unistr2(&usr->uni_logon_script, logon_script, UNI_FLAGS_NONE);
+ init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
+ init_unistr2(&usr->uni_profile_path, profile_path, UNI_FLAGS_NONE);
+ init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
+ init_unistr2(&usr->uni_home_dir, home_dir, UNI_FLAGS_NONE);
+ init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
+ init_unistr2(&usr->uni_dir_drive, dir_drive, UNI_FLAGS_NONE);
+ init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
usr->num_groups2 = num_groups;
@@ -1373,8 +1343,10 @@ void init_net_user_info3(TALLOC_CTX *ctx, NET_USER_INFO_3 *usr,
for (i = 0; i < num_groups; i++)
usr->gids[i] = gids[i];
- init_unistr2(&usr->uni_logon_srv, logon_srv, len_logon_srv);
- init_unistr2(&usr->uni_logon_dom, logon_dom, len_logon_dom);
+ init_unistr2(&usr->uni_logon_srv, logon_srv, UNI_FLAGS_NONE);
+ init_uni_hdr(&usr->hdr_logon_srv, &usr->uni_logon_srv);
+ init_unistr2(&usr->uni_logon_dom, logon_dom, UNI_FLAGS_NONE);
+ init_uni_hdr(&usr->hdr_logon_dom, &usr->uni_logon_dom);
init_dom_sid2(&usr->dom_sid, dom_sid);
/* "other" sids are set up above */
@@ -1670,8 +1642,8 @@ BOOL init_net_q_sam_sync(NET_Q_SAM_SYNC * q_s, const char *srv_name,
{
DEBUG(5, ("init_q_sam_sync\n"));
- init_unistr2(&q_s->uni_srv_name, srv_name, strlen(srv_name) + 1);
- init_unistr2(&q_s->uni_cli_name, cli_name, strlen(cli_name) + 1);
+ init_unistr2(&q_s->uni_srv_name, srv_name, UNI_STR_TERMINATE);
+ init_unistr2(&q_s->uni_cli_name, cli_name, UNI_STR_TERMINATE);
if (cli_creds)
memcpy(&q_s->cli_creds, cli_creds, sizeof(q_s->cli_creds));
@@ -2858,8 +2830,8 @@ BOOL init_net_q_sam_deltas(NET_Q_SAM_DELTAS *q_s, const char *srv_name,
{
DEBUG(5, ("init_net_q_sam_deltas\n"));
- init_unistr2(&q_s->uni_srv_name, srv_name, strlen(srv_name) + 1);
- init_unistr2(&q_s->uni_cli_name, cli_name, strlen(cli_name) + 1);
+ init_unistr2(&q_s->uni_srv_name, srv_name, UNI_STR_TERMINATE);
+ init_unistr2(&q_s->uni_cli_name, cli_name, UNI_STR_TERMINATE);
memcpy(&q_s->cli_creds, cli_creds, sizeof(q_s->cli_creds));
memset(&q_s->ret_creds, 0, sizeof(q_s->ret_creds));
diff --git a/source3/rpc_parse/parse_reg.c b/source3/rpc_parse/parse_reg.c
index bbf6e6a8e3..69c0dfc754 100644
--- a/source3/rpc_parse/parse_reg.c
+++ b/source3/rpc_parse/parse_reg.c
@@ -281,18 +281,15 @@ void init_reg_q_create_key(REG_Q_CREATE_KEY *q_c, POLICY_HND *hnd,
char *name, char *class, SEC_ACCESS *sam_access,
SEC_DESC_BUF *sec_buf)
{
- int len_name = name != NULL ? strlen(name ) + 1: 0;
- int len_class = class != NULL ? strlen(class) + 1: 0;
-
ZERO_STRUCTP(q_c);
memcpy(&q_c->pnt_pol, hnd, sizeof(q_c->pnt_pol));
- init_uni_hdr(&q_c->hdr_name, len_name);
- init_unistr2(&q_c->uni_name, name, len_name);
+ init_unistr2(&q_c->uni_name, name, UNI_STR_TERMINATE);
+ init_uni_hdr(&q_c->hdr_name, &q_c->uni_name);
- init_uni_hdr(&q_c->hdr_class, len_class);
- init_unistr2(&q_c->uni_class, class, len_class);
+ init_unistr2(&q_c->uni_class, class, UNI_STR_TERMINATE);
+ init_uni_hdr(&q_c->hdr_class, &q_c->uni_class);
q_c->reserved = 0x00000000;
memcpy(&q_c->sam_access, sam_access, sizeof(q_c->sam_access));
@@ -397,13 +394,12 @@ BOOL reg_io_r_create_key(const char *desc, REG_R_CREATE_KEY *r_r, prs_struct *p
void init_reg_q_delete_val(REG_Q_DELETE_VALUE *q_c, POLICY_HND *hnd,
char *name)
{
- int len_name = name != NULL ? strlen(name ) + 1: 0;
ZERO_STRUCTP(q_c);
memcpy(&q_c->pnt_pol, hnd, sizeof(q_c->pnt_pol));
- init_uni_hdr(&q_c->hdr_name, len_name);
- init_unistr2(&q_c->uni_name, name, len_name);
+ init_unistr2(&q_c->uni_name, name, UNI_STR_TERMINATE);
+ init_uni_hdr(&q_c->hdr_name, &q_c->uni_name);
}
/*******************************************************************
@@ -463,13 +459,12 @@ BOOL reg_io_r_delete_val(const char *desc, REG_R_DELETE_VALUE *r_r, prs_struct
void init_reg_q_delete_key(REG_Q_DELETE_KEY *q_c, POLICY_HND *hnd,
char *name)
{
- int len_name = name != NULL ? strlen(name ) + 1: 0;
ZERO_STRUCTP(q_c);
memcpy(&q_c->pnt_pol, hnd, sizeof(q_c->pnt_pol));
- init_uni_hdr(&q_c->hdr_name, len_name);
- init_unistr2(&q_c->uni_name, name, len_name);
+ init_unistr2(&q_c->uni_name, name, UNI_STR_TERMINATE);
+ init_uni_hdr(&q_c->hdr_name, &q_c->uni_name);
}
/*******************************************************************
@@ -525,14 +520,12 @@ BOOL reg_io_r_delete_key(const char *desc, REG_R_DELETE_KEY *r_r, prs_struct *p
Inits a structure.
********************************************************************/
-void init_reg_q_query_key(REG_Q_QUERY_KEY *q_o, POLICY_HND *hnd,
- uint32 max_class_len)
+void init_reg_q_query_key(REG_Q_QUERY_KEY *q_o, POLICY_HND *hnd, UNISTR2 *uni2)
{
ZERO_STRUCTP(q_o);
memcpy(&q_o->pol, hnd, sizeof(q_o->pol));
- init_uni_hdr(&q_o->hdr_class, max_class_len);
- q_o->uni_class.uni_max_len = max_class_len;
+ init_uni_hdr(&q_o->hdr_class, uni2);
}
/*******************************************************************
@@ -1010,15 +1003,13 @@ makes a structure.
BOOL init_reg_q_info(REG_Q_INFO *q_i, POLICY_HND *pol, char* val_name)
{
- int len_type = val_name != NULL ? strlen(val_name) + 1 : 0;
-
if (q_i == NULL)
return False;
q_i->pol = *pol;
- init_uni_hdr(&(q_i->hdr_type), len_type);
- init_unistr2(&(q_i->uni_type), val_name, len_type);
+ init_unistr2(&q_i->uni_type, val_name, UNI_STR_TERMINATE);
+ init_uni_hdr(&q_i->hdr_type, &q_i->uni_type);
q_i->ptr_reserved = 1;
q_i->ptr_buf = 1;
@@ -1230,7 +1221,7 @@ makes a structure.
********************************************************************/
void init_reg_q_enum_val(REG_Q_ENUM_VALUE *q_i, POLICY_HND *pol,
- uint32 val_idx, uint32 max_val_len,
+ uint32 val_idx, UNISTR2 *uni2,
uint32 max_buf_len)
{
ZERO_STRUCTP(q_i);
@@ -1238,8 +1229,7 @@ void init_reg_q_enum_val(REG_Q_ENUM_VALUE *q_i, POLICY_HND *pol,
memcpy(&q_i->pol, pol, sizeof(q_i->pol));
q_i->val_index = val_idx;
- init_uni_hdr(&q_i->hdr_name, max_val_len);
- q_i->uni_name.uni_max_len = max_val_len;
+ init_uni_hdr(&q_i->hdr_name, uni2);
q_i->ptr_type = 1;
q_i->type = 0x0;
@@ -1270,8 +1260,8 @@ void init_reg_r_enum_val(REG_R_ENUM_VALUE *r_u, REGISTRY_VALUE *val )
DEBUG(10,("init_reg_r_enum_val: Valuename => [%s]\n", val->valuename));
- init_uni_hdr( &r_u->hdr_name, strlen(val->valuename)+1 );
- init_unistr2( &r_u->uni_name, val->valuename, strlen(val->valuename)+1 );
+ init_unistr2( &r_u->uni_name, val->valuename, UNI_STR_TERMINATE);
+ init_uni_hdr( &r_u->hdr_name, &r_u->uni_name);
/* type */
@@ -1418,14 +1408,12 @@ void init_reg_q_create_val(REG_Q_CREATE_VALUE *q_i, POLICY_HND *pol,
char *val_name, uint32 type,
BUFFER3 *val)
{
- int val_len = strlen(val_name) + 1;
-
ZERO_STRUCTP(q_i);
memcpy(&q_i->pol, pol, sizeof(q_i->pol));
- init_uni_hdr(&q_i->hdr_name, val_len);
- init_unistr2(&q_i->uni_name, val_name, val_len);
+ init_unistr2(&q_i->uni_name, val_name, UNI_STR_TERMINATE);
+ init_uni_hdr(&q_i->hdr_name, &q_i->uni_name);
q_i->type = type;
q_i->buf_value = val;
@@ -1650,12 +1638,10 @@ makes a structure.
void init_reg_q_open_entry(REG_Q_OPEN_ENTRY *r_q, POLICY_HND *pol,
char *key_name, uint32 access_desired)
{
- int len_name = strlen(key_name)+1;
-
memcpy(&r_q->pol, pol, sizeof(r_q->pol));
- init_uni_hdr(&r_q->hdr_name, len_name);
- init_unistr2(&r_q->uni_name, key_name, len_name);
+ init_unistr2(&r_q->uni_name, key_name, UNI_STR_TERMINATE);
+ init_uni_hdr(&r_q->hdr_name, &r_q->uni_name);
r_q->unknown_0 = 0x00000000;
r_q->access_desired = access_desired;
@@ -1736,29 +1722,27 @@ BOOL reg_io_r_open_entry(const char *desc, REG_R_OPEN_ENTRY *r_r, prs_struct *p
/*******************************************************************
Inits a structure.
********************************************************************/
+
void init_reg_q_shutdown(REG_Q_SHUTDOWN * q_s, const char *msg,
uint32 timeout, BOOL do_reboot, BOOL force)
{
- int msg_len;
- msg_len = strlen(msg);
-
q_s->ptr_0 = 1;
q_s->ptr_1 = 1;
q_s->ptr_2 = 1;
- init_uni_hdr(&(q_s->hdr_msg), msg_len);
- init_unistr2(&(q_s->uni_msg), msg, msg_len);
+ init_unistr2(&q_s->uni_msg, msg, UNI_FLAGS_NONE);
+ init_uni_hdr(&q_s->hdr_msg, &q_s->uni_msg);
q_s->timeout = timeout;
q_s->reboot = do_reboot ? 1 : 0;
q_s->force = force ? 1 : 0;
-
}
/*******************************************************************
reads or writes a structure.
********************************************************************/
+
BOOL reg_io_q_shutdown(const char *desc, REG_Q_SHUTDOWN * q_s, prs_struct *ps,
int depth)
{
diff --git a/source3/rpc_parse/parse_samr.c b/source3/rpc_parse/parse_samr.c
index 420a727765..939b652a1e 100644
--- a/source3/rpc_parse/parse_samr.c
+++ b/source3/rpc_parse/parse_samr.c
@@ -93,14 +93,12 @@ inits a SAMR_Q_LOOKUP_DOMAIN structure.
void init_samr_q_lookup_domain(SAMR_Q_LOOKUP_DOMAIN * q_u,
POLICY_HND *pol, char *dom_name)
{
- int len_name = strlen(dom_name);
-
DEBUG(5, ("init_samr_q_lookup_domain\n"));
q_u->connect_pol = *pol;
- init_uni_hdr(&q_u->hdr_domain, len_name);
- init_unistr2(&q_u->uni_domain, dom_name, len_name);
+ init_unistr2(&q_u->uni_domain, dom_name, UNI_FLAGS_NONE);
+ init_uni_hdr(&q_u->hdr_domain, &q_u->uni_domain);
}
/*******************************************************************
@@ -630,13 +628,11 @@ static BOOL sam_io_unk_info12(const char *desc, SAM_UNK_INFO_12 * u_12,
/*******************************************************************
inits a structure.
********************************************************************/
+
void init_unk_info5(SAM_UNK_INFO_5 * u_5,const char *server)
{
- int len_server = strlen(server);
-
- init_uni_hdr(&u_5->hdr_server, len_server);
-
- init_unistr2(&u_5->uni_server, server, len_server);
+ init_unistr2(&u_5->uni_server, server, UNI_FLAGS_NONE);
+ init_uni_hdr(&u_5->hdr_server, &u_5->uni_server);
}
/*******************************************************************
@@ -664,20 +660,16 @@ static BOOL sam_io_unk_info5(const char *desc, SAM_UNK_INFO_5 * u_5,
/*******************************************************************
inits a structure.
********************************************************************/
+
void init_unk_info2(SAM_UNK_INFO_2 * u_2,
const char *domain, const char *server,
uint32 seq_num, uint32 num_users, uint32 num_groups, uint32 num_alias)
{
- int len_domain = strlen(domain);
- int len_server = strlen(server);
-
u_2->unknown_0 = 0x00000000;
u_2->unknown_1 = 0x80000000;
u_2->unknown_2 = 0x00000000;
u_2->ptr_0 = 1;
- init_uni_hdr(&u_2->hdr_domain, len_domain);
- init_uni_hdr(&u_2->hdr_server, len_server);
u_2->seq_num = seq_num;
u_2->unknown_3 = 0x00000000;
@@ -691,8 +683,10 @@ void init_unk_info2(SAM_UNK_INFO_2 * u_2,
memset(u_2->padding, 0, sizeof(u_2->padding)); /* 12 bytes zeros */
- init_unistr2(&u_2->uni_domain, domain, len_domain);
- init_unistr2(&u_2->uni_server, server, len_server);
+ init_unistr2(&u_2->uni_domain, domain, UNI_FLAGS_NONE);
+ init_uni_hdr(&u_2->hdr_domain, &u_2->uni_domain);
+ init_unistr2(&u_2->uni_server, server, UNI_FLAGS_NONE);
+ init_uni_hdr(&u_2->hdr_server, &u_2->uni_server);
}
/*******************************************************************
@@ -984,9 +978,9 @@ static BOOL sam_io_sam_str1(const char *desc, SAM_STR1 * sam, uint32 acct_buf,
inits a SAM_ENTRY1 structure.
********************************************************************/
-static void init_sam_entry1(SAM_ENTRY1 * sam, uint32 user_idx,
- uint32 len_sam_name, uint32 len_sam_full,
- uint32 len_sam_desc, uint32 rid_user,
+static void init_sam_entry1(SAM_ENTRY1 *sam, uint32 user_idx,
+ UNISTR2 *sam_name, UNISTR2 *sam_full,
+ UNISTR2 *sam_desc, uint32 rid_user,
uint16 acb_info)
{
DEBUG(5, ("init_sam_entry1\n"));
@@ -997,9 +991,9 @@ static void init_sam_entry1(SAM_ENTRY1 * sam, uint32 user_idx,
sam->rid_user = rid_user;
sam->acb_info = acb_info;
- init_uni_hdr(&sam->hdr_acct_name, len_sam_name);
- init_uni_hdr(&sam->hdr_user_name, len_sam_full);
- init_uni_hdr(&sam->hdr_user_desc, len_sam_desc);
+ init_uni_hdr(&sam->hdr_acct_name, sam_name);
+ init_uni_hdr(&sam->hdr_user_name, sam_full);
+ init_uni_hdr(&sam->hdr_user_desc, sam_desc);
}
/*******************************************************************
@@ -1067,7 +1061,7 @@ static BOOL sam_io_sam_str2(const char *desc, SAM_STR2 * sam, uint32 acct_buf,
inits a SAM_ENTRY2 structure.
********************************************************************/
static void init_sam_entry2(SAM_ENTRY2 * sam, uint32 user_idx,
- uint32 len_sam_name, uint32 len_sam_desc,
+ UNISTR2 *sam_name, UNISTR2 *sam_desc,
uint32 rid_user, uint16 acb_info)
{
DEBUG(5, ("init_sam_entry2\n"));
@@ -1076,8 +1070,8 @@ static void init_sam_entry2(SAM_ENTRY2 * sam, uint32 user_idx,
sam->rid_user = rid_user;
sam->acb_info = acb_info;
- init_uni_hdr(&sam->hdr_srv_name, len_sam_name);
- init_uni_hdr(&sam->hdr_srv_desc, len_sam_desc);
+ init_uni_hdr(&sam->hdr_srv_name, sam_name);
+ init_uni_hdr(&sam->hdr_srv_desc, sam_desc);
}
/*******************************************************************
@@ -1144,7 +1138,7 @@ inits a SAM_ENTRY3 structure.
********************************************************************/
static void init_sam_entry3(SAM_ENTRY3 * sam, uint32 grp_idx,
- uint32 len_grp_name, uint32 len_grp_desc,
+ UNISTR2 *grp_name, UNISTR2 *grp_desc,
uint32 rid_grp)
{
DEBUG(5, ("init_sam_entry3\n"));
@@ -1153,8 +1147,8 @@ static void init_sam_entry3(SAM_ENTRY3 * sam, uint32 grp_idx,
sam->rid_grp = rid_grp;
sam->attr = 0x07; /* group rid attributes - gets ignored by nt 4.0 */
- init_uni_hdr(&sam->hdr_grp_name, len_grp_name);
- init_uni_hdr(&sam->hdr_grp_desc, len_grp_desc);
+ init_uni_hdr(&sam->hdr_grp_name, grp_name);
+ init_uni_hdr(&sam->hdr_grp_desc, grp_desc);
}
/*******************************************************************
@@ -1268,12 +1262,12 @@ static BOOL sam_io_sam_entry5(const char *desc, SAM_ENTRY5 * sam,
inits a SAM_ENTRY structure.
********************************************************************/
-void init_sam_entry(SAM_ENTRY * sam, uint32 len_sam_name, uint32 rid)
+void init_sam_entry(SAM_ENTRY *sam, UNISTR2 *uni2, uint32 rid)
{
- DEBUG(10, ("init_sam_entry: %d %d\n", len_sam_name, rid));
+ DEBUG(10, ("init_sam_entry: %d\n", rid));
sam->rid = rid;
- init_uni_hdr(&sam->hdr_name, len_sam_name);
+ init_uni_hdr(&sam->hdr_name, uni2);
}
/*******************************************************************
@@ -1502,7 +1496,6 @@ NTSTATUS init_sam_dispinfo_1(TALLOC_CTX *ctx, SAM_DISPINFO_1 *sam, uint32 num_en
uint32 start_idx, SAM_ACCOUNT *disp_user_info,
DOM_SID *domain_sid)
{
- uint32 len_sam_name, len_sam_full, len_sam_desc;
uint32 i;
SAM_ACCOUNT *pwd = NULL;
@@ -1560,21 +1553,14 @@ NTSTATUS init_sam_dispinfo_1(TALLOC_CTX *ctx, SAM_DISPINFO_1 *sam, uint32 num_en
return NT_STATUS_UNSUCCESSFUL;
}
- len_sam_name = strlen(username);
- len_sam_full = strlen(fullname);
- len_sam_desc = strlen(acct_desc);
+ init_unistr2(&sam->str[i].uni_acct_name, pdb_get_username(pwd), UNI_FLAGS_NONE);
+ init_unistr2(&sam->str[i].uni_full_name, pdb_get_fullname(pwd), UNI_FLAGS_NONE);
+ init_unistr2(&sam->str[i].uni_acct_desc, pdb_get_acct_desc(pwd), UNI_FLAGS_NONE);
init_sam_entry1(&sam->sam[i], start_idx + i + 1,
- len_sam_name, len_sam_full, len_sam_desc,
+ &sam->str[i].uni_acct_name, &sam->str[i].uni_full_name, &sam->str[i].uni_acct_desc,
user_rid, pdb_get_acct_ctrl(pwd));
- ZERO_STRUCTP(&sam->str[i].uni_acct_name);
- ZERO_STRUCTP(&sam->str[i].uni_full_name);
- ZERO_STRUCTP(&sam->str[i].uni_acct_desc);
-
- init_unistr2(&sam->str[i].uni_acct_name, pdb_get_username(pwd), len_sam_name);
- init_unistr2(&sam->str[i].uni_full_name, pdb_get_fullname(pwd), len_sam_full);
- init_unistr2(&sam->str[i].uni_acct_desc, pdb_get_acct_desc(pwd), len_sam_desc);
}
return NT_STATUS_OK;
@@ -1637,7 +1623,6 @@ NTSTATUS init_sam_dispinfo_2(TALLOC_CTX *ctx, SAM_DISPINFO_2 *sam, uint32 num_en
uint32 start_idx, SAM_ACCOUNT *disp_user_info,
DOM_SID *domain_sid )
{
- uint32 len_sam_name, len_sam_desc;
uint32 i;
SAM_ACCOUNT *pwd = NULL;
@@ -1680,18 +1665,12 @@ NTSTATUS init_sam_dispinfo_2(TALLOC_CTX *ctx, SAM_DISPINFO_2 *sam, uint32 num_en
return NT_STATUS_UNSUCCESSFUL;
}
- len_sam_name = strlen(username);
- len_sam_desc = strlen(acct_desc);
-
+ init_unistr2(&sam->str[i].uni_srv_name, username, UNI_FLAGS_NONE);
+ init_unistr2(&sam->str[i].uni_srv_desc, pdb_get_acct_desc(pwd), UNI_FLAGS_NONE);
+
init_sam_entry2(&sam->sam[i], start_idx + i + 1,
- len_sam_name, len_sam_desc,
+ &sam->str[i].uni_srv_name, &sam->str[i].uni_srv_desc,
user_rid, pdb_get_acct_ctrl(pwd));
-
- ZERO_STRUCTP(&sam->str[i].uni_srv_name);
- ZERO_STRUCTP(&sam->str[i].uni_srv_desc);
-
- init_unistr2(&sam->str[i].uni_srv_name, username, len_sam_name);
- init_unistr2(&sam->str[i].uni_srv_desc, pdb_get_acct_desc(pwd), len_sam_desc);
}
return NT_STATUS_OK;
@@ -1755,7 +1734,6 @@ inits a SAM_DISPINFO_3 structure.
NTSTATUS init_sam_dispinfo_3(TALLOC_CTX *ctx, SAM_DISPINFO_3 *sam, uint32 num_entries,
uint32 start_idx, DOMAIN_GRP *disp_group_info)
{
- uint32 len_sam_name, len_sam_desc;
uint32 i;
ZERO_STRUCTP(sam);
@@ -1779,13 +1757,11 @@ NTSTATUS init_sam_dispinfo_3(TALLOC_CTX *ctx, SAM_DISPINFO_3 *sam, uint32 num_en
DEBUG(11, ("init_sam_dispinfo_3: entry: %d\n",i));
- len_sam_name = strlen(grp->name);
- len_sam_desc = strlen(grp->comment);
+ init_unistr2(&sam->str[i].uni_grp_name, grp->name, UNI_FLAGS_NONE);
+ init_unistr2(&sam->str[i].uni_grp_desc, grp->comment, UNI_FLAGS_NONE);
- init_sam_entry3(&sam->sam[i], start_idx + i + 1, len_sam_name, len_sam_desc, grp->rid);
-
- init_unistr2(&sam->str[i].uni_grp_name, grp->name, len_sam_name);
- init_unistr2(&sam->str[i].uni_grp_desc, grp->comment, len_sam_desc);
+ init_sam_entry3(&sam->sam[i], start_idx + i + 1, &sam->str[i].uni_grp_name,
+ &sam->str[i].uni_grp_desc, grp->rid);
}
return NT_STATUS_OK;
@@ -2210,20 +2186,15 @@ void init_samr_group_info1(GROUP_INFO1 * gr1,
char *acct_name, char *acct_desc,
uint32 num_members)
{
- int desc_len = acct_desc != NULL ? strlen(acct_desc) : 0;
- int acct_len = acct_name != NULL ? strlen(acct_name) : 0;
-
DEBUG(5, ("init_samr_group_info1\n"));
- init_uni_hdr(&gr1->hdr_acct_name, acct_len);
-
gr1->unknown_1 = 0x3;
gr1->num_members = num_members;
- init_uni_hdr(&gr1->hdr_acct_desc, desc_len);
-
- init_unistr2(&gr1->uni_acct_name, acct_name, acct_len);
- init_unistr2(&gr1->uni_acct_desc, acct_desc, desc_len);
+ init_unistr2(&gr1->uni_acct_name, acct_name, UNI_FLAGS_NONE);
+ init_uni_hdr(&gr1->hdr_acct_name, &gr1->uni_acct_name);
+ init_unistr2(&gr1->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
+ init_uni_hdr(&gr1->hdr_acct_desc, &gr1->uni_acct_desc);
}
/*******************************************************************
@@ -2302,12 +2273,10 @@ inits a GROUP_INFO4 structure.
void init_samr_group_info4(GROUP_INFO4 * gr4, char *acct_desc)
{
- int acct_len = acct_desc != NULL ? strlen(acct_desc) : 0;
-
DEBUG(5, ("init_samr_group_info4\n"));
- init_uni_hdr(&gr4->hdr_acct_desc, acct_len);
- init_unistr2(&gr4->uni_acct_desc, acct_desc, acct_len);
+ init_unistr2(&gr4->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
+ init_uni_hdr(&gr4->hdr_acct_desc, &gr4->uni_acct_desc);
}
/*******************************************************************
@@ -2383,14 +2352,12 @@ void init_samr_q_create_dom_group(SAMR_Q_CREATE_DOM_GROUP * q_e,
POLICY_HND *pol, char *acct_desc,
uint32 access_mask)
{
- int acct_len = acct_desc != NULL ? strlen(acct_desc) : 0;
-
DEBUG(5, ("init_samr_q_create_dom_group\n"));
q_e->pol = *pol;
- init_uni_hdr(&q_e->hdr_acct_desc, acct_len);
- init_unistr2(&q_e->uni_acct_desc, acct_desc, acct_len);
+ init_unistr2(&q_e->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
+ init_uni_hdr(&q_e->hdr_acct_desc, &q_e->uni_acct_desc);
q_e->access_mask = access_mask;
}
@@ -3502,18 +3469,15 @@ inits a ALIAS_INFO1 structure.
void init_samr_alias_info1(ALIAS_INFO1 * al1, char *acct_name, uint32 num_member, char *acct_desc)
{
- int acct_len_name = acct_name != NULL ? strlen(acct_name) : 0;
- int acct_len_desc = acct_desc != NULL ? strlen(acct_desc) : 0;
-
DEBUG(5, ("init_samr_alias_info1\n"));
- init_uni_hdr(&al1->hdr_acct_name, acct_len_name);
- init_unistr2(&al1->uni_acct_name, acct_name, acct_len_name);
+ init_unistr2(&al1->uni_acct_name, acct_name, UNI_FLAGS_NONE);
+ init_uni_hdr(&al1->hdr_acct_name, &al1->uni_acct_name);
al1->num_member=num_member;
- init_uni_hdr(&al1->hdr_acct_desc, acct_len_desc);
- init_unistr2(&al1->uni_acct_desc, acct_desc, acct_len_desc);
+ init_unistr2(&al1->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
+ init_uni_hdr(&al1->hdr_acct_desc, &al1->uni_acct_name);
}
/*******************************************************************
@@ -3559,12 +3523,10 @@ inits a ALIAS_INFO3 structure.
void init_samr_alias_info3(ALIAS_INFO3 * al3, char *acct_desc)
{
- int acct_len = acct_desc != NULL ? strlen(acct_desc) : 0;
-
DEBUG(5, ("init_samr_alias_info3\n"));
- init_uni_hdr(&al3->hdr_acct_desc, acct_len);
- init_unistr2(&al3->uni_acct_desc, acct_desc, acct_len);
+ init_unistr2(&al3->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
+ init_uni_hdr(&al3->hdr_acct_desc, &al3->uni_acct_desc);
}
/*******************************************************************
@@ -4272,14 +4234,12 @@ inits a SAMR_Q_CREATE_DOM_ALIAS structure.
void init_samr_q_create_dom_alias(SAMR_Q_CREATE_DOM_ALIAS * q_u,
POLICY_HND *hnd, char *acct_desc)
{
- int acct_len = acct_desc != NULL ? strlen(acct_desc) : 0;
-
DEBUG(5, ("init_samr_q_create_dom_alias\n"));
q_u->dom_pol = *hnd;
- init_uni_hdr(&q_u->hdr_acct_desc, acct_len);
- init_unistr2(&q_u->uni_acct_desc, acct_desc, acct_len);
+ init_unistr2(&q_u->uni_acct_desc, acct_desc, UNI_FLAGS_NONE);
+ init_uni_hdr(&q_u->hdr_acct_desc, &q_u->uni_acct_desc);
q_u->access_mask = 0x001f000f;
}
@@ -4675,9 +4635,8 @@ NTSTATUS init_samr_q_lookup_names(TALLOC_CTX *ctx, SAMR_Q_LOOKUP_NAMES * q_u,
return NT_STATUS_NO_MEMORY;
for (i = 0; i < num_names; i++) {
- int len_name = name[i] != NULL ? strlen(name[i]) : 0;
- init_uni_hdr(&q_u->hdr_name[i], len_name); /* unicode header for user_name */
- init_unistr2(&q_u->uni_name[i], name[i], len_name); /* unicode string for machine account */
+ init_unistr2(&q_u->uni_name[i], name[i], UNI_FLAGS_NONE); /* unicode string for machine account */
+ init_uni_hdr(&q_u->hdr_name[i], &q_u->uni_name[i]); /* unicode header for user_name */
}
return NT_STATUS_OK;
@@ -5013,15 +4972,12 @@ void init_samr_q_create_user(SAMR_Q_CREATE_USER * q_u,
const char *name,
uint32 acb_info, uint32 access_mask)
{
- int len_name;
- len_name = strlen(name);
-
DEBUG(5, ("samr_init_samr_q_create_user\n"));
q_u->domain_pol = *pol;
- init_uni_hdr(&q_u->hdr_name, len_name);
- init_unistr2(&q_u->uni_name, name, len_name);
+ init_unistr2(&q_u->uni_name, name, UNI_FLAGS_NONE);
+ init_uni_hdr(&q_u->hdr_name, &q_u->uni_name);
q_u->acb_info = acb_info;
q_u->access_mask = access_mask;
@@ -5244,16 +5200,11 @@ void init_sam_user_info11(SAM_USER_INFO_11 * usr,
char *mach_acct,
uint32 rid_user, uint32 rid_group, uint16 acct_ctrl)
{
- int len_mach_acct;
-
DEBUG(5, ("init_sam_user_info11\n"));
- len_mach_acct = strlen(mach_acct);
-
- memcpy(&(usr->expiry), expiry, sizeof(usr->expiry)); /* expiry time or something? */
+ memcpy(&usr->expiry, expiry, sizeof(usr->expiry)); /* expiry time or something? */
ZERO_STRUCT(usr->padding_1); /* 0 - padding 24 bytes */
- init_uni_hdr(&usr->hdr_mach_acct, len_mach_acct); /* unicode header for machine account */
usr->padding_2 = 0; /* 0 - padding 4 bytes */
usr->ptr_1 = 1; /* pointer */
@@ -5278,7 +5229,8 @@ void init_sam_user_info11(SAM_USER_INFO_11 * usr,
ZERO_STRUCT(usr->padding_7); /* 0 - padding 16 bytes */
usr->padding_8 = 0; /* 0 - padding 4 bytes */
- init_unistr2(&usr->uni_mach_acct, mach_acct, len_mach_acct); /* unicode string for machine account */
+ init_unistr2(&usr->uni_mach_acct, mach_acct, UNI_FLAGS_NONE); /* unicode string for machine account */
+ init_uni_hdr(&usr->hdr_mach_acct, &usr->uni_mach_acct); /* unicode header for machine account */
}
/*******************************************************************
@@ -5441,17 +5393,6 @@ void init_sam_user_info23W(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all z
uint16 logon_count,
char newpass[516], uint32 unknown_6)
{
- int len_user_name = user_name != NULL ? user_name->uni_str_len : 0;
- int len_full_name = full_name != NULL ? full_name->uni_str_len : 0;
- int len_home_dir = home_dir != NULL ? home_dir->uni_str_len : 0;
- int len_dir_drive = dir_drive != NULL ? dir_drive->uni_str_len : 0;
- int len_logon_script = log_scr != NULL ? log_scr->uni_str_len : 0;
- int len_profile_path = prof_path != NULL ? prof_path->uni_str_len : 0;
- int len_description = desc != NULL ? desc->uni_str_len : 0;
- int len_workstations = wkstas != NULL ? wkstas->uni_str_len : 0;
- int len_unknown_str = unk_str != NULL ? unk_str->uni_str_len : 0;
- int len_munged_dial = mung_dial != NULL ? mung_dial->uni_str_len : 0;
-
usr->logon_time = *logon_time; /* all zeros */
usr->logoff_time = *logoff_time; /* all zeros */
usr->kickoff_time = *kickoff_time; /* all zeros */
@@ -5459,17 +5400,6 @@ void init_sam_user_info23W(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all z
usr->pass_can_change_time = *pass_can_change_time; /* all zeros */
usr->pass_must_change_time = *pass_must_change_time; /* all zeros */
- init_uni_hdr(&usr->hdr_user_name, len_user_name); /* NULL */
- init_uni_hdr(&usr->hdr_full_name, len_full_name);
- init_uni_hdr(&usr->hdr_home_dir, len_home_dir);
- init_uni_hdr(&usr->hdr_dir_drive, len_dir_drive);
- init_uni_hdr(&usr->hdr_logon_script, len_logon_script);
- init_uni_hdr(&usr->hdr_profile_path, len_profile_path);
- init_uni_hdr(&usr->hdr_acct_desc, len_description);
- init_uni_hdr(&usr->hdr_workstations, len_workstations);
- init_uni_hdr(&usr->hdr_unknown_str, len_unknown_str);
- init_uni_hdr(&usr->hdr_munged_dial, len_munged_dial);
-
ZERO_STRUCT(usr->nt_pwd);
ZERO_STRUCT(usr->lm_pwd);
@@ -5496,15 +5426,34 @@ void init_sam_user_info23W(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all z
memcpy(usr->pass, newpass, sizeof(usr->pass));
copy_unistr2(&usr->uni_user_name, user_name);
+ init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
+
copy_unistr2(&usr->uni_full_name, full_name);
+ init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
+
copy_unistr2(&usr->uni_home_dir, home_dir);
+ init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
+
copy_unistr2(&usr->uni_dir_drive, dir_drive);
+ init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
+
copy_unistr2(&usr->uni_logon_script, log_scr);
+ init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
+
copy_unistr2(&usr->uni_profile_path, prof_path);
+ init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
+
copy_unistr2(&usr->uni_acct_desc, desc);
+ init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
+
copy_unistr2(&usr->uni_workstations, wkstas);
+ init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
+
copy_unistr2(&usr->uni_unknown_str, unk_str);
+ init_uni_hdr(&usr->hdr_unknown_str, &usr->uni_unknown_str);
+
copy_unistr2(&usr->uni_munged_dial, mung_dial);
+ init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
usr->unknown_6 = unknown_6; /* 0x0000 04ec */
usr->padding4 = 0;
@@ -5536,17 +5485,6 @@ void init_sam_user_info23A(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all z
LOGON_HRS * hrs, uint16 bad_password_count, uint16 logon_count,
char newpass[516], uint32 unknown_6)
{
- int len_user_name = user_name != NULL ? strlen(user_name) : 0;
- int len_full_name = full_name != NULL ? strlen(full_name) : 0;
- int len_home_dir = home_dir != NULL ? strlen(home_dir) : 0;
- int len_dir_drive = dir_drive != NULL ? strlen(dir_drive) : 0;
- int len_logon_script = log_scr != NULL ? strlen(log_scr) : 0;
- int len_profile_path = prof_path != NULL ? strlen(prof_path) : 0;
- int len_description = desc != NULL ? strlen(desc) : 0;
- int len_workstations = wkstas != NULL ? strlen(wkstas) : 0;
- int len_unknown_str = unk_str != NULL ? strlen(unk_str) : 0;
- int len_munged_dial = mung_dial != NULL ? strlen(mung_dial) : 0;
-
usr->logon_time = *logon_time; /* all zeros */
usr->logoff_time = *logoff_time; /* all zeros */
usr->kickoff_time = *kickoff_time; /* all zeros */
@@ -5554,17 +5492,6 @@ void init_sam_user_info23A(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all z
usr->pass_can_change_time = *pass_can_change_time; /* all zeros */
usr->pass_must_change_time = *pass_must_change_time; /* all zeros */
- init_uni_hdr(&usr->hdr_user_name, len_user_name); /* NULL */
- init_uni_hdr(&usr->hdr_full_name, len_full_name);
- init_uni_hdr(&usr->hdr_home_dir, len_home_dir);
- init_uni_hdr(&usr->hdr_dir_drive, len_dir_drive);
- init_uni_hdr(&usr->hdr_logon_script, len_logon_script);
- init_uni_hdr(&usr->hdr_profile_path, len_profile_path);
- init_uni_hdr(&usr->hdr_acct_desc, len_description);
- init_uni_hdr(&usr->hdr_workstations, len_workstations);
- init_uni_hdr(&usr->hdr_unknown_str, len_unknown_str);
- init_uni_hdr(&usr->hdr_munged_dial, len_munged_dial);
-
ZERO_STRUCT(usr->nt_pwd);
ZERO_STRUCT(usr->lm_pwd);
@@ -5590,16 +5517,35 @@ void init_sam_user_info23A(SAM_USER_INFO_23 * usr, NTTIME * logon_time, /* all z
memcpy(usr->pass, newpass, sizeof(usr->pass));
- init_unistr2(&usr->uni_user_name, user_name, len_user_name); /* NULL */
- init_unistr2(&usr->uni_full_name, full_name, len_full_name);
- init_unistr2(&usr->uni_home_dir, home_dir, len_home_dir);
- init_unistr2(&usr->uni_dir_drive, dir_drive, len_dir_drive);
- init_unistr2(&usr->uni_logon_script, log_scr, len_logon_script);
- init_unistr2(&usr->uni_profile_path, prof_path, len_profile_path);
- init_unistr2(&usr->uni_acct_desc, desc, len_description);
- init_unistr2(&usr->uni_workstations, wkstas, len_workstations);
- init_unistr2(&usr->uni_unknown_str, unk_str, len_unknown_str);
- init_unistr2(&usr->uni_munged_dial, mung_dial, len_munged_dial);
+ init_unistr2(&usr->uni_user_name, user_name, UNI_FLAGS_NONE);
+ init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
+
+ init_unistr2(&usr->uni_full_name, full_name, UNI_FLAGS_NONE);
+ init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
+
+ init_unistr2(&usr->uni_home_dir, home_dir, UNI_FLAGS_NONE);
+ init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
+
+ init_unistr2(&usr->uni_dir_drive, dir_drive, UNI_FLAGS_NONE);
+ init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
+
+ init_unistr2(&usr->uni_logon_script, log_scr, UNI_FLAGS_NONE);
+ init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
+
+ init_unistr2(&usr->uni_profile_path, prof_path, UNI_FLAGS_NONE);
+ init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
+
+ init_unistr2(&usr->uni_acct_desc, desc, UNI_FLAGS_NONE);
+ init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
+
+ init_unistr2(&usr->uni_workstations, wkstas, UNI_FLAGS_NONE);
+ init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
+
+ init_unistr2(&usr->uni_unknown_str, unk_str, UNI_FLAGS_NONE);
+ init_uni_hdr(&usr->hdr_unknown_str, &usr->uni_unknown_str);
+
+ init_unistr2(&usr->uni_munged_dial, mung_dial, UNI_FLAGS_NONE);
+ init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
usr->unknown_6 = unknown_6; /* 0x0000 04ec */
usr->padding4 = 0;
@@ -5900,17 +5846,6 @@ void init_sam_user_info21W(SAM_USER_INFO_21 * usr,
uint16 logon_count,
uint32 unknown_6)
{
- int len_user_name = user_name != NULL ? user_name->uni_str_len : 0;
- int len_full_name = full_name != NULL ? full_name->uni_str_len : 0;
- int len_home_dir = home_dir != NULL ? home_dir->uni_str_len : 0;
- int len_dir_drive = dir_drive != NULL ? dir_drive->uni_str_len : 0;
- int len_logon_script = log_scr != NULL ? log_scr->uni_str_len : 0;
- int len_profile_path = prof_path != NULL ? prof_path->uni_str_len : 0;
- int len_description = desc != NULL ? desc->uni_str_len : 0;
- int len_workstations = wkstas != NULL ? wkstas->uni_str_len : 0;
- int len_unknown_str = unk_str != NULL ? unk_str->uni_str_len : 0;
- int len_munged_dial = mung_dial != NULL ? mung_dial->uni_str_len : 0;
-
usr->logon_time = *logon_time;
usr->logoff_time = *logoff_time;
usr->kickoff_time = *kickoff_time;
@@ -5918,17 +5853,6 @@ void init_sam_user_info21W(SAM_USER_INFO_21 * usr,
usr->pass_can_change_time = *pass_can_change_time;
usr->pass_must_change_time = *pass_must_change_time;
- init_uni_hdr(&usr->hdr_user_name, len_user_name);
- init_uni_hdr(&usr->hdr_full_name, len_full_name);
- init_uni_hdr(&usr->hdr_home_dir, len_home_dir);
- init_uni_hdr(&usr->hdr_dir_drive, len_dir_drive);
- init_uni_hdr(&usr->hdr_logon_script, len_logon_script);
- init_uni_hdr(&usr->hdr_profile_path, len_profile_path);
- init_uni_hdr(&usr->hdr_acct_desc, len_description);
- init_uni_hdr(&usr->hdr_workstations, len_workstations);
- init_uni_hdr(&usr->hdr_unknown_str, len_unknown_str);
- init_uni_hdr(&usr->hdr_munged_dial, len_munged_dial);
-
memcpy(usr->lm_pwd, lm_pwd, sizeof(usr->lm_pwd));
memcpy(usr->nt_pwd, nt_pwd, sizeof(usr->nt_pwd));
@@ -5952,15 +5876,34 @@ void init_sam_user_info21W(SAM_USER_INFO_21 * usr,
ZERO_STRUCT(usr->padding2);
copy_unistr2(&usr->uni_user_name, user_name);
+ init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
+
copy_unistr2(&usr->uni_full_name, full_name);
+ init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
+
copy_unistr2(&usr->uni_home_dir, home_dir);
+ init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
+
copy_unistr2(&usr->uni_dir_drive, dir_drive);
+ init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
+
copy_unistr2(&usr->uni_logon_script, log_scr);
+ init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
+
copy_unistr2(&usr->uni_profile_path, prof_path);
+ init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
+
copy_unistr2(&usr->uni_acct_desc, desc);
+ init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
+
copy_unistr2(&usr->uni_workstations, wkstas);
+ init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
+
copy_unistr2(&usr->uni_unknown_str, unk_str);
+ init_uni_hdr(&usr->hdr_unknown_str, &usr->uni_unknown_str);
+
copy_unistr2(&usr->uni_munged_dial, mung_dial);
+ init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
usr->unknown_6 = unknown_6; /* 0x0000 04ec */
usr->padding4 = 0;
@@ -5981,11 +5924,6 @@ NTSTATUS init_sam_user_info21A(SAM_USER_INFO_21 *usr, SAM_ACCOUNT *pw, DOM_SID *
NTTIME logon_time, logoff_time, kickoff_time,
pass_last_set_time, pass_can_change_time,
pass_must_change_time;
-
- int len_user_name, len_full_name, len_home_dir,
- len_dir_drive, len_logon_script, len_profile_path,
- len_description, len_workstations, len_unknown_str,
- len_munged_dial;
const char* user_name = pdb_get_username(pw);
const char* full_name = pdb_get_fullname(pw);
@@ -6003,18 +5941,6 @@ NTSTATUS init_sam_user_info21A(SAM_USER_INFO_21 *usr, SAM_ACCOUNT *pw, DOM_SID *
uint32 group_rid;
const DOM_SID *group_sid;
- len_user_name = user_name != NULL ? strlen(user_name )+1 : 0;
- len_full_name = full_name != NULL ? strlen(full_name )+1 : 0;
- len_home_dir = home_dir != NULL ? strlen(home_dir )+1 : 0;
- len_dir_drive = dir_drive != NULL ? strlen(dir_drive )+1 : 0;
- len_logon_script = logon_script != NULL ? strlen(logon_script)+1 : 0;
- len_profile_path = profile_path != NULL ? strlen(profile_path)+1 : 0;
- len_description = description != NULL ? strlen(description )+1 : 0;
- len_workstations = workstations != NULL ? strlen(workstations)+1 : 0;
- len_unknown_str = 0;
- len_munged_dial = munged_dial != NULL ? strlen(munged_dial )+1 : 0;
-
-
/* Create NTTIME structs */
unix_to_nt_time (&logon_time, pdb_get_logon_time(pw));
unix_to_nt_time (&logoff_time, pdb_get_logoff_time(pw));
@@ -6031,17 +5957,6 @@ NTSTATUS init_sam_user_info21A(SAM_USER_INFO_21 *usr, SAM_ACCOUNT *pw, DOM_SID *
usr->pass_can_change_time = pass_can_change_time;
usr->pass_must_change_time = pass_must_change_time;
- init_uni_hdr(&usr->hdr_user_name, len_user_name);
- init_uni_hdr(&usr->hdr_full_name, len_full_name);
- init_uni_hdr(&usr->hdr_home_dir, len_home_dir);
- init_uni_hdr(&usr->hdr_dir_drive, len_dir_drive);
- init_uni_hdr(&usr->hdr_logon_script, len_logon_script);
- init_uni_hdr(&usr->hdr_profile_path, len_profile_path);
- init_uni_hdr(&usr->hdr_acct_desc, len_description);
- init_uni_hdr(&usr->hdr_workstations, len_workstations);
- init_uni_hdr(&usr->hdr_unknown_str, len_unknown_str);
- init_uni_hdr(&usr->hdr_munged_dial, len_munged_dial);
-
ZERO_STRUCT(usr->nt_pwd);
ZERO_STRUCT(usr->lm_pwd);
@@ -6100,16 +6015,35 @@ NTSTATUS init_sam_user_info21A(SAM_USER_INFO_21 *usr, SAM_ACCOUNT *pw, DOM_SID *
ZERO_STRUCT(usr->padding1);
ZERO_STRUCT(usr->padding2);
- init_unistr2(&usr->uni_user_name, user_name, len_user_name);
- init_unistr2(&usr->uni_full_name, full_name, len_full_name);
- init_unistr2(&usr->uni_home_dir, home_dir, len_home_dir);
- init_unistr2(&usr->uni_dir_drive, dir_drive, len_dir_drive);
- init_unistr2(&usr->uni_logon_script, logon_script, len_logon_script);
- init_unistr2(&usr->uni_profile_path, profile_path, len_profile_path);
- init_unistr2(&usr->uni_acct_desc, description, len_description);
- init_unistr2(&usr->uni_workstations, workstations, len_workstations);
- init_unistr2(&usr->uni_unknown_str, NULL, len_unknown_str);
- init_unistr2(&usr->uni_munged_dial, munged_dial, len_munged_dial);
+ init_unistr2(&usr->uni_user_name, user_name, UNI_STR_TERMINATE);
+ init_uni_hdr(&usr->hdr_user_name, &usr->uni_user_name);
+
+ init_unistr2(&usr->uni_full_name, full_name, UNI_STR_TERMINATE);
+ init_uni_hdr(&usr->hdr_full_name, &usr->uni_full_name);
+
+ init_unistr2(&usr->uni_home_dir, home_dir, UNI_STR_TERMINATE);
+ init_uni_hdr(&usr->hdr_home_dir, &usr->uni_home_dir);
+
+ init_unistr2(&usr->uni_dir_drive, dir_drive, UNI_STR_TERMINATE);
+ init_uni_hdr(&usr->hdr_dir_drive, &usr->uni_dir_drive);
+
+ init_unistr2(&usr->uni_logon_script, logon_script, UNI_STR_TERMINATE);
+ init_uni_hdr(&usr->hdr_logon_script, &usr->uni_logon_script);
+
+ init_unistr2(&usr->uni_profile_path, profile_path, UNI_STR_TERMINATE);
+ init_uni_hdr(&usr->hdr_profile_path, &usr->uni_profile_path);
+
+ init_unistr2(&usr->uni_acct_desc, description, UNI_STR_TERMINATE);
+ init_uni_hdr(&usr->hdr_acct_desc, &usr->uni_acct_desc);
+
+ init_unistr2(&usr->uni_workstations, workstations, UNI_STR_TERMINATE);
+ init_uni_hdr(&usr->hdr_workstations, &usr->uni_workstations);
+
+ init_unistr2(&usr->uni_unknown_str, NULL, UNI_STR_TERMINATE);
+ init_uni_hdr(&usr->hdr_unknown_str, &usr->uni_unknown_str);
+
+ init_unistr2(&usr->uni_munged_dial, munged_dial, UNI_STR_TERMINATE);
+ init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
usr->unknown_6 = pdb_get_unknown_6(pw);
usr->padding4 = 0;
@@ -6249,12 +6183,10 @@ static BOOL sam_io_user_info21(const char *desc, SAM_USER_INFO_21 * usr,
void init_sam_user_info20A(SAM_USER_INFO_20 *usr, SAM_ACCOUNT *pw)
{
- int len_munged_dial;
- const char* munged_dial = pdb_get_munged_dial(pw);
+ const char *munged_dial = pdb_get_munged_dial(pw);
- len_munged_dial = munged_dial != NULL ? strlen(munged_dial )+1 : 0;
- init_uni_hdr(&usr->hdr_munged_dial, len_munged_dial);
- init_unistr2(&usr->uni_munged_dial, munged_dial, len_munged_dial);
+ init_unistr2(&usr->uni_munged_dial, munged_dial, UNI_STR_TERMINATE);
+ init_uni_hdr(&usr->hdr_munged_dial, &usr->uni_munged_dial);
}
@@ -6720,13 +6652,11 @@ inits a SAMR_Q_CONNECT structure.
void init_samr_q_connect(SAMR_Q_CONNECT * q_u,
char *srv_name, uint32 access_mask)
{
- int len_srv_name = strlen(srv_name);
-
DEBUG(5, ("init_samr_q_connect\n"));
/* make PDC server name \\server */
- q_u->ptr_srv_name = len_srv_name > 0 ? 1 : 0;
- init_unistr2(&q_u->uni_srv_name, srv_name, len_srv_name + 1);
+ q_u->ptr_srv_name = (srv_name != NULL && *srv_name) ? 1 : 0;
+ init_unistr2(&q_u->uni_srv_name, srv_name, UNI_STR_TERMINATE);
/* example values: 0x0000 0002 */
q_u->access_mask = access_mask;
@@ -6793,13 +6723,11 @@ inits a SAMR_Q_CONNECT4 structure.
void init_samr_q_connect4(SAMR_Q_CONNECT4 * q_u,
char *srv_name, uint32 access_mask)
{
- int len_srv_name = strlen(srv_name);
-
DEBUG(5, ("init_samr_q_connect\n"));
/* make PDC server name \\server */
- q_u->ptr_srv_name = len_srv_name > 0 ? 1 : 0;
- init_unistr2(&q_u->uni_srv_name, srv_name, len_srv_name + 1);
+ q_u->ptr_srv_name = (srv_name != NULL && *srv_name) ? 1 : 0;
+ init_unistr2(&q_u->uni_srv_name, srv_name, UNI_STR_TERMINATE);
/* Only value we've seen, possibly an address type ? */
q_u->unk_0 = 2;
@@ -6938,13 +6866,11 @@ inits a SAMR_Q_GET_DOM_PWINFO structure.
void init_samr_q_get_dom_pwinfo(SAMR_Q_GET_DOM_PWINFO * q_u,
char *srv_name)
{
- int len_srv_name = strlen(srv_name);
-
DEBUG(5, ("init_samr_q_get_dom_pwinfo\n"));
q_u->ptr = 1;
- init_uni_hdr(&q_u->hdr_srv_name, len_srv_name);
- init_unistr2(&q_u->uni_srv_name, srv_name, len_srv_name);
+ init_unistr2(&q_u->uni_srv_name, srv_name, UNI_FLAGS_NONE);
+ init_uni_hdr(&q_u->hdr_srv_name, &q_u->uni_srv_name);
}
/*******************************************************************
@@ -7105,16 +7031,14 @@ void init_samr_q_chgpasswd_user(SAMR_Q_CHGPASSWD_USER * q_u,
char lm_newpass[516],
uchar lm_oldhash[16])
{
- int len_dest_host = strlen(dest_host);
- int len_user_name = strlen(user_name);
-
DEBUG(5, ("init_samr_q_chgpasswd_user\n"));
q_u->ptr_0 = 1;
- init_uni_hdr(&q_u->hdr_dest_host, len_dest_host);
- init_unistr2(&q_u->uni_dest_host, dest_host, len_dest_host);
- init_uni_hdr(&q_u->hdr_user_name, len_user_name);
- init_unistr2(&q_u->uni_user_name, user_name, len_user_name);
+ init_unistr2(&q_u->uni_dest_host, dest_host, UNI_FLAGS_NONE);
+ init_uni_hdr(&q_u->hdr_dest_host, &q_u->uni_dest_host);
+
+ init_unistr2(&q_u->uni_user_name, user_name, UNI_FLAGS_NONE);
+ init_uni_hdr(&q_u->hdr_user_name, &q_u->uni_user_name);
init_enc_passwd(&q_u->nt_newpass, nt_newpass);
init_enc_hash(&q_u->nt_oldhash, nt_oldhash);
diff --git a/source3/rpc_parse/parse_spoolss.c b/source3/rpc_parse/parse_spoolss.c
index 7ca9bccab4..65f16414a0 100644
--- a/source3/rpc_parse/parse_spoolss.c
+++ b/source3/rpc_parse/parse_spoolss.c
@@ -916,12 +916,12 @@ BOOL make_spoolss_q_open_printer_ex(SPOOL_Q_OPEN_PRINTER_EX *q_u,
{
DEBUG(5,("make_spoolss_q_open_printer_ex\n"));
q_u->printername_ptr = (printername!=NULL)?1:0;
- init_unistr2(&q_u->printername, printername, strlen(printername)+1);
+ init_unistr2(&q_u->printername, printername, UNI_STR_TERMINATE);
q_u->printer_default.datatype_ptr = 0;
/*
q_u->printer_default.datatype_ptr = (datatype!=NULL)?1:0;
- init_unistr2(&q_u->printer_default.datatype, datatype, strlen(datatype));
+ init_unistr2(&q_u->printer_default.datatype, datatype, UNI_FLAGS_NONE);
*/
q_u->printer_default.devmode_cont.size=0;
q_u->printer_default.devmode_cont.devmode_ptr=0;
@@ -937,8 +937,8 @@ BOOL make_spoolss_q_open_printer_ex(SPOOL_Q_OPEN_PRINTER_EX *q_u,
q_u->user_ctr.user1.major=2;
q_u->user_ctr.user1.minor=0;
q_u->user_ctr.user1.processor=0;
- init_unistr2(&q_u->user_ctr.user1.client_name, clientname, strlen(clientname)+1);
- init_unistr2(&q_u->user_ctr.user1.user_name, user_name, strlen(user_name)+1);
+ init_unistr2(&q_u->user_ctr.user1.client_name, clientname, UNI_STR_TERMINATE);
+ init_unistr2(&q_u->user_ctr.user1.user_name, user_name, UNI_STR_TERMINATE);
return True;
}
@@ -963,7 +963,7 @@ BOOL make_spoolss_q_addprinterex(
ZERO_STRUCTP(q_u);
q_u->server_name_ptr = (srv_name!=NULL)?1:0;
- init_unistr2(&q_u->server_name, srv_name, strlen(srv_name));
+ init_unistr2(&q_u->server_name, srv_name, UNI_FLAGS_NONE);
q_u->level = level;
@@ -991,8 +991,8 @@ BOOL make_spoolss_q_addprinterex(
q_u->user_ctr.user1.major=2;
q_u->user_ctr.user1.minor=0;
q_u->user_ctr.user1.processor=0;
- init_unistr2(&q_u->user_ctr.user1.client_name, clientname, strlen(clientname)+1);
- init_unistr2(&q_u->user_ctr.user1.user_name, user_name, strlen(user_name)+1);
+ init_unistr2(&q_u->user_ctr.user1.client_name, clientname, UNI_STR_TERMINATE);
+ init_unistr2(&q_u->user_ctr.user1.user_name, user_name, UNI_STR_TERMINATE);
q_u->user_ctr.user1.size=q_u->user_ctr.user1.user_name.uni_str_len +
q_u->user_ctr.user1.client_name.uni_str_len + 2;
@@ -1187,15 +1187,13 @@ BOOL make_spoolss_q_deleteprinterdriver(
/* these must be NULL terminated or else NT4 will
complain about invalid parameters --jerry */
- init_unistr2(&q_u->server, server, strlen(server)+1);
- init_unistr2(&q_u->arch, arch, strlen(arch)+1);
- init_unistr2(&q_u->driver, driver, strlen(driver)+1);
-
+ init_unistr2(&q_u->server, server, UNI_STR_TERMINATE);
+ init_unistr2(&q_u->arch, arch, UNI_STR_TERMINATE);
+ init_unistr2(&q_u->driver, driver, UNI_STR_TERMINATE);
return True;
}
-
/*******************************************************************
* make a structure.
********************************************************************/
@@ -1209,7 +1207,7 @@ BOOL make_spoolss_q_getprinterdata(SPOOL_Q_GETPRINTERDATA *q_u,
DEBUG(5,("make_spoolss_q_getprinterdata\n"));
q_u->handle = *handle;
- init_unistr2(&q_u->valuename, valuename, strlen(valuename) + 1);
+ init_unistr2(&q_u->valuename, valuename, UNI_STR_TERMINATE);
q_u->size = size;
return True;
@@ -1229,8 +1227,8 @@ BOOL make_spoolss_q_getprinterdataex(SPOOL_Q_GETPRINTERDATAEX *q_u,
DEBUG(5,("make_spoolss_q_getprinterdataex\n"));
q_u->handle = *handle;
- init_unistr2(&q_u->valuename, valuename, strlen(valuename) + 1);
- init_unistr2(&q_u->keyname, keyname, strlen(keyname) + 1);
+ init_unistr2(&q_u->valuename, valuename, UNI_STR_TERMINATE);
+ init_unistr2(&q_u->keyname, keyname, UNI_STR_TERMINATE);
q_u->size = size;
return True;
@@ -5317,7 +5315,7 @@ BOOL smb_io_unibuffer(const char *desc, UNISTR2 *buffer, prs_struct *ps, int dep
{
if (buffer==NULL) return False;
- buffer->undoc=0;
+ buffer->offset=0;
buffer->uni_str_len=buffer->uni_max_len;
if(!prs_uint32("buffer_size", ps, depth, &buffer->uni_max_len))
@@ -5374,7 +5372,7 @@ BOOL make_spoolss_q_addprinterdriver(TALLOC_CTX *mem_ctx,
DEBUG(5,("make_spoolss_q_addprinterdriver\n"));
q_u->server_name_ptr = (srv_name!=NULL)?1:0;
- init_unistr2(&q_u->server_name, srv_name, strlen(srv_name)+1);
+ init_unistr2(&q_u->server_name, srv_name, UNI_STR_TERMINATE);
q_u->level = level;
@@ -6162,7 +6160,7 @@ BOOL make_spoolss_q_enumprinterdataex(SPOOL_Q_ENUMPRINTERDATAEX *q_u,
uint32 size)
{
memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
- init_unistr2(&q_u->key, key, strlen(key)+1);
+ init_unistr2(&q_u->key, key, UNI_STR_TERMINATE);
q_u->size = size;
return True;
@@ -6175,7 +6173,7 @@ BOOL make_spoolss_q_setprinterdata(SPOOL_Q_SETPRINTERDATA *q_u, const POLICY_HND
{
memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
q_u->type = data_type;
- init_unistr2(&q_u->value, value, strlen(value)+1);
+ init_unistr2(&q_u->value, value, UNI_STR_TERMINATE);
q_u->max_len = q_u->real_len = data_size;
q_u->data = (unsigned char *)data;
@@ -6191,8 +6189,8 @@ BOOL make_spoolss_q_setprinterdataex(SPOOL_Q_SETPRINTERDATAEX *q_u, const POLICY
{
memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
q_u->type = data_type;
- init_unistr2(&q_u->value, value, strlen(value)+1);
- init_unistr2(&q_u->key, key, strlen(key)+1);
+ init_unistr2(&q_u->value, value, UNI_STR_TERMINATE);
+ init_unistr2(&q_u->key, key, UNI_STR_TERMINATE);
q_u->max_len = q_u->real_len = data_size;
q_u->data = (unsigned char *)data;
@@ -6589,7 +6587,7 @@ BOOL make_spoolss_q_replyopenprinter(SPOOL_Q_REPLYOPENPRINTER *q_u,
if (q_u == NULL)
return False;
- init_unistr2(&q_u->string, string, strlen(string)+1);
+ init_unistr2(&q_u->string, string, UNI_STR_TERMINATE);
q_u->printer=printer;
q_u->type=type;
@@ -7092,7 +7090,7 @@ BOOL make_spoolss_q_enumprinterkey(SPOOL_Q_ENUMPRINTERKEY *q_u,
DEBUG(5,("make_spoolss_q_enumprinterkey\n"));
memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
- init_unistr2(&q_u->key, key, strlen(key)+1);
+ init_unistr2(&q_u->key, key, UNI_STR_TERMINATE);
q_u->size = size;
return True;
@@ -7161,7 +7159,7 @@ BOOL make_spoolss_q_deleteprinterkey(SPOOL_Q_DELETEPRINTERKEY *q_u,
DEBUG(5,("make_spoolss_q_deleteprinterkey\n"));
memcpy(&q_u->handle, hnd, sizeof(q_u->handle));
- init_unistr2(&q_u->keyname, keyname, strlen(keyname)+1);
+ init_unistr2(&q_u->keyname, keyname, UNI_STR_TERMINATE);
return True;
}
@@ -7382,8 +7380,8 @@ BOOL make_spoolss_q_getprintprocessordirectory(SPOOL_Q_GETPRINTPROCESSORDIRECTOR
{
DEBUG(5,("make_spoolss_q_getprintprocessordirectory\n"));
- init_unistr2(&q_u->name, name, strlen(name)+1);
- init_unistr2(&q_u->environment, environment, strlen(environment)+1);
+ init_unistr2(&q_u->name, name, UNI_STR_TERMINATE);
+ init_unistr2(&q_u->environment, environment, UNI_STR_TERMINATE);
q_u->level = level;
@@ -7509,7 +7507,7 @@ BOOL make_spoolss_q_setform(SPOOL_Q_SETFORM *q_u, POLICY_HND *handle,
q_u->level = level;
q_u->level2 = level;
memcpy(&q_u->form, form, sizeof(FORM));
- init_unistr2(&q_u->name, form_name, strlen(form_name) + 1);
+ init_unistr2(&q_u->name, form_name, UNI_STR_TERMINATE);
return True;
}
@@ -7522,7 +7520,7 @@ BOOL make_spoolss_q_deleteform(SPOOL_Q_DELETEFORM *q_u, POLICY_HND *handle,
const char *form)
{
memcpy(&q_u->handle, handle, sizeof(POLICY_HND));
- init_unistr2(&q_u->name, form, strlen(form) + 1);
+ init_unistr2(&q_u->name, form, UNI_STR_TERMINATE);
return True;
}
@@ -7536,7 +7534,7 @@ BOOL make_spoolss_q_getform(SPOOL_Q_GETFORM *q_u, POLICY_HND *handle,
{
memcpy(&q_u->handle, handle, sizeof(POLICY_HND));
q_u->level = level;
- init_unistr2(&q_u->formname, formname, strlen(formname) + 1);
+ init_unistr2(&q_u->formname, formname, UNI_STR_TERMINATE);
q_u->buffer=buffer;
q_u->offered=offered;
@@ -7642,17 +7640,9 @@ BOOL make_spoolss_q_startdocprinter(SPOOL_Q_STARTDOCPRINTER *q_u,
ctr->docinfo.doc_info_1.p_outputfile = outputfile ? 1 : 0;
ctr->docinfo.doc_info_1.p_datatype = datatype ? 1 : 0;
- if (docname)
- init_unistr2(&ctr->docinfo.doc_info_1.docname, docname,
- strlen(docname) + 1);
-
- if (outputfile)
- init_unistr2(&ctr->docinfo.doc_info_1.outputfile, outputfile,
- strlen(outputfile) + 1);
-
- if (datatype)
- init_unistr2(&ctr->docinfo.doc_info_1.datatype, datatype,
- strlen(datatype) + 1);
+ init_unistr2(&ctr->docinfo.doc_info_1.docname, docname, UNI_STR_TERMINATE);
+ init_unistr2(&ctr->docinfo.doc_info_1.outputfile, outputfile, UNI_STR_TERMINATE);
+ init_unistr2(&ctr->docinfo.doc_info_1.datatype, datatype, UNI_STR_TERMINATE);
break;
case 2:
@@ -7701,7 +7691,7 @@ BOOL make_spoolss_q_deleteprinterdata(SPOOL_Q_DELETEPRINTERDATA *q_u,
POLICY_HND *handle, char *valuename)
{
memcpy(&q_u->handle, handle, sizeof(POLICY_HND));
- init_unistr2(&q_u->valuename, valuename, strlen(valuename) + 1);
+ init_unistr2(&q_u->valuename, valuename, UNI_STR_TERMINATE);
return True;
}
@@ -7715,8 +7705,8 @@ BOOL make_spoolss_q_deleteprinterdataex(SPOOL_Q_DELETEPRINTERDATAEX *q_u,
char *value)
{
memcpy(&q_u->handle, handle, sizeof(POLICY_HND));
- init_unistr2(&q_u->valuename, value, strlen(value) + 1);
- init_unistr2(&q_u->keyname, key, strlen(key) + 1);
+ init_unistr2(&q_u->valuename, value, UNI_STR_TERMINATE);
+ init_unistr2(&q_u->keyname, key, UNI_STR_TERMINATE);
return True;
}
@@ -7736,8 +7726,7 @@ BOOL make_spoolss_q_rffpcnex(SPOOL_Q_RFFPCNEX *q_u, POLICY_HND *handle,
q_u->localmachine_ptr = 1;
- init_unistr2(&q_u->localmachine, localmachine,
- strlen(localmachine) + 1);
+ init_unistr2(&q_u->localmachine, localmachine, UNI_STR_TERMINATE);
q_u->printerlocal = printerlocal;
diff --git a/source3/rpc_parse/parse_srv.c b/source3/rpc_parse/parse_srv.c
index bbb5193ddc..6349fc1632 100644
--- a/source3/rpc_parse/parse_srv.c
+++ b/source3/rpc_parse/parse_srv.c
@@ -36,8 +36,7 @@ void init_srv_share_info0_str(SH_INFO_0_STR *sh0, const char *net_name)
{
DEBUG(5,("init_srv_share_info0_str\n"));
- if(net_name)
- init_unistr2(&sh0->uni_netname, net_name, strlen(net_name)+1);
+ init_unistr2(&sh0->uni_netname, net_name, UNI_STR_TERMINATE);
}
/*******************************************************************
@@ -101,10 +100,8 @@ void init_srv_share_info1_str(SH_INFO_1_STR *sh1, const char *net_name, const ch
{
DEBUG(5,("init_srv_share_info1_str\n"));
- if(net_name)
- init_unistr2(&sh1->uni_netname, net_name, strlen(net_name)+1);
- if(remark)
- init_unistr2(&sh1->uni_remark, remark, strlen(remark)+1);
+ init_unistr2(&sh1->uni_netname, net_name, UNI_STR_TERMINATE);
+ init_unistr2(&sh1->uni_remark, remark, UNI_STR_TERMINATE);
}
/*******************************************************************
@@ -184,14 +181,10 @@ void init_srv_share_info2_str(SH_INFO_2_STR *sh2,
{
DEBUG(5,("init_srv_share_info2_str\n"));
- if (net_name)
- init_unistr2(&sh2->uni_netname, net_name, strlen(net_name)+1);
- if (remark)
- init_unistr2(&sh2->uni_remark, remark, strlen(remark)+1);
- if (path)
- init_unistr2(&sh2->uni_path, path, strlen(path)+1);
- if (passwd)
- init_unistr2(&sh2->uni_passwd, passwd, strlen(passwd)+1);
+ init_unistr2(&sh2->uni_netname, net_name, UNI_STR_TERMINATE);
+ init_unistr2(&sh2->uni_remark, remark, UNI_STR_TERMINATE);
+ init_unistr2(&sh2->uni_path, path, UNI_STR_TERMINATE);
+ init_unistr2(&sh2->uni_passwd, passwd, UNI_STR_TERMINATE);
}
/*******************************************************************
@@ -296,10 +289,8 @@ void init_srv_share_info501_str(SH_INFO_501_STR *sh501,
{
DEBUG(5,("init_srv_share_info501_str\n"));
- if(net_name)
- init_unistr2(&sh501->uni_netname, net_name, strlen(net_name)+1);
- if(remark)
- init_unistr2(&sh501->uni_remark, remark, strlen(remark)+1);
+ init_unistr2(&sh501->uni_netname, net_name, UNI_STR_TERMINATE);
+ init_unistr2(&sh501->uni_remark, remark, UNI_STR_TERMINATE);
}
/*******************************************************************
@@ -446,17 +437,13 @@ void init_srv_share_info502_str(SH_INFO_502_STR *sh502str,
{
DEBUG(5,("init_srv_share_info502_str\n"));
- if(net_name)
- init_unistr2(&sh502str->uni_netname, net_name, strlen(net_name)+1);
- if(remark)
- init_unistr2(&sh502str->uni_remark, remark, strlen(remark)+1);
- if(path)
- init_unistr2(&sh502str->uni_path, path, strlen(path)+1);
- if(passwd)
- init_unistr2(&sh502str->uni_passwd, passwd, strlen(passwd)+1);
- sh502str->sd = psd;
+ init_unistr2(&sh502str->uni_netname, net_name, UNI_STR_TERMINATE);
+ init_unistr2(&sh502str->uni_remark, remark, UNI_STR_TERMINATE);
+ init_unistr2(&sh502str->uni_path, path, UNI_STR_TERMINATE);
+ init_unistr2(&sh502str->uni_passwd, passwd, UNI_STR_TERMINATE);
+ sh502str->sd = psd;
sh502str->reserved = 0;
- sh502str->sd_size = sd_size;
+ sh502str->sd_size = sd_size;
}
/*******************************************************************
@@ -551,8 +538,7 @@ void init_srv_share_info1004_str(SH_INFO_1004_STR *sh1004, const char *remark)
{
DEBUG(5,("init_srv_share_info1004_str\n"));
- if(remark)
- init_unistr2(&sh1004->uni_remark, remark, strlen(remark)+1);
+ init_unistr2(&sh1004->uni_remark, remark, UNI_STR_TERMINATE);
}
/*******************************************************************
@@ -659,8 +645,7 @@ void init_srv_share_info1007_str(SH_INFO_1007_STR *sh1007, const char *alternate
{
DEBUG(5,("init_srv_share_info1007_str\n"));
- if(alternate_directory_name)
- init_unistr2(&sh1007->uni_AlternateDirectoryName, alternate_directory_name, strlen(alternate_directory_name)+1);
+ init_unistr2(&sh1007->uni_AlternateDirectoryName, alternate_directory_name, UNI_STR_TERMINATE);
}
/*******************************************************************
@@ -1474,7 +1459,7 @@ void init_srv_q_net_share_add(SRV_Q_NET_SHARE_ADD *q, const char *srvname,
const char *path, const char *passwd)
{
q->ptr_srv_name = 1;
- init_unistr2(&q->uni_srv_name, srvname, strlen(srvname) +1);
+ init_unistr2(&q->uni_srv_name, srvname, UNI_STR_TERMINATE);
q->info.switch_value = q->info_level = 2;
q->info.ptr_share_ctr = 1;
@@ -1525,8 +1510,8 @@ void init_srv_q_net_share_del(SRV_Q_NET_SHARE_DEL *del, const char *srvname,
const char *sharename)
{
del->ptr_srv_name = 1;
- init_unistr2(&del->uni_srv_name, srvname, strlen(srvname) +1 );
- init_unistr2(&del->uni_share_name, sharename, strlen(sharename) + 1);
+ init_unistr2(&del->uni_srv_name, srvname, UNI_STR_TERMINATE);
+ init_unistr2(&del->uni_share_name, sharename, UNI_STR_TERMINATE);
}
/*******************************************************************
@@ -1589,7 +1574,7 @@ void init_srv_sess_info0_str(SESS_INFO_0_STR *ss0, const char *name)
{
DEBUG(5,("init_srv_sess_info0_str\n"));
- init_unistr2(&ss0->uni_name, name, strlen(name)+1);
+ init_unistr2(&ss0->uni_name, name, UNI_STR_TERMINATE);
}
/*******************************************************************
@@ -1703,8 +1688,8 @@ void init_srv_sess_info1_str(SESS_INFO_1_STR *ss1, const char *name, const char
{
DEBUG(5,("init_srv_sess_info1_str\n"));
- init_unistr2(&ss1->uni_name, name, strlen(name)+1);
- init_unistr2(&ss1->uni_user, user, strlen(user)+1);
+ init_unistr2(&ss1->uni_name, name, UNI_STR_TERMINATE);
+ init_unistr2(&ss1->uni_user, user, UNI_STR_TERMINATE);
}
/*******************************************************************
@@ -2075,8 +2060,8 @@ void init_srv_conn_info1_str(CONN_INFO_1_STR *ss1, const char *usr_name, const c
{
DEBUG(5,("init_srv_conn_info1_str\n"));
- init_unistr2(&ss1->uni_usr_name, usr_name, strlen(usr_name)+1);
- init_unistr2(&ss1->uni_net_name, net_name, strlen(net_name)+1);
+ init_unistr2(&ss1->uni_usr_name, usr_name, UNI_STR_TERMINATE);
+ init_unistr2(&ss1->uni_net_name, net_name, UNI_STR_TERMINATE);
}
/*******************************************************************
@@ -2365,8 +2350,8 @@ void init_srv_file_info3_str(FILE_INFO_3_STR *fi3, const char *user_name, const
{
DEBUG(5,("init_srv_file_info3_str\n"));
- init_unistr2(&fi3->uni_path_name, path_name, strlen(path_name)+1);
- init_unistr2(&fi3->uni_user_name, user_name, strlen(user_name)+1);
+ init_unistr2(&fi3->uni_path_name, path_name, UNI_STR_TERMINATE);
+ init_unistr2(&fi3->uni_user_name, user_name, UNI_STR_TERMINATE);
}
/*******************************************************************
@@ -2628,7 +2613,7 @@ void init_srv_q_net_file_close(SRV_Q_NET_FILE_CLOSE *q_n, const char *server,
uint32 file_id)
{
q_n->ptr_srv_name = 1;
- init_unistr2(&q_n->uni_srv_name, server, strlen(server) + 1);
+ init_unistr2(&q_n->uni_srv_name, server, UNI_STR_TERMINATE);
q_n->file_id = file_id;
}
@@ -3586,6 +3571,5 @@ BOOL srv_io_r_net_file_set_secdesc(const char *desc, SRV_R_NET_FILE_SET_SECDESC
void init_srv_q_net_remote_tod(SRV_Q_NET_REMOTE_TOD *q_u, const char *server)
{
q_u->ptr_srv_name = 1;
- init_unistr2(&q_u->uni_srv_name, server, strlen(server) + 1);
+ init_unistr2(&q_u->uni_srv_name, server, UNI_STR_TERMINATE);
}
-