ref = (DOM_R_REF *)talloc_zero(p->mem_ctx, sizeof(DOM_R_REF));
names = (LSA_TRANS_NAME_ENUM *)talloc_zero(p->mem_ctx, sizeof(LSA_TRANS_NAME_ENUM));
- if (!find_policy_by_hnd(p, &q_u->pol, (void **)&handle))
- return NT_STATUS_INVALID_HANDLE;
+ if (!find_policy_by_hnd(p, &q_u->pol, (void **)&handle)) {
+ r_u->status = NT_STATUS_INVALID_HANDLE;
+ goto done;
+ }
/* check if the user have enough rights */
- if (!(handle->access & POLICY_LOOKUP_NAMES))
- return NT_STATUS_ACCESS_DENIED;
-
+ if (!(handle->access & POLICY_LOOKUP_NAMES)) {
+ r_u->status = NT_STATUS_ACCESS_DENIED;
+ goto done;
+ }
if (!ref || !names)
return NT_STATUS_NO_MEMORY;
+done:
+
/* set up the LSA Lookup SIDs response */
init_lsa_trans_names(p->mem_ctx, ref, names, num_entries, sid, &mapped_count);
init_reply_lookup_sids(r_u, ref, names, mapped_count);
ref = (DOM_R_REF *)talloc_zero(p->mem_ctx, sizeof(DOM_R_REF));
rids = (DOM_RID2 *)talloc_zero(p->mem_ctx, sizeof(DOM_RID2)*num_entries);
- if (!find_policy_by_hnd(p, &q_u->pol, (void **)&handle))
- return NT_STATUS_INVALID_HANDLE;
+ if (!find_policy_by_hnd(p, &q_u->pol, (void **)&handle)) {
+ r_u->status = NT_STATUS_INVALID_HANDLE;
+ goto done;
+ }
/* check if the user have enough rights */
- if (!(handle->access & POLICY_LOOKUP_NAMES))
- return NT_STATUS_ACCESS_DENIED;
+ if (!(handle->access & POLICY_LOOKUP_NAMES)) {
+ r_u->status = NT_STATUS_ACCESS_DENIED;
+ goto done;
+ }
if (!ref || !rids)
return NT_STATUS_NO_MEMORY;
+done:
+
/* set up the LSA Lookup RIDs response */
init_lsa_rid2s(ref, rids, num_entries, names, &mapped_count, p->endian);
init_reply_lookup_names(r_u, ref, num_entries, rids, mapped_count);
}
/* calculate the size and limit on the number of entries we will return */
- temp_size=(enum_context+max_entries)*struct_size;
+ temp_size=max_entries*struct_size;
if (temp_size>max_size) {
- max_entries=max_size/struct_size;
+ max_entries=MIN((max_size/struct_size),max_entries);;
DEBUG(5, ("samr_reply_query_dispinfo: buffer size limits to only %d entries\n", max_entries));
}