r22748: fix memleaks by passing an mem_ctx to
authorStefan Metzmacher <metze@samba.org>
Mon, 7 May 2007 15:19:53 +0000 (15:19 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 19:52:09 +0000 (14:52 -0500)
irpc_servers_byname()

metze
(This used to be commit b54584dfabee77ec7743cab431bda9765057a295)

source4/auth/auth_winbind.c
source4/lib/messaging/irpc.h
source4/lib/messaging/messaging.c
source4/libcli/finddcs.c
source4/scripting/ejs/smbcalls_rpc.c
source4/winbind/wb_dom_info.c
source4/wrepl_server/wrepl_apply_records.c
source4/wrepl_server/wrepl_scavenging.c

index 2a35047e21ea3917e8795df1a3820c03b85906b5..05183d65d06d2fb0cc84366f9b51dcf95ef2ba54 100644 (file)
@@ -162,7 +162,10 @@ static NTSTATUS winbind_check_password(struct auth_method_context *ctx,
        const struct auth_usersupplied_info *user_info_new;
        struct netr_IdentityInfo *identity_info;
 
-       winbind_servers = irpc_servers_byname(ctx->auth_ctx->msg_ctx, "winbind_server");
+       s = talloc(mem_ctx, struct winbind_check_password_state);
+       NT_STATUS_HAVE_NO_MEMORY(s);
+
+       winbind_servers = irpc_servers_byname(ctx->auth_ctx->msg_ctx, s, "winbind_server");
        if ((winbind_servers == NULL) || (winbind_servers[0].id == 0)) {
                DEBUG(0, ("Winbind authentication for [%s]\\[%s] failed, " 
                          "no winbind_server running!\n",
@@ -170,9 +173,6 @@ static NTSTATUS winbind_check_password(struct auth_method_context *ctx,
                return NT_STATUS_NO_LOGON_SERVERS;
        }
 
-       s = talloc(mem_ctx, struct winbind_check_password_state);
-       NT_STATUS_HAVE_NO_MEMORY(s);
-
        if (user_info->flags & USER_INFO_INTERACTIVE_LOGON) {
                struct netr_PasswordInfo *password_info;
 
index 6873f014a6a9fbe9b78db80639664e8d50bd85a4..0ea1d5d69fb9f3c91d85a1fbd0dae209ed48dfe7 100644 (file)
@@ -117,7 +117,7 @@ NTSTATUS irpc_call(struct messaging_context *msg_ctx,
                   int callnum, void *r, TALLOC_CTX *ctx);
 
 NTSTATUS irpc_add_name(struct messaging_context *msg_ctx, const char *name);
-struct server_id *irpc_servers_byname(struct messaging_context *msg_ctx, const char *name);
+struct server_id *irpc_servers_byname(struct messaging_context *msg_ctx, TALLOC_CTX *mem_ctx, const char *name);
 void irpc_remove_name(struct messaging_context *msg_ctx, const char *name);
 NTSTATUS irpc_send_reply(struct irpc_message *m, NTSTATUS status);
 
index 705fdcc4655d6e9ce4a9c13505594aa870c5e9c7..9b4f4b49c435d56b24ff3c282b4b779fd2bb2308 100644 (file)
@@ -961,7 +961,8 @@ NTSTATUS irpc_add_name(struct messaging_context *msg_ctx, const char *name)
 /*
   return a list of server ids for a server name
 */
-struct server_id *irpc_servers_byname(struct messaging_context *msg_ctx, 
+struct server_id *irpc_servers_byname(struct messaging_context *msg_ctx,
+                                     TALLOC_CTX *mem_ctx,
                                      const char *name)
 {
        struct tdb_wrap *t;
@@ -985,7 +986,7 @@ struct server_id *irpc_servers_byname(struct messaging_context *msg_ctx,
                return NULL;
        }
        count = rec.dsize / sizeof(struct server_id);
-       ret = talloc_array(msg_ctx, struct server_id, count+1);
+       ret = talloc_array(mem_ctx, struct server_id, count+1);
        if (ret == NULL) {
                tdb_unlock_bystring(t->tdb, name);
                talloc_free(t);
index d8acf44ba0a2cb9643bb97462c2e91c2a60cc6aa..09967c72b164f43e5433eef571d59eb50fda4e4a 100644 (file)
@@ -133,7 +133,7 @@ static void finddcs_name_resolved(struct composite_context *ctx)
                return;
        }
 
-       nbt_servers = irpc_servers_byname(state->msg_ctx, "nbt_server");
+       nbt_servers = irpc_servers_byname(state->msg_ctx, state, "nbt_server");
        if ((nbt_servers == NULL) || (nbt_servers[0].id == 0)) {
                fallback_node_status(state);
                return;
index 4d4e12e855ef650a94d07003d2a703f0eef09253..73b6661cd328eecb0f2c537bc7bc136f7e9d6610 100644 (file)
@@ -88,7 +88,7 @@ static int ejs_irpc_connect(MprVarHandle eid, int argc, char **argv)
                return -1;
        }
 
-       p->dest_ids = irpc_servers_byname(p->msg_ctx, p->server_name);
+       p->dest_ids = irpc_servers_byname(p->msg_ctx, p, p->server_name);
        if (p->dest_ids == NULL || p->dest_ids[0].id == 0) {
                talloc_free(p);
                status = NT_STATUS_OBJECT_NAME_NOT_FOUND;
index 28f35c20952c9b4d70793cc3b6fd21049eebac35..39a734aace4b718b2ca1857560352787663920e1 100644 (file)
@@ -96,7 +96,7 @@ static void get_dom_info_recv_addrs(struct composite_context *ctx)
        if (!composite_is_ok(state->ctx)) return;
 
        nbt_servers = irpc_servers_byname(state->service->task->msg_ctx,
-                                         "nbt_server");
+                                         state, "nbt_server");
        if ((nbt_servers == NULL) || (nbt_servers[0].id == 0)) {
                composite_error(state->ctx, NT_STATUS_NO_LOGON_SERVERS);
                return;
index f805d21dfe8d280561b2803b58a15a0cdcf5141d..033657987ef3302789da65aa9194efbd31da481c 100644 (file)
@@ -911,7 +911,7 @@ static NTSTATUS r_do_late_release_demand(struct r_do_challenge_state *state)
        DEBUG(4,("late release demand record %s\n",
                 nbt_name_string(state, &state->replica.name)));
 
-       nbt_servers = irpc_servers_byname(state->msg_ctx, "nbt_server");
+       nbt_servers = irpc_servers_byname(state->msg_ctx, state, "nbt_server");
        if ((nbt_servers == NULL) || (nbt_servers[0].id == 0)) {
                return NT_STATUS_INTERNAL_ERROR;
        }
@@ -1051,7 +1051,7 @@ static NTSTATUS r_do_challenge(struct wreplsrv_partner *partner,
        talloc_steal(state, replica->owner);
        talloc_steal(state, replica->addresses);
 
-       nbt_servers = irpc_servers_byname(state->msg_ctx, "nbt_server");
+       nbt_servers = irpc_servers_byname(state->msg_ctx, state, "nbt_server");
        if ((nbt_servers == NULL) || (nbt_servers[0].id == 0)) {
                return NT_STATUS_INTERNAL_ERROR;
        }
@@ -1113,7 +1113,7 @@ static NTSTATUS r_do_release_demand(struct wreplsrv_partner *partner,
        DEBUG(4,("release demand record %s\n",
                 nbt_name_string(mem_ctx, &replica->name)));
 
-       nbt_servers = irpc_servers_byname(partner->service->task->msg_ctx, "nbt_server");
+       nbt_servers = irpc_servers_byname(partner->service->task->msg_ctx, mem_ctx, "nbt_server");
        if ((nbt_servers == NULL) || (nbt_servers[0].id == 0)) {
                return NT_STATUS_INTERNAL_ERROR;
        }
index e134e64c06598ec30715099f24eb606baeec239a..b75fa72abfc804344efee38648402b0ffae6f0cf 100644 (file)
@@ -390,7 +390,7 @@ static NTSTATUS wreplsrv_scavenging_replica_active_records(struct wreplsrv_servi
        struct verify_state *s;
        struct server_id *nbt_servers;
 
-       nbt_servers = irpc_servers_byname(service->task->msg_ctx, "nbt_server");
+       nbt_servers = irpc_servers_byname(service->task->msg_ctx, tmp_mem, "nbt_server");
        if ((nbt_servers == NULL) || (nbt_servers[0].id == 0)) {
                return NT_STATUS_INTERNAL_ERROR;
        }