libnet dssync: fix memory allocation for error/result messages.
authorMichael Adam <obnox@samba.org>
Fri, 1 Aug 2008 15:10:59 +0000 (17:10 +0200)
committerMichael Adam <obnox@samba.org>
Fri, 1 Aug 2008 15:10:59 +0000 (17:10 +0200)
Use the libnet_dssync_context as a talloc context for the
result_message and error_message string members.
Using the passed in mem_ctx makes the implicit assumption
that mem_ctx is at least as long-lived as the libnet_dssync_context,
which is wrong.

Michael
(This used to be commit 635baf6b7d2a1822ceb48aa4bc47569ef19d51cc)

source3/libnet/libnet_dssync.c
source3/libnet/libnet_dssync_keytab.c

index e03a6023c948d5cfee2536f77764df3d93858f77..3641505d991a7c3aaf6bd2de9f392da40e2aec2d 100644 (file)
@@ -308,7 +308,7 @@ static NTSTATUS libnet_dssync_lookup_nc(TALLOC_CTX *mem_ctx,
                                             &ctr,
                                             &werr);
        if (!NT_STATUS_IS_OK(status)) {
-               ctx->error_message = talloc_asprintf(mem_ctx,
+               ctx->error_message = talloc_asprintf(ctx,
                        "Failed to lookup DN for domain name: %s",
                        get_friendly_werror_msg(werr));
                return status;
@@ -525,7 +525,7 @@ static NTSTATUS libnet_dssync_getncchanges(TALLOC_CTX *mem_ctx,
                                                       &ctr,
                                                       &werr);
                if (!NT_STATUS_IS_OK(status)) {
-                       ctx->error_message = talloc_asprintf(mem_ctx,
+                       ctx->error_message = talloc_asprintf(ctx,
                                "Failed to get NC Changes: %s",
                                get_friendly_werror_msg(werr));
                        goto out;
@@ -600,7 +600,7 @@ static NTSTATUS libnet_dssync_getncchanges(TALLOC_CTX *mem_ctx,
 
                status = cli_get_session_key(mem_ctx, ctx->cli, &ctx->session_key);
                if (!NT_STATUS_IS_OK(status)) {
-                       ctx->error_message = talloc_asprintf(mem_ctx,
+                       ctx->error_message = talloc_asprintf(ctx,
                                "Failed to get Session Key: %s",
                                nt_errstr(status));
                        goto out;
@@ -615,7 +615,7 @@ static NTSTATUS libnet_dssync_getncchanges(TALLOC_CTX *mem_ctx,
                                                           first_object,
                                                           mapping_ctr);
                        if (!NT_STATUS_IS_OK(status)) {
-                               ctx->error_message = talloc_asprintf(mem_ctx,
+                               ctx->error_message = talloc_asprintf(ctx,
                                        "Failed to call processing function: %s",
                                        nt_errstr(status));
                                goto out;
@@ -644,7 +644,7 @@ static NTSTATUS libnet_dssync_process(TALLOC_CTX *mem_ctx,
 
        status = ctx->ops->startup(ctx, mem_ctx, &old_utdv);
        if (!NT_STATUS_IS_OK(status)) {
-               ctx->error_message = talloc_asprintf(mem_ctx,
+               ctx->error_message = talloc_asprintf(ctx,
                        "Failed to call startup operation: %s",
                        nt_errstr(status));
                goto out;
@@ -670,7 +670,7 @@ static NTSTATUS libnet_dssync_process(TALLOC_CTX *mem_ctx,
                status = libnet_dssync_getncchanges(mem_ctx, ctx, level, &req,
                                                    &pnew_utdv);
                if (!NT_STATUS_IS_OK(status)) {
-                       ctx->error_message = talloc_asprintf(mem_ctx,
+                       ctx->error_message = talloc_asprintf(ctx,
                                "Failed to call DsGetNCCHanges: %s",
                                nt_errstr(status));
                        goto out;
@@ -679,7 +679,7 @@ static NTSTATUS libnet_dssync_process(TALLOC_CTX *mem_ctx,
 
        status = ctx->ops->finish(ctx, mem_ctx, pnew_utdv);
        if (!NT_STATUS_IS_OK(status)) {
-               ctx->error_message = talloc_asprintf(mem_ctx,
+               ctx->error_message = talloc_asprintf(ctx,
                        "Failed to call finishing operation: %s",
                        nt_errstr(status));
                goto out;
index 71fc7147df527a65d5fafcfd33ee6ea4005b7baf..6ba2c3aa41962665912f1a1ae14d936bd4e0bbd4 100644 (file)
@@ -90,7 +90,7 @@ static NTSTATUS keytab_startup(struct dssync_context *ctx, TALLOC_CTX *mem_ctx,
                                (ndr_pull_flags_fn_t)ndr_pull_replUpToDateVectorBlob);
                if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
                        NTSTATUS status = ndr_map_error2ntstatus(ndr_err);
-                       ctx->error_message = talloc_asprintf(mem_ctx,
+                       ctx->error_message = talloc_asprintf(ctx,
                                        "Failed to pull UpToDateVector: %s",
                                        nt_errstr(status));
                        return status;
@@ -128,7 +128,7 @@ static NTSTATUS keytab_finish(struct dssync_context *ctx, TALLOC_CTX *mem_ctx,
                                (ndr_push_flags_fn_t)ndr_push_replUpToDateVectorBlob);
                if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
                        status = ndr_map_error2ntstatus(ndr_err);
-                       ctx->error_message = talloc_asprintf(mem_ctx,
+                       ctx->error_message = talloc_asprintf(ctx,
                                        "Failed to push UpToDateVector: %s",
                                        nt_errstr(status));
                        goto done;
@@ -146,13 +146,13 @@ static NTSTATUS keytab_finish(struct dssync_context *ctx, TALLOC_CTX *mem_ctx,
        ret = libnet_keytab_add(keytab_ctx);
        if (ret) {
                status = krb5_to_nt_status(ret);
-               ctx->error_message = talloc_asprintf(mem_ctx,
+               ctx->error_message = talloc_asprintf(ctx,
                        "Failed to add entries to keytab %s: %s",
                        keytab_ctx->keytab_name, error_message(ret));
                goto done;
        }
 
-       ctx->result_message = talloc_asprintf(mem_ctx,
+       ctx->result_message = talloc_asprintf(ctx,
                "Vampired %d accounts to keytab %s",
                keytab_ctx->count,
                keytab_ctx->keytab_name);