summaryrefslogtreecommitdiff
path: root/source3/rpc_parse
diff options
context:
space:
mode:
authorLuke Leighton <lkcl@samba.org>1999-10-21 18:25:12 +0000
committerLuke Leighton <lkcl@samba.org>1999-10-21 18:25:12 +0000
commit52fed795e156b9db8a0f29d9087042ccdec093f5 (patch)
tree38680f9baf542752561306fe4df0bc0783070894 /source3/rpc_parse
parent6f9105c853020fde1691a28cd707d6d3f6561b4d (diff)
downloadsamba-52fed795e156b9db8a0f29d9087042ccdec093f5.tar.gz
samba-52fed795e156b9db8a0f29d9087042ccdec093f5.tar.bz2
samba-52fed795e156b9db8a0f29d9087042ccdec093f5.zip
turning some of the rpcclient functions dynamic. this is likely to
break a few things... (This used to be commit 4b06f303235d36903b6e9f55ee45b987d98256b0)
Diffstat (limited to 'source3/rpc_parse')
-rw-r--r--source3/rpc_parse/parse_lsa.c2
-rw-r--r--source3/rpc_parse/parse_samr.c120
2 files changed, 95 insertions, 27 deletions
diff --git a/source3/rpc_parse/parse_lsa.c b/source3/rpc_parse/parse_lsa.c
index 1f194aa874..4053da0721 100644
--- a/source3/rpc_parse/parse_lsa.c
+++ b/source3/rpc_parse/parse_lsa.c
@@ -906,7 +906,7 @@ BOOL lsa_io_r_lookup_sids(char *desc, LSA_R_LOOKUP_SIDS *r_s, prs_struct *ps, i
makes a structure.
********************************************************************/
BOOL make_q_lookup_names(LSA_Q_LOOKUP_NAMES *q_l, POLICY_HND *hnd,
- int num_names, const char **names)
+ int num_names, char **names)
{
int i;
if (q_l == NULL) return False;
diff --git a/source3/rpc_parse/parse_samr.c b/source3/rpc_parse/parse_samr.c
index f0c16469c5..9b5ed1d294 100644
--- a/source3/rpc_parse/parse_samr.c
+++ b/source3/rpc_parse/parse_samr.c
@@ -2689,6 +2689,12 @@ BOOL samr_io_r_query_usergroups(char *desc, SAMR_R_QUERY_USERGROUPS *r_u, prs_s
{
prs_uint32("num_entries2", ps, depth, &(r_u->num_entries2));
+ r_u->gid = malloc(r_u->num_entries2 * sizeof(r_u->gid[0]));
+ if (r_u->gid == NULL)
+ {
+ return False;
+ }
+
for (i = 0; i < r_u->num_entries2; i++)
{
prs_grow(ps);
@@ -3193,7 +3199,7 @@ makes a SAMR_Q_QUERY_USERALIASES structure.
********************************************************************/
BOOL make_samr_q_query_useraliases(SAMR_Q_QUERY_USERALIASES *q_u,
POLICY_HND *hnd,
- DOM_SID *sid)
+ uint32 *ptr_sid, DOM_SID2 *sid)
{
if (q_u == NULL || hnd == NULL) return False;
@@ -3205,10 +3211,8 @@ BOOL make_samr_q_query_useraliases(SAMR_Q_QUERY_USERALIASES *q_u,
q_u->ptr = 1;
q_u->num_sids2 = 1;
- {
- q_u->ptr_sid[0] = 1;
- make_dom_sid2(&q_u->sid[0], sid);
- }
+ q_u->ptr_sid = ptr_sid;
+ q_u->sid = sid;
return True;
}
@@ -3235,7 +3239,24 @@ BOOL samr_io_q_query_useraliases(char *desc, SAMR_Q_QUERY_USERALIASES *q_u, prs
prs_uint32("ptr ", ps, depth, &(q_u->ptr ));
prs_uint32("num_sids2", ps, depth, &(q_u->num_sids2));
- SMB_ASSERT_ARRAY(q_u->ptr_sid, q_u->num_sids2);
+ if (q_u->num_sids2 != 0)
+ {
+ q_u->ptr_sid = Realloc(q_u->ptr_sid, sizeof(q_u->ptr_sid[0]) *
+ q_u->num_sids2);
+ if (q_u->ptr_sid == NULL)
+ {
+ samr_free_q_query_useraliases(q_u);
+ return False;
+ }
+
+ q_u->sid = Realloc(q_u->sid,
+ sizeof(q_u->sid[0]) * q_u->num_sids2);
+ if (q_u->sid == NULL)
+ {
+ samr_free_q_query_useraliases(q_u);
+ return False;
+ }
+ }
for (i = 0; i < q_u->num_sids2; i++)
{
@@ -3255,9 +3276,31 @@ BOOL samr_io_q_query_useraliases(char *desc, SAMR_Q_QUERY_USERALIASES *q_u, prs
prs_align(ps);
+ if (!ps->io)
+ {
+ /* storing. memory no longer needed */
+ samr_free_q_query_useraliases(q_u);
+ }
return True;
}
+/*******************************************************************
+frees memory in a SAMR_Q_QUERY_USERALIASES structure.
+********************************************************************/
+void samr_free_q_query_useraliases(SAMR_Q_QUERY_USERALIASES *q_u)
+{
+ if (q_u->ptr_sid == NULL)
+ {
+ free(q_u->ptr_sid);
+ q_u->ptr_sid = NULL;
+ }
+
+ if (q_u->sid == NULL)
+ {
+ free(q_u->sid);
+ q_u->sid = NULL;
+ }
+}
/*******************************************************************
makes a SAMR_R_QUERY_USERALIASES structure.
@@ -3309,6 +3352,14 @@ BOOL samr_io_r_query_useraliases(char *desc, SAMR_R_QUERY_USERALIASES *r_u, prs
if (r_u->num_entries != 0)
{
+ r_u->rid = Realloc(r_u->rid,
+ sizeof(r_u->rid[0]) * r_u->num_entries);
+ if (r_u->rid == NULL)
+ {
+ samr_free_r_query_useraliases(r_u);
+ return False;
+ }
+
for (i = 0; i < r_u->num_entries2; i++)
{
slprintf(tmp, sizeof(tmp)-1, "rid[%02d]", i);
@@ -3318,10 +3369,27 @@ BOOL samr_io_r_query_useraliases(char *desc, SAMR_R_QUERY_USERALIASES *r_u, prs
prs_uint32("status", ps, depth, &(r_u->status));
+ if (!ps->io)
+ {
+ /* storing. memory no longer needed */
+ samr_free_r_query_useraliases(r_u);
+ }
return True;
}
/*******************************************************************
+frees memory in a SAMR_R_QUERY_USERALIASES structure.
+********************************************************************/
+void samr_free_r_query_useraliases(SAMR_R_QUERY_USERALIASES *r_u)
+{
+ if (r_u->rid == NULL)
+ {
+ free(r_u->rid);
+ r_u->rid = NULL;
+ }
+}
+
+/*******************************************************************
makes a SAMR_Q_OPEN_ALIAS structure.
********************************************************************/
BOOL make_samr_q_open_alias(SAMR_Q_OPEN_ALIAS *q_u, POLICY_HND *pol,
@@ -3426,8 +3494,6 @@ 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));
- SMB_ASSERT_ARRAY(q_u->rid, q_u->num_rids2);
-
for (i = 0; i < q_u->num_rids2; i++)
{
prs_grow(ps);
@@ -3463,26 +3529,28 @@ BOOL make_samr_r_lookup_rids(SAMR_R_LOOKUP_RIDS *r_u,
r_u->ptr_types = 1;
r_u->num_types2 = num_names;
- r_u->hdr_name = malloc(num_names * sizeof(r_u->hdr_name[0]));
- if (r_u->hdr_name == NULL)
- {
- return False;
- }
- r_u->uni_name = malloc(num_names * sizeof(r_u->uni_name[0]));
- if (r_u->uni_name == NULL)
- {
- free(r_u->hdr_name);
- return False;
- }
- r_u->type = malloc(r_u->num_types2 * sizeof(r_u->type[0]));
- if (r_u->type == NULL)
+ if (num_names != 0)
{
- free(r_u->hdr_name);
- free(r_u->uni_name);
- return False;
+ r_u->hdr_name = malloc(num_names * sizeof(r_u->hdr_name[0]));
+ if (r_u->hdr_name == NULL)
+ {
+ samr_free_r_lookup_rids(r_u);
+ return False;
+ }
+ r_u->uni_name = malloc(num_names * sizeof(r_u->uni_name[0]));
+ if (r_u->uni_name == NULL)
+ {
+ samr_free_r_lookup_rids(r_u);
+ return False;
+ }
+ r_u->type = malloc(r_u->num_types2 * sizeof(r_u->type[0]));
+ if (r_u->type == NULL)
+ {
+ samr_free_r_lookup_rids(r_u);
+ return False;
+ }
}
-
for (i = 0; i < num_names; i++)
{
int len = name[i] != NULL ? strlen(name[i]) : 0;
@@ -4037,7 +4105,7 @@ makes a SAMR_Q_LOOKUP_NAMES structure.
********************************************************************/
BOOL make_samr_q_lookup_names(SAMR_Q_LOOKUP_NAMES *q_u,
POLICY_HND *pol, uint32 flags,
- uint32 num_names, const char **name)
+ uint32 num_names, char **name)
{
int i;
if (q_u == NULL) return False;