diff options
author | Andrew Tridgell <tridge@samba.org> | 2003-01-17 04:58:45 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2003-01-17 04:58:45 +0000 |
commit | ec879eacc263043409b584797d1e8c39258ba125 (patch) | |
tree | 7a7775040b27f7fea0f7bd1c8f0ede91c9ce770d /source3/rpc_parse/parse_net.c | |
parent | ba51d1d888f98e196627486490e8569faeb641c2 (diff) | |
download | samba-ec879eacc263043409b584797d1e8c39258ba125.tar.gz samba-ec879eacc263043409b584797d1e8c39258ba125.tar.bz2 samba-ec879eacc263043409b584797d1e8c39258ba125.zip |
This removes the 3rd argument from init_unistr2(). There were 240
calls to init_unistr2() in the code and every one of them got the 3rd
argument incorrect, so I thought it best just to remove the argument.
The incorrect usage was caused by callers using strlen() to determine
the length of the string. The 3rd argument to init_unistr2() was
supposed to be the character length, not the byte length of the
string, so for non-english this could come out wrong.
I also removed the bogus 'always allocate at least 256 bytes'
hack. There may be some code that relies on this, but if there is then
the code is broken and needs fixing.
(This used to be commit b9eff31b1433c81fbff733e194914a40f25e3bda)
Diffstat (limited to 'source3/rpc_parse/parse_net.c')
-rw-r--r-- | source3/rpc_parse/parse_net.c | 51 |
1 files changed, 25 insertions, 26 deletions
diff --git a/source3/rpc_parse/parse_net.c b/source3/rpc_parse/parse_net.c index ac21e6f2dd..859ad6b408 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); else - init_unistr2(&info->uni_trusted_dc_name, "", 1); + init_unistr2(&info->uni_trusted_dc_name, ""); } /******************************************************************* @@ -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); } /******************************************************************* @@ -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); } /******************************************************************* @@ -447,7 +446,7 @@ void init_r_trust_dom(NET_R_TRUST_DOM_LIST *r_t, fstring domain_name; fstrcpy(domain_name, dom_name); strupper(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); /* the use of UNISTR2 here is non-standard. */ r_t->uni_trust_dom_name[i].undoc = 0x1; } @@ -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 ); + init_unistr2(&q_c->uni_logon_clnt, logon_clnt); memcpy(q_c->clnt_chal.data, clnt_chal->data, sizeof(clnt_chal->data)); @@ -958,9 +957,9 @@ 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); + init_unistr2(&id->uni_user_name, user_name); + init_unistr2(&id->uni_wksta_name, wksta_name); } /******************************************************************* @@ -1070,9 +1069,9 @@ 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); + init_unistr2(&id->uni_user_name, user_name); + init_unistr2(&id->uni_wksta_name, 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); @@ -1352,12 +1351,12 @@ 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); + init_unistr2(&usr->uni_full_name, full_name); + init_unistr2(&usr->uni_logon_script, logon_script); + init_unistr2(&usr->uni_profile_path, profile_path); + init_unistr2(&usr->uni_home_dir, home_dir); + init_unistr2(&usr->uni_dir_drive, dir_drive); usr->num_groups2 = num_groups; @@ -1368,8 +1367,8 @@ 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); + init_unistr2(&usr->uni_logon_dom, logon_dom); init_dom_sid2(&usr->dom_sid, dom_sid); /* "other" sids are set up above */ @@ -1665,8 +1664,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); + init_unistr2(&q_s->uni_cli_name, cli_name); if (cli_creds) memcpy(&q_s->cli_creds, cli_creds, sizeof(q_s->cli_creds)); @@ -2842,8 +2841,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); + init_unistr2(&q_s->uni_cli_name, cli_name); memcpy(&q_s->cli_creds, cli_creds, sizeof(q_s->cli_creds)); memset(&q_s->ret_creds, 0, sizeof(q_s->ret_creds)); |