Author: obnox Date: 2007-05-22 13:40:01 +0000 (Tue, 22 May 2007) New Revision: 23073
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=23073 Log: In the internal rpccli_lsa_lookup_sids_noalloc(), use a temporary talloc context for use with the actual rpc query and response. So the the parent context does not get flooded by the posslibly large amount of response data (when looking up a lot of sids). Note: It not possible, to simply use the names and domains arrays as talloc contexts for the talloc_strdup calls, because from rpccli_lsa_lookup_sids_all, this is called with names + offset and domains + offset where names and domains are talloced arraye for the complete response. Modified: branches/SAMBA_3_0/source/rpc_client/cli_lsarpc.c Changeset: Modified: branches/SAMBA_3_0/source/rpc_client/cli_lsarpc.c =================================================================== --- branches/SAMBA_3_0/source/rpc_client/cli_lsarpc.c 2007-05-22 12:49:41 UTC (rev 23072) +++ branches/SAMBA_3_0/source/rpc_client/cli_lsarpc.c 2007-05-22 13:40:01 UTC (rev 23073) @@ -129,9 +129,8 @@ /* Lookup a list of sids * - * internal version withOUT memory allocation. - * this assumes suffciently sized arrays to store - * domains, names and types */ + * internal version withOUT memory allocation of the target arrays. + * this assumes suffciently sized arrays to store domains, names and types. */ static NTSTATUS rpccli_lsa_lookup_sids_noalloc(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, @@ -148,12 +147,20 @@ DOM_R_REF ref; LSA_TRANS_NAME_ENUM t_names; NTSTATUS result = NT_STATUS_OK; + TALLOC_CTX *tmp_ctx = NULL; int i; + tmp_ctx = talloc_new(mem_ctx); + if (!tmp_ctx) { + DEBUG(0, ("rpccli_lsa_lookup_sids_noalloc: out of memory!\n")); + result = NT_STATUS_UNSUCCESSFUL; + goto done; + } + ZERO_STRUCT(q); ZERO_STRUCT(r); - init_q_lookup_sids(mem_ctx, &q, pol, num_sids, sids, 1); + init_q_lookup_sids(tmp_ctx, &q, pol, num_sids, sids, 1); ZERO_STRUCT(ref); ZERO_STRUCT(t_names); @@ -161,7 +168,7 @@ r.dom_ref = &ref; r.names = &t_names; - CLI_DO_RPC( cli, mem_ctx, PI_LSARPC, LSA_LOOKUPSIDS, + CLI_DO_RPC( cli, tmp_ctx, PI_LSARPC, LSA_LOOKUPSIDS, q, r, qbuf, rbuf, lsa_io_q_lookup_sids, @@ -213,8 +220,8 @@ } } - done: - +done: + TALLOC_FREE(tmp_ctx); return result; } @@ -401,7 +408,8 @@ sids_processed + hunk_num_sids - 1, num_sids)); - hunk_result = rpccli_lsa_lookup_sids_noalloc(cli, mem_ctx, + hunk_result = rpccli_lsa_lookup_sids_noalloc(cli, + mem_ctx, pol, hunk_num_sids, hunk_sids,
