summaryrefslogtreecommitdiffstats
path: root/source3/rpc_parse
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2000-12-12 02:45:11 +0000
committerJeremy Allison <jra@samba.org>2000-12-12 02:45:11 +0000
commit20ac3fc77e9423ab13a2cc1a2ef3d266f5b233e0 (patch)
treee3d55ebe50dda9d3368993b5664facf3c1b268be /source3/rpc_parse
parent276364e2a4cee00f4521845347a0b0a371f6b0e6 (diff)
downloadsamba-20ac3fc77e9423ab13a2cc1a2ef3d266f5b233e0.tar.gz
samba-20ac3fc77e9423ab13a2cc1a2ef3d266f5b233e0.tar.xz
samba-20ac3fc77e9423ab13a2cc1a2ef3d266f5b233e0.zip
Merged in Tim's changes : Removed static limit of MAX_LOOKUP_SIDS in rpc server and client
lsa_lookup_names() and lsa_lookup_sids(). Jeremy. (This used to be commit 9e9c71c8b3194b7cd02fea0b6a000d4f2940d905)
Diffstat (limited to 'source3/rpc_parse')
-rw-r--r--source3/rpc_parse/parse_lsa.c142
1 files changed, 101 insertions, 41 deletions
diff --git a/source3/rpc_parse/parse_lsa.c b/source3/rpc_parse/parse_lsa.c
index a53c07366e2..6a2e504f791 100644
--- a/source3/rpc_parse/parse_lsa.c
+++ b/source3/rpc_parse/parse_lsa.c
@@ -297,10 +297,10 @@ void init_q_open_pol(LSA_Q_OPEN_POL *r_q, uint16 system_name,
Reads or writes an LSA_Q_OPEN_POL structure.
********************************************************************/
-BOOL lsa_io_q_open_pol(char *desc, LSA_Q_OPEN_POL *r_q, prs_struct *ps,
- int depth)
+BOOL lsa_io_q_open_pol(char *desc, LSA_Q_OPEN_POL *r_q, prs_struct *ps, int depth)
{
- if (r_q == NULL) return False;
+ if (r_q == NULL)
+ return False;
prs_debug(ps, depth, desc, "lsa_io_q_open_pol");
depth++;
@@ -309,7 +309,7 @@ BOOL lsa_io_q_open_pol(char *desc, LSA_Q_OPEN_POL *r_q, prs_struct *ps,
return False;
if(!prs_uint16("system_name", ps, depth, &r_q->system_name))
return False;
- if(!prs_align(ps))
+ if(!prs_align( ps ))
return False;
if(!lsa_io_obj_attr("", &r_q->attr, ps, depth))
@@ -353,7 +353,7 @@ void init_q_open_pol2(LSA_Q_OPEN_POL2 *r_q, char *server_name,
uint32 desired_access,
LSA_SEC_QOS *qos)
{
- DEBUG(5, ("init_open_pol2: attr:%d da:%d\n", attributes,
+ DEBUG(5, ("init_q_open_pol2: attr:%d da:%d\n", attributes,
desired_access));
r_q->ptr = 1; /* undocumented pointer */
@@ -648,21 +648,43 @@ BOOL lsa_io_r_query(char *desc, LSA_R_QUERY_INFO *r_q, prs_struct *ps, int depth
Inits a LSA_SID_ENUM structure.
********************************************************************/
-void init_lsa_sid_enum(LSA_SID_ENUM *sen, int num_entries, DOM_SID *sids)
+void init_lsa_sid_enum(TALLOC_CTX *mem_ctx, LSA_SID_ENUM *sen,
+ int num_entries, DOM_SID **sids)
{
- int i;
+ int i, i2;
DEBUG(5, ("init_lsa_sid_enum\n"));
sen->num_entries = num_entries;
- sen->ptr_sid_enum = num_entries != 0;
+ sen->ptr_sid_enum = (num_entries != 0);
sen->num_entries2 = num_entries;
- SMB_ASSERT_ARRAY(sen->sid, sen->num_entries);
+ /* Allocate memory for sids and sid pointers */
+
+ if (num_entries == 0) return;
+
+ if ((sen->ptr_sid = (uint32 *)talloc(mem_ctx, num_entries *
+ sizeof(uint32))) == NULL) {
+ DEBUG(3, ("init_lsa_sid_enum(): out of memory for ptr_sid\n"));
+ return;
+ }
+
+ if ((sen->sid = (DOM_SID2 *)talloc(mem_ctx, num_entries *
+ sizeof(DOM_SID2))) == NULL) {
+ DEBUG(3, ("init_lsa_sid_enum(): out of memory for sids\n"));
+ return;
+ }
+
+ /* Copy across SIDs and SID pointers */
- for (i = 0; i < num_entries; i++) {
- sen->ptr_sid[i] = 1;
- init_dom_sid2(&sen->sid[i], &sids[i]);
+ for (i = 0, i2 = 0; i < num_entries; i++) {
+ if (sids[i] != NULL) {
+ sen->ptr_sid[i] = 1;
+ init_dom_sid2(&sen->sid[i2], sids[i]);
+ i2++;
+ } else {
+ sen->ptr_sid[i] = 0;
+ }
}
}
@@ -670,13 +692,12 @@ void init_lsa_sid_enum(LSA_SID_ENUM *sen, int num_entries, DOM_SID *sids)
Reads or writes a LSA_SID_ENUM structure.
********************************************************************/
-static BOOL lsa_io_sid_enum(char *desc, LSA_SID_ENUM *sen,
- prs_struct *ps, int depth)
+static BOOL lsa_io_sid_enum(char *desc, LSA_SID_ENUM *sen,
+ prs_struct *ps, int depth)
{
int i;
- if (sen == NULL)
- return False;
+ if (sen == NULL) return False;
prs_debug(ps, depth, desc, "lsa_io_sid_enum");
depth++;
@@ -691,22 +712,40 @@ static BOOL lsa_io_sid_enum(char *desc, LSA_SID_ENUM *sen,
if(!prs_uint32("num_entries2", ps, depth, &sen->num_entries2))
return False;
- SMB_ASSERT_ARRAY(sen->ptr_sid, sen->num_entries);
+ /* Mallocate memory if we're unpacking from the wire */
+
+ if (UNMARSHALLING(ps)) {
+ if ((sen->ptr_sid = (uint32 *)malloc(
+ sen->num_entries * sizeof(uint32))) == NULL) {
+ DEBUG(3, ("init_lsa_sid_enum(): out of memory for "
+ "ptr_sid\n"));
+ return False;
+ }
+
+ if ((sen->sid = (DOM_SID2 *)malloc(
+ sen->num_entries * sizeof(DOM_SID2))) == NULL) {
+ DEBUG(3, ("init_lsa_sid_enum(): out of memory for "
+ "sids\n"));
+ return False;
+ }
+ }
for (i = 0; i < sen->num_entries; i++) {
fstring temp;
+
slprintf(temp, sizeof(temp) - 1, "ptr_sid[%d]", i);
- if(!prs_uint32(temp, ps, depth, &sen->ptr_sid[i])) /* domain SID pointers to be looked up. */
+ if(!prs_uint32(temp, ps, depth, &sen->ptr_sid[i])) {
return False;
+ }
}
- SMB_ASSERT_ARRAY(sen->sid, sen->num_entries);
-
for (i = 0; i < sen->num_entries; i++) {
fstring temp;
+
slprintf(temp, sizeof(temp) - 1, "sid[%d]", i);
- if(!smb_io_dom_sid2(temp, &sen->sid[i], ps, depth)) /* domain SIDs to be looked up. */
+ if(!smb_io_dom_sid2(temp, &sen->sid[i], ps, depth)) {
return False;
+ }
}
return True;
@@ -716,19 +755,17 @@ static BOOL lsa_io_sid_enum(char *desc, LSA_SID_ENUM *sen,
Inits an LSA_R_ENUM_TRUST_DOM structure.
********************************************************************/
-void init_q_lookup_sids(LSA_Q_LOOKUP_SIDS *q_l, POLICY_HND *hnd,
- int num_sids, DOM_SID *sids, uint16 level)
+void init_q_lookup_sids(TALLOC_CTX *mem_ctx, LSA_Q_LOOKUP_SIDS *q_l,
+ POLICY_HND *hnd, int num_sids, DOM_SID **sids,
+ uint16 level)
{
- DEBUG(5, ("init_q_lookup_sids\n"));
-
- q_l->pol = *hnd;
-
- init_lsa_sid_enum(&q_l->sids, num_sids, sids);
+ DEBUG(5, ("init_r_enum_trust_dom\n"));
- q_l->names.num_entries = 0;
- q_l->names.ptr_trans_names = 0;
- q_l->names.num_entries2 = 0;
+ ZERO_STRUCTP(q_l);
+ memcpy(&q_l->pol, hnd, sizeof(q_l->pol));
+ init_lsa_sid_enum(mem_ctx, &q_l->sids, num_sids, sids);
+
q_l->level.value = level;
}
@@ -736,8 +773,7 @@ void init_q_lookup_sids(LSA_Q_LOOKUP_SIDS *q_l, POLICY_HND *hnd,
Reads or writes a LSA_Q_LOOKUP_SIDS structure.
********************************************************************/
-BOOL lsa_io_q_lookup_sids(char *desc, LSA_Q_LOOKUP_SIDS *q_s,
- prs_struct *ps, int depth)
+BOOL lsa_io_q_lookup_sids(char *desc, LSA_Q_LOOKUP_SIDS *q_s, prs_struct *ps, int depth)
{
if (q_s == NULL)
return False;
@@ -787,9 +823,23 @@ static BOOL lsa_io_trans_names(char *desc, LSA_TRANS_NAME_ENUM *trn,
return False;
if (trn->ptr_trans_names != 0) {
- if(!prs_uint32("num_entries2 ", ps, depth, &trn->num_entries2))
+ if(!prs_uint32("num_entries2 ", ps, depth,
+ &trn->num_entries2))
return False;
- SMB_ASSERT_ARRAY(trn->name, trn->num_entries);
+
+ if (UNMARSHALLING(ps)) {
+ if ((trn->name = (LSA_TRANS_NAME *)
+ malloc(trn->num_entries *
+ sizeof(LSA_TRANS_NAME))) == NULL) {
+ return False;
+ }
+
+ if ((trn->uni_name = (UNISTR2 *)
+ malloc(trn->num_entries *
+ sizeof(UNISTR2))) == NULL) {
+ return False;
+ }
+ }
for (i = 0; i < trn->num_entries2; i++) {
fstring t;
@@ -808,6 +858,16 @@ static BOOL lsa_io_trans_names(char *desc, LSA_TRANS_NAME_ENUM *trn,
if(!prs_align(ps))
return False;
}
+
+ /* Free memory if we've sent it */
+
+ if (MARSHALLING(ps)) {
+ safe_free(trn->name);
+ safe_free(trn->uni_name);
+
+ trn->name = NULL;
+ trn->uni_name = NULL;
+ }
}
return True;
@@ -855,22 +915,22 @@ makes a structure.
********************************************************************/
void init_q_lookup_names(LSA_Q_LOOKUP_NAMES *q_l, POLICY_HND *hnd,
- int num_names, char **names)
+ int num_names, char **names)
{
int i;
- DEBUG(5,("init_q_lookup_names\n"));
+ DEBUG(5, ("init_q_lookup_names\n"));
+
+ memcpy(&q_l->pol, hnd, sizeof(q_l->pol));
- q_l->pol = *hnd;
q_l->num_entries = num_names;
q_l->num_entries2 = num_names;
SMB_ASSERT_ARRAY(q_l->uni_name, q_l->num_entries);
for (i = 0; i < num_names; i++) {
- char *name = names[i];
- int len = strlen(name);
-
+ char* name = names[i];
+ int len = strlen(name)+1;
init_uni_hdr(&q_l->hdr_name[i], len);
init_unistr2(&q_l->uni_name[i], name, len);
}