summaryrefslogtreecommitdiff
path: root/source3/rpc_server/srv_lsa_nt.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2007-04-30 01:17:34 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:19:47 -0500
commit1e362c0e7fff603cffa32863a5b07ecbc50f8a2d (patch)
tree59850105addaeccbcf5a9d9d90d18a784edab8f5 /source3/rpc_server/srv_lsa_nt.c
parent6b605a9cd783451072e0bb9f63eb0e29d7969cd4 (diff)
downloadsamba-1e362c0e7fff603cffa32863a5b07ecbc50f8a2d.tar.gz
samba-1e362c0e7fff603cffa32863a5b07ecbc50f8a2d.tar.bz2
samba-1e362c0e7fff603cffa32863a5b07ecbc50f8a2d.zip
r22587: Ensure TALLOC_ZERO_ARRAY is consistent.
Jeremy. (This used to be commit c3df5d08dd6a983f9d53dc6628a50e571d322e8d)
Diffstat (limited to 'source3/rpc_server/srv_lsa_nt.c')
-rw-r--r--source3/rpc_server/srv_lsa_nt.c85
1 files changed, 62 insertions, 23 deletions
diff --git a/source3/rpc_server/srv_lsa_nt.c b/source3/rpc_server/srv_lsa_nt.c
index 2343e3eedb..a85f0548bf 100644
--- a/source3/rpc_server/srv_lsa_nt.c
+++ b/source3/rpc_server/srv_lsa_nt.c
@@ -1066,7 +1066,18 @@ NTSTATUS _lsa_lookup_names(pipes_struct *p,LSA_Q_LOOKUP_NAMES *q_u, LSA_R_LOOKUP
}
ref = TALLOC_ZERO_P(p->mem_ctx, DOM_R_REF);
- rids = TALLOC_ZERO_ARRAY(p->mem_ctx, DOM_RID, num_entries);
+ if (!ref) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ if (num_entries) {
+ rids = TALLOC_ZERO_ARRAY(p->mem_ctx, DOM_RID, num_entries);
+ if (!rids) {
+ return NT_STATUS_NO_MEMORY;
+ }
+ } else {
+ rids = NULL;
+ }
if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle)) {
r_u->status = NT_STATUS_INVALID_HANDLE;
@@ -1079,9 +1090,6 @@ NTSTATUS _lsa_lookup_names(pipes_struct *p,LSA_Q_LOOKUP_NAMES *q_u, LSA_R_LOOKUP
goto done;
}
- if (!ref || !rids)
- return NT_STATUS_NO_MEMORY;
-
/* set up the LSA Lookup RIDs response */
become_root(); /* lookup_name can require root privs */
r_u->status = lookup_lsa_rids(p->mem_ctx, ref, rids, num_entries,
@@ -1128,14 +1136,23 @@ NTSTATUS _lsa_lookup_names2(pipes_struct *p, LSA_Q_LOOKUP_NAMES2 *q_u, LSA_R_LOO
}
ref = TALLOC_ZERO_P(p->mem_ctx, DOM_R_REF);
- rids = TALLOC_ZERO_ARRAY(p->mem_ctx, DOM_RID, num_entries);
- rids2 = TALLOC_ZERO_ARRAY(p->mem_ctx, DOM_RID2, num_entries);
-
- if ((ref == NULL) || (rids == NULL) || (rids2 == NULL)) {
+ if (ref == NULL) {
r_u->status = NT_STATUS_NO_MEMORY;
return NT_STATUS_NO_MEMORY;
}
+ if (num_entries) {
+ rids = TALLOC_ZERO_ARRAY(p->mem_ctx, DOM_RID, num_entries);
+ rids2 = TALLOC_ZERO_ARRAY(p->mem_ctx, DOM_RID2, num_entries);
+ if ((rids == NULL) || (rids2 == NULL)) {
+ r_u->status = NT_STATUS_NO_MEMORY;
+ return NT_STATUS_NO_MEMORY;
+ }
+ } else {
+ rids = NULL;
+ rids2 = NULL;
+ }
+
if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle)) {
r_u->status = NT_STATUS_INVALID_HANDLE;
goto done;
@@ -1200,7 +1217,17 @@ NTSTATUS _lsa_lookup_names3(pipes_struct *p, LSA_Q_LOOKUP_NAMES3 *q_u, LSA_R_LOO
}
ref = TALLOC_ZERO_P(p->mem_ctx, DOM_R_REF);
- trans_sids = TALLOC_ZERO_ARRAY(p->mem_ctx, LSA_TRANSLATED_SID3, num_entries);
+ if (ref == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+ if (num_entries) {
+ trans_sids = TALLOC_ZERO_ARRAY(p->mem_ctx, LSA_TRANSLATED_SID3, num_entries);
+ if (!trans_sids) {
+ return NT_STATUS_NO_MEMORY;
+ }
+ } else {
+ trans_sids = NULL;
+ }
if (!find_policy_by_hnd(p, &q_u->pol, (void **)(void *)&handle)) {
r_u->status = NT_STATUS_INVALID_HANDLE;
@@ -1213,10 +1240,6 @@ NTSTATUS _lsa_lookup_names3(pipes_struct *p, LSA_Q_LOOKUP_NAMES3 *q_u, LSA_R_LOO
goto done;
}
- if (!ref || !trans_sids) {
- return NT_STATUS_NO_MEMORY;
- }
-
/* set up the LSA Lookup SIDs response */
become_root(); /* lookup_name can require root privs */
r_u->status = lookup_lsa_sids(p->mem_ctx, ref, trans_sids, num_entries,
@@ -1268,12 +1291,19 @@ NTSTATUS _lsa_lookup_names4(pipes_struct *p, LSA_Q_LOOKUP_NAMES4 *q_u, LSA_R_LOO
}
ref = TALLOC_ZERO_P(p->mem_ctx, DOM_R_REF);
- trans_sids = TALLOC_ZERO_ARRAY(p->mem_ctx, LSA_TRANSLATED_SID3, num_entries);
-
- if (!ref || !trans_sids) {
+ if (!ref) {
return NT_STATUS_NO_MEMORY;
}
+ if (num_entries) {
+ trans_sids = TALLOC_ZERO_ARRAY(p->mem_ctx, LSA_TRANSLATED_SID3, num_entries);
+ if (!trans_sids) {
+ return NT_STATUS_NO_MEMORY;
+ }
+ } else {
+ trans_sids = NULL;
+ }
+
/* set up the LSA Lookup SIDs response */
become_root(); /* lookup_name can require root privs */
r_u->status = lookup_lsa_sids(p->mem_ctx, ref, trans_sids, num_entries,
@@ -1384,8 +1414,12 @@ NTSTATUS _lsa_enum_privs(pipes_struct *p, LSA_Q_ENUM_PRIVS *q_u, LSA_R_ENUM_PRIV
if (!(handle->access & POLICY_VIEW_LOCAL_INFORMATION))
return NT_STATUS_ACCESS_DENIED;
- if ( !(entries = TALLOC_ZERO_ARRAY(p->mem_ctx, LSA_PRIV_ENTRY, num_privs )) )
- return NT_STATUS_NO_MEMORY;
+ if (num_privs) {
+ if ( !(entries = TALLOC_ZERO_ARRAY(p->mem_ctx, LSA_PRIV_ENTRY, num_privs )) )
+ return NT_STATUS_NO_MEMORY;
+ } else {
+ entries = NULL;
+ }
for (i = 0; i < num_privs; i++) {
if( i < enum_context) {
@@ -1489,12 +1523,17 @@ NTSTATUS _lsa_enum_accounts(pipes_struct *p, LSA_Q_ENUM_ACCOUNTS *q_u, LSA_R_ENU
if (q_u->enum_context >= num_entries)
return NT_STATUS_NO_MORE_ENTRIES;
- sids->ptr_sid = TALLOC_ZERO_ARRAY(p->mem_ctx, uint32, num_entries-q_u->enum_context);
- sids->sid = TALLOC_ZERO_ARRAY(p->mem_ctx, DOM_SID2, num_entries-q_u->enum_context);
+ if (num_entries-q_u->enum_context) {
+ sids->ptr_sid = TALLOC_ZERO_ARRAY(p->mem_ctx, uint32, num_entries-q_u->enum_context);
+ sids->sid = TALLOC_ZERO_ARRAY(p->mem_ctx, DOM_SID2, num_entries-q_u->enum_context);
- if (sids->ptr_sid==NULL || sids->sid==NULL) {
- SAFE_FREE(sid_list);
- return NT_STATUS_NO_MEMORY;
+ if (sids->ptr_sid==NULL || sids->sid==NULL) {
+ SAFE_FREE(sid_list);
+ return NT_STATUS_NO_MEMORY;
+ }
+ } else {
+ sids->ptr_sid = NULL;
+ sids->sid = NULL;
}
for (i = q_u->enum_context, j = 0; i < num_entries; i++, j++) {