summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/include/proto.h6
-rw-r--r--source3/lib/domain_namemap.c2
-rw-r--r--source3/rpc_client/cli_samr.c11
-rw-r--r--source3/rpc_parse/parse_samr.c77
-rw-r--r--source3/rpc_server/srv_samr.c3
-rw-r--r--source3/rpcclient/cmd_lsarpc.c2
-rw-r--r--source3/rpcclient/cmd_netlogon.c6
-rw-r--r--source3/rpcclient/cmd_samr.c26
8 files changed, 106 insertions, 27 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index a142f3e4b5..7cbddd2084 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -1873,7 +1873,7 @@ BOOL delete_samr_dom_group(struct cli_state *cli, uint16 fnum,
BOOL get_samr_query_groupmem(struct cli_state *cli, uint16 fnum,
POLICY_HND *pol_open_domain,
uint32 group_rid, uint32 *num_mem,
- uint32 *rid, uint32 *attr);
+ uint32 **rid, uint32 **attr);
BOOL delete_samr_dom_alias(struct cli_state *cli, uint16 fnum,
POLICY_HND *pol_open_domain,
uint32 alias_rid);
@@ -1977,7 +1977,7 @@ BOOL samr_query_useraliases(struct cli_state *cli, uint16 fnum,
uint32 *num_aliases, uint32 **rid);
BOOL samr_query_groupmem(struct cli_state *cli, uint16 fnum,
POLICY_HND *group_pol,
- uint32 *num_mem, uint32 *rid, uint32 *attr);
+ uint32 *num_mem, uint32 **rid, uint32 **attr);
BOOL samr_query_usergroups(struct cli_state *cli, uint16 fnum,
POLICY_HND *pol, uint32 *num_groups,
DOM_GID **gid);
@@ -2585,6 +2585,7 @@ BOOL samr_io_q_query_groupmem(char *desc, SAMR_Q_QUERY_GROUPMEM *q_u, prs_struc
BOOL make_samr_r_query_groupmem(SAMR_R_QUERY_GROUPMEM *r_u,
uint32 num_entries, uint32 *rid, uint32 *attr, uint32 status);
BOOL samr_io_r_query_groupmem(char *desc, SAMR_R_QUERY_GROUPMEM *r_u, prs_struct *ps, int depth);
+void samr_free_r_query_groupmem(SAMR_R_QUERY_GROUPMEM *r_u);
BOOL make_samr_q_query_usergroups(SAMR_Q_QUERY_USERGROUPS *q_u,
POLICY_HND *hnd);
BOOL samr_io_q_query_usergroups(char *desc, SAMR_Q_QUERY_USERGROUPS *q_u, prs_struct *ps, int depth);
@@ -2634,6 +2635,7 @@ BOOL make_samr_q_lookup_rids(SAMR_Q_LOOKUP_RIDS *q_u,
POLICY_HND *pol, uint32 flags,
uint32 num_rids, uint32 *rid);
BOOL samr_io_q_lookup_rids(char *desc, SAMR_Q_LOOKUP_RIDS *q_u, prs_struct *ps, int depth);
+void samr_free_q_lookup_rids(SAMR_Q_LOOKUP_RIDS *q_u);
BOOL make_samr_r_lookup_rids(SAMR_R_LOOKUP_RIDS *r_u,
uint32 num_names, fstring *name, uint8 *type,
uint32 status);
diff --git a/source3/lib/domain_namemap.c b/source3/lib/domain_namemap.c
index ed4325a4d7..05b67632a2 100644
--- a/source3/lib/domain_namemap.c
+++ b/source3/lib/domain_namemap.c
@@ -889,7 +889,7 @@ static BOOL lookup_remote_ntname(const char *ntname, DOM_SID *sid, uint8 *type)
uint32 num_sids;
DOM_SID *sids;
uint8 *types;
- const char *names[1];
+ char *names[1];
DEBUG(5,("lookup_remote_ntname: %s\n", ntname));
diff --git a/source3/rpc_client/cli_samr.c b/source3/rpc_client/cli_samr.c
index c19a01d213..8e051d4f98 100644
--- a/source3/rpc_client/cli_samr.c
+++ b/source3/rpc_client/cli_samr.c
@@ -215,7 +215,7 @@ do a SAMR query group members
BOOL get_samr_query_groupmem(struct cli_state *cli, uint16 fnum,
POLICY_HND *pol_open_domain,
uint32 group_rid, uint32 *num_mem,
- uint32 *rid, uint32 *attr)
+ uint32 **rid, uint32 **attr)
{
POLICY_HND pol_open_group;
BOOL ret = True;
@@ -2142,7 +2142,7 @@ do a SAMR Query Group Members
****************************************************************************/
BOOL samr_query_groupmem(struct cli_state *cli, uint16 fnum,
POLICY_HND *group_pol,
- uint32 *num_mem, uint32 *rid, uint32 *attr)
+ uint32 *num_mem, uint32 **rid, uint32 **attr)
{
prs_struct data;
prs_struct rdata;
@@ -2171,11 +2171,12 @@ BOOL samr_query_groupmem(struct cli_state *cli, uint16 fnum,
SAMR_R_QUERY_GROUPMEM r_o;
BOOL p;
- /* get user info */
- r_o.rid = rid;
- r_o.attr = attr;
+ r_o.rid = NULL;
+ r_o.attr = NULL;
samr_io_r_query_groupmem("", &r_o, &rdata, 0);
+ *rid = r_o.rid ;
+ *attr = r_o.attr;
p = rdata.offset != 0;
if (p && r_o.status != 0)
diff --git a/source3/rpc_parse/parse_samr.c b/source3/rpc_parse/parse_samr.c
index 9b5ed1d294..69c7599a98 100644
--- a/source3/rpc_parse/parse_samr.c
+++ b/source3/rpc_parse/parse_samr.c
@@ -2576,6 +2576,17 @@ BOOL samr_io_r_query_groupmem(char *desc, SAMR_R_QUERY_GROUPMEM *r_u, prs_struc
if (r_u->ptr_rids != 0)
{
prs_uint32("num_rids", ps, depth, &(r_u->num_rids));
+ if (r_u->num_rids != 0)
+ {
+ r_u->rid = Realloc(r_u->rid,
+ sizeof(r_u->rid[0]) *
+ r_u->num_rids);
+ if (r_u->rid == NULL)
+ {
+ samr_free_r_query_groupmem(r_u);
+ return False;
+ }
+ }
for (i = 0; i < r_u->num_rids; i++)
{
prs_grow(ps);
@@ -2586,6 +2597,18 @@ BOOL samr_io_r_query_groupmem(char *desc, SAMR_R_QUERY_GROUPMEM *r_u, prs_struc
if (r_u->ptr_attrs != 0)
{
prs_uint32("num_attrs", ps, depth, &(r_u->num_attrs));
+
+ if (r_u->num_attrs != 0)
+ {
+ r_u->attr = Realloc(r_u->attr,
+ sizeof(r_u->attr[0]) *
+ r_u->num_attrs);
+ if (r_u->attr == NULL)
+ {
+ samr_free_r_query_groupmem(r_u);
+ return False;
+ }
+ }
for (i = 0; i < r_u->num_attrs; i++)
{
prs_grow(ps);
@@ -2596,11 +2619,34 @@ BOOL samr_io_r_query_groupmem(char *desc, SAMR_R_QUERY_GROUPMEM *r_u, prs_struc
prs_uint32("status", ps, depth, &(r_u->status));
+ if (!ps->io)
+ {
+ /* storing. memory no longer needed */
+ samr_free_r_query_groupmem(r_u);
+ }
+
return True;
}
/*******************************************************************
+frees a structure.
+********************************************************************/
+void samr_free_r_query_groupmem(SAMR_R_QUERY_GROUPMEM *r_u)
+{
+ if (r_u->rid != NULL)
+ {
+ free(r_u->rid);
+ r_u->rid = NULL;
+ }
+ if (r_u->attr != NULL)
+ {
+ free(r_u->attr);
+ r_u->attr = NULL;
+ }
+}
+
+/*******************************************************************
makes a SAMR_Q_QUERY_USERGROUPS structure.
********************************************************************/
BOOL make_samr_q_query_usergroups(SAMR_Q_QUERY_USERGROUPS *q_u,
@@ -3494,6 +3540,17 @@ BOOL samr_io_q_lookup_rids(char *desc, SAMR_Q_LOOKUP_RIDS *q_u, prs_struct *ps,
prs_uint32("ptr ", ps, depth, &(q_u->ptr ));
prs_uint32("num_rids2", ps, depth, &(q_u->num_rids2));
+ if (q_u->num_rids2 != 0)
+ {
+ q_u->rid = Realloc(q_u->rid, sizeof(q_u->rid[0]) *
+ q_u->num_rids2);
+ if (q_u->rid == NULL)
+ {
+ samr_free_q_lookup_rids(q_u);
+ return False;
+ }
+ }
+
for (i = 0; i < q_u->num_rids2; i++)
{
prs_grow(ps);
@@ -3503,9 +3560,27 @@ BOOL samr_io_q_lookup_rids(char *desc, SAMR_Q_LOOKUP_RIDS *q_u, prs_struct *ps,
prs_align(ps);
+ if (!ps->io)
+ {
+ /* storing. don't need memory any more */
+ samr_free_q_lookup_rids(q_u);
+ }
+
return True;
}
+/*******************************************************************
+frees a structure.
+********************************************************************/
+void samr_free_q_lookup_rids(SAMR_Q_LOOKUP_RIDS *q_u)
+{
+ if (q_u->rid != NULL)
+ {
+ free(q_u->rid);
+ q_u->rid = NULL;
+ }
+}
+
/*******************************************************************
makes a SAMR_R_LOOKUP_RIDS structure.
@@ -3666,7 +3741,7 @@ BOOL samr_io_r_lookup_rids(char *desc, SAMR_R_LOOKUP_RIDS *r_u, prs_struct *ps,
}
/*******************************************************************
-reads or writes a structure.
+frees a structure.
********************************************************************/
void samr_free_r_lookup_rids(SAMR_R_LOOKUP_RIDS *r_u)
{
diff --git a/source3/rpc_server/srv_samr.c b/source3/rpc_server/srv_samr.c
index 876035186e..b1ee0cfe31 100644
--- a/source3/rpc_server/srv_samr.c
+++ b/source3/rpc_server/srv_samr.c
@@ -1242,6 +1242,7 @@ static void samr_reply_query_useraliases(SAMR_Q_QUERY_USERALIASES *q_u,
fstring usr_sid_str;
SAMR_R_QUERY_USERALIASES r_u;
+ ZERO_STRUCT(r_u);
DEBUG(5,("samr_query_useraliases: %d\n", __LINE__));
@@ -1340,6 +1341,7 @@ static void api_samr_query_useraliases( pipes_struct *p, prs_struct *data, prs_s
SAMR_Q_QUERY_USERALIASES q_u;
samr_io_q_query_useraliases("", &q_u, data, 0);
samr_reply_query_useraliases(&q_u, rdata);
+ samr_free_q_query_useraliases(&q_u);
}
/*******************************************************************
@@ -1704,6 +1706,7 @@ static void api_samr_lookup_rids( pipes_struct *p, prs_struct *data, prs_struct
SAMR_Q_LOOKUP_RIDS q_u;
samr_io_q_lookup_rids("", &q_u, data, 0);
samr_reply_lookup_rids(&q_u, rdata);
+ samr_free_q_lookup_rids(&q_u);
}
diff --git a/source3/rpcclient/cmd_lsarpc.c b/source3/rpcclient/cmd_lsarpc.c
index 57336362d1..d0e429801e 100644
--- a/source3/rpcclient/cmd_lsarpc.c
+++ b/source3/rpcclient/cmd_lsarpc.c
@@ -129,7 +129,7 @@ void cmd_lsa_lookup_names(struct client_info *info)
int i;
fstring srv_name;
int num_names = 0;
- const char *names[10];
+ char *names[10];
DOM_SID *sids = NULL;
int num_sids = 0;
#if 0
diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c
index c9eee7bf8a..3652218692 100644
--- a/source3/rpcclient/cmd_netlogon.c
+++ b/source3/rpcclient/cmd_netlogon.c
@@ -166,7 +166,7 @@ void cmd_netlogon_domain_test(struct client_info *info)
res = res ? cli_nt_session_open(smb_cli, PIPE_NETLOGON, &nt_pipe_fnum) : False;
res = res ? cli_nt_setup_creds(smb_cli, nt_pipe_fnum, inter_dom_acct,
- trust_passwd, global_myname,
+ global_myname, trust_passwd,
SEC_CHAN_DOMAIN) == 0x0 : False;
memset(trust_passwd, 0, 16);
@@ -195,8 +195,8 @@ void cmd_sam_sync(struct client_info *info)
return;
}
- if (do_sam_sync(smb_cli, global_myname,
- trust_passwd, hdr_deltas, deltas, &num))
+ if (do_sam_sync(smb_cli, trust_passwd, global_myname,
+ hdr_deltas, deltas, &num))
{
display_sam_sync(out_hnd, ACTION_HEADER , hdr_deltas, deltas, num);
display_sam_sync(out_hnd, ACTION_ENUMERATE, hdr_deltas, deltas, num);
diff --git a/source3/rpcclient/cmd_samr.c b/source3/rpcclient/cmd_samr.c
index 910db7eae3..66b10319ed 100644
--- a/source3/rpcclient/cmd_samr.c
+++ b/source3/rpcclient/cmd_samr.c
@@ -1311,12 +1311,6 @@ static void req_alias_info(struct client_info *info, uint16 fnum,
}
}
- if (rid != NULL)
- {
- free(rid);
- rid = NULL;
- }
-
/* send user alias query */
if (samr_query_useraliases(smb_cli, fnum,
&info->dom.samr_pol_open_builtindom,
@@ -1347,11 +1341,6 @@ static void req_alias_info(struct client_info *info, uint16 fnum,
free(ptr_sid);
ptr_sid = NULL;
}
- if (rid != NULL)
- {
- free(rid);
- rid = NULL;
- }
if (als_sid != NULL)
{
free(als_sid);
@@ -1987,13 +1976,13 @@ static void req_groupmem_info(struct client_info *info, uint16 fnum,
uint32 group_rid)
{
uint32 num_mem;
- uint32 rid_mem[MAX_LOOKUP_SIDS];
- uint32 attr_mem[MAX_LOOKUP_SIDS];
+ uint32 *rid_mem = NULL;
+ uint32 *attr_mem = NULL;
/* get group members */
if (get_samr_query_groupmem(smb_cli, fnum,
&info->dom.samr_pol_open_domain,
- group_rid, &num_mem, rid_mem, attr_mem))
+ group_rid, &num_mem, &rid_mem, &attr_mem))
{
BOOL res3 = True;
int num_names = 0;
@@ -2017,6 +2006,15 @@ static void req_groupmem_info(struct client_info *info, uint16 fnum,
free(type);
}
}
+
+ if (attr_mem != NULL)
+ {
+ free(attr_mem);
+ }
+ if (rid_mem != NULL)
+ {
+ free(rid_mem);
+ }
}
/****************************************************************************