diff options
author | Jeremy Allison <jra@samba.org> | 2007-04-29 21:13:13 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:19:46 -0500 |
commit | 138668d5d284f7d2496f22c16a99be107cdfc872 (patch) | |
tree | 9bd5fb94a64173bd6a9325a1ecfc7bb4ccf34129 /source3/rpc_parse | |
parent | 571845991e137eb5f166d54c59a9e7efc1d565af (diff) | |
download | samba-138668d5d284f7d2496f22c16a99be107cdfc872.tar.gz samba-138668d5d284f7d2496f22c16a99be107cdfc872.tar.xz samba-138668d5d284f7d2496f22c16a99be107cdfc872.zip |
r22577: Change all of parse/*.c to use standard form. Fix some
marshalling bugs.
Jeremy.
(This used to be commit 3df99006f8a52af7cff0fbca1bf16157a8648254)
Diffstat (limited to 'source3/rpc_parse')
-rw-r--r-- | source3/rpc_parse/parse_lsa.c | 15 | ||||
-rw-r--r-- | source3/rpc_parse/parse_net.c | 166 | ||||
-rw-r--r-- | source3/rpc_parse/parse_ntsvcs.c | 10 | ||||
-rw-r--r-- | source3/rpc_parse/parse_svcctl.c | 12 |
4 files changed, 127 insertions, 76 deletions
diff --git a/source3/rpc_parse/parse_lsa.c b/source3/rpc_parse/parse_lsa.c index e1630f79f4..cbbba7f3e9 100644 --- a/source3/rpc_parse/parse_lsa.c +++ b/source3/rpc_parse/parse_lsa.c @@ -573,14 +573,17 @@ void init_r_enum_trust_dom(TALLOC_CTX *ctx, LSA_R_ENUM_TRUST_DOM *out, return; } - out->domlist->domains = TALLOC_ARRAY( ctx, DOMAIN_INFO, + if (out->count) { + out->domlist->domains = TALLOC_ARRAY( ctx, DOMAIN_INFO, out->count ); - - if ( !out->domlist->domains ) { - out->status = NT_STATUS_NO_MEMORY; - return; + if ( !out->domlist->domains ) { + out->status = NT_STATUS_NO_MEMORY; + return; + } + } else { + out->domlist->domains = NULL; } - + out->domlist->count = out->count; /* initialize the list of domains and their sid */ diff --git a/source3/rpc_parse/parse_net.c b/source3/rpc_parse/parse_net.c index b3331c8369..d821cf85f0 100644 --- a/source3/rpc_parse/parse_net.c +++ b/source3/rpc_parse/parse_net.c @@ -2551,13 +2551,19 @@ static BOOL net_io_sam_group_mem_info(const char *desc, SAM_GROUP_MEM_INFO * inf return False; } - info->rids = TALLOC_ARRAY(ps->mem_ctx, uint32, info->num_members2); - - if (info->rids == NULL) { - DEBUG(0, ("out of memory allocating %d rids\n", - info->num_members2)); - return False; - } + if (UNMARSHALLING(ps)) { + if (info->num_members2) { + info->rids = TALLOC_ARRAY(ps->mem_ctx, uint32, info->num_members2); + + if (info->rids == NULL) { + DEBUG(0, ("out of memory allocating %d rids\n", + info->num_members2)); + return False; + } + } else { + info->rids = NULL; + } + } for (i = 0; i < info->num_members2; i++) { @@ -2578,13 +2584,19 @@ static BOOL net_io_sam_group_mem_info(const char *desc, SAM_GROUP_MEM_INFO * inf return False; } - info->attribs = TALLOC_ARRAY(ps->mem_ctx, uint32, info->num_members3); - - if (info->attribs == NULL) { - DEBUG(0, ("out of memory allocating %d attribs\n", - info->num_members3)); - return False; - } + if (UNMARSHALLING(ps)) { + if (info->num_members3) { + info->attribs = TALLOC_ARRAY(ps->mem_ctx, uint32, info->num_members3); + + if (info->attribs == NULL) { + DEBUG(0, ("out of memory allocating %d attribs\n", + info->num_members3)); + return False; + } + } else { + info->attribs = NULL; + } + } for (i = 0; i < info->num_members3; i++) { @@ -2664,13 +2676,19 @@ static BOOL net_io_sam_alias_mem_info(const char *desc, SAM_ALIAS_MEM_INFO * inf return False; } - info->ptr_sids = TALLOC_ARRAY(ps->mem_ctx, uint32, info->num_sids); + if (UNMARSHALLING(ps)) { + if (info->num_sids) { + info->ptr_sids = TALLOC_ARRAY(ps->mem_ctx, uint32, info->num_sids); - if (info->ptr_sids == NULL) { - DEBUG(0, ("out of memory allocating %d ptr_sids\n", - info->num_sids)); - return False; - } + if (info->ptr_sids == NULL) { + DEBUG(0, ("out of memory allocating %d ptr_sids\n", + info->num_sids)); + return False; + } + } else { + info->ptr_sids = NULL; + } + } for (i = 0; i < info->num_sids; i++) { @@ -2679,13 +2697,19 @@ static BOOL net_io_sam_alias_mem_info(const char *desc, SAM_ALIAS_MEM_INFO * inf return False; } - info->sids = TALLOC_ARRAY(ps->mem_ctx, DOM_SID2, info->num_sids); - - if (info->sids == NULL) { - DEBUG(0, ("error allocating %d sids\n", - info->num_sids)); - return False; - } + if (UNMARSHALLING(ps)) { + if (info->num_sids) { + info->sids = TALLOC_ARRAY(ps->mem_ctx, DOM_SID2, info->num_sids); + + if (info->sids == NULL) { + DEBUG(0, ("error allocating %d sids\n", + info->num_sids)); + return False; + } + } else { + info->sids = NULL; + } + } for (i = 0; i < info->num_sids; i++) { @@ -3157,15 +3181,19 @@ BOOL net_io_r_sam_sync(const char *desc, return False; } - if (r_s->num_deltas2 > 0) { - r_s->hdr_deltas = TALLOC_ARRAY(ps->mem_ctx, SAM_DELTA_HDR, r_s->num_deltas2); - if (r_s->hdr_deltas == NULL) { - DEBUG(0, ("error tallocating memory " - "for %d delta headers\n", - r_s->num_deltas2)); - return False; - } - } + if (UNMARSHALLING(ps)) { + if (r_s->num_deltas2) { + r_s->hdr_deltas = TALLOC_ARRAY(ps->mem_ctx, SAM_DELTA_HDR, r_s->num_deltas2); + if (r_s->hdr_deltas == NULL) { + DEBUG(0, ("error tallocating memory " + "for %d delta headers\n", + r_s->num_deltas2)); + return False; + } + } else { + r_s->hdr_deltas = NULL; + } + } for (i = 0; i < r_s->num_deltas2; i++) { @@ -3175,15 +3203,19 @@ BOOL net_io_r_sam_sync(const char *desc, return False; } - if (r_s->num_deltas2 > 0) { - r_s->deltas = TALLOC_ARRAY(ps->mem_ctx, SAM_DELTA_CTR, r_s->num_deltas2); - if (r_s->deltas == NULL) { - DEBUG(0, ("error tallocating memory " - "for %d deltas\n", - r_s->num_deltas2)); - return False; - } - } + if (UNMARSHALLING(ps)) { + if (r_s->num_deltas2) { + r_s->deltas = TALLOC_ARRAY(ps->mem_ctx, SAM_DELTA_CTR, r_s->num_deltas2); + if (r_s->deltas == NULL) { + DEBUG(0, ("error tallocating memory " + "for %d deltas\n", + r_s->num_deltas2)); + return False; + } + } else { + r_s->deltas = NULL; + } + } for (i = 0; i < r_s->num_deltas2; i++) { @@ -3286,15 +3318,19 @@ BOOL net_io_r_sam_deltas(const char *desc, if (r_s->ptr_deltas != 0) { - if (r_s->num_deltas > 0) { - r_s->hdr_deltas = TALLOC_ARRAY(ps->mem_ctx, SAM_DELTA_HDR, r_s->num_deltas); - if (r_s->hdr_deltas == NULL) { - DEBUG(0, ("error tallocating memory " - "for %d delta headers\n", - r_s->num_deltas)); - return False; - } - } + if (UNMARSHALLING(ps)) { + if (r_s->num_deltas) { + r_s->hdr_deltas = TALLOC_ARRAY(ps->mem_ctx, SAM_DELTA_HDR, r_s->num_deltas); + if (r_s->hdr_deltas == NULL) { + DEBUG(0, ("error tallocating memory " + "for %d delta headers\n", + r_s->num_deltas)); + return False; + } + } else { + r_s->hdr_deltas = NULL; + } + } for (i = 0; i < r_s->num_deltas; i++) { @@ -3302,15 +3338,19 @@ BOOL net_io_r_sam_deltas(const char *desc, ps, depth); } - if (r_s->num_deltas > 0) { - r_s->deltas = TALLOC_ARRAY(ps->mem_ctx, SAM_DELTA_CTR, r_s->num_deltas); - if (r_s->deltas == NULL) { - DEBUG(0, ("error tallocating memory " - "for %d deltas\n", - r_s->num_deltas)); - return False; - } - } + if (UNMARSHALLING(ps)) { + if (r_s->num_deltas) { + r_s->deltas = TALLOC_ARRAY(ps->mem_ctx, SAM_DELTA_CTR, r_s->num_deltas); + if (r_s->deltas == NULL) { + DEBUG(0, ("error tallocating memory " + "for %d deltas\n", + r_s->num_deltas)); + return False; + } + } else { + r_s->deltas = NULL; + } + } for (i = 0; i < r_s->num_deltas; i++) { diff --git a/source3/rpc_parse/parse_ntsvcs.c b/source3/rpc_parse/parse_ntsvcs.c index ab5f3f75e8..559a9d5ab5 100644 --- a/source3/rpc_parse/parse_ntsvcs.c +++ b/source3/rpc_parse/parse_ntsvcs.c @@ -334,9 +334,13 @@ BOOL ntsvcs_io_r_get_hw_profile_info(const char *desc, NTSVCS_R_GET_HW_PROFILE_I return False; if ( UNMARSHALLING(ps) ) { - r_u->buffer = TALLOC_ARRAY(get_talloc_ctx(), uint8, r_u->buffer_size ); - if (!r_u->buffer) { - return False; + if (r_u->buffer_size) { + r_u->buffer = TALLOC_ARRAY(get_talloc_ctx(), uint8, r_u->buffer_size ); + if (!r_u->buffer) { + return False; + } + } else { + r_u->buffer = NULL; } } diff --git a/source3/rpc_parse/parse_svcctl.c b/source3/rpc_parse/parse_svcctl.c index dc4ee3e6e9..3846812f31 100644 --- a/source3/rpc_parse/parse_svcctl.c +++ b/source3/rpc_parse/parse_svcctl.c @@ -829,10 +829,14 @@ BOOL svcctl_io_service_fa( const char *desc, SERVICE_FAILURE_ACTIONS *fa, RPC_BU if ( !prs_uint32("num_actions", ps, depth, &fa->num_actions) ) return False; - if ( UNMARSHALLING(ps) && fa->num_actions ) { - if ( !(fa->actions = TALLOC_ARRAY( get_talloc_ctx(), SC_ACTION, fa->num_actions )) ) { - DEBUG(0,("svcctl_io_service_fa: talloc() failure!\n")); - return False; + if ( UNMARSHALLING(ps)) { + if (fa->num_actions) { + if ( !(fa->actions = TALLOC_ARRAY( get_talloc_ctx(), SC_ACTION, fa->num_actions )) ) { + DEBUG(0,("svcctl_io_service_fa: talloc() failure!\n")); + return False; + } + } else { + fa->actions = NULL; } } |