[Freeipa-devel] [PATCH 0072] Fix memory leaks in dynamic update PTR synchronization
Adam Tkac
atkac at redhat.com
Thu Oct 4 11:44:46 UTC 2012
On Thu, Oct 04, 2012 at 09:49:03AM +0200, Petr Spacek wrote:
> Hello,
>
> Fix memory leaks in dynamic update PTR synchronization.
>
> During settings code refactoring I found several ugly memory leaks
> in sync_ptr handling.
Ack
> From 690008eb1fb6f340c735150f21a8d30a244e14bf Mon Sep 17 00:00:00 2001
> From: Petr Spacek <pspacek at redhat.com>
> Date: Thu, 4 Oct 2012 09:46:25 +0200
> Subject: [PATCH] Fix memory leaks in dynamic update PTR synchronization.
>
> Signed-off-by: Petr Spacek <pspacek at redhat.com>
> ---
> src/ldap_helper.c | 12 ++++++++----
> 1 file changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/src/ldap_helper.c b/src/ldap_helper.c
> index 629c76732c86af2a614e589a5afff18136068a66..a7f492e1169c36a321c240fd6ff321a9ef63c2c4 100644
> --- a/src/ldap_helper.c
> +++ b/src/ldap_helper.c
> @@ -2496,11 +2496,16 @@ modify_ldap_common(dns_name_t *owner, ldap_instance_t *ldap_inst,
> isc_boolean_t zone_sync_ptr = ldap_inst->sync_ptr;
> ld_string_t *owner_dn_ptr = NULL;
> char *attrs[] = {"idnsAllowSyncPTR", "idnsAllowDynUpdate", NULL};
> + ld_string_t *str_ptr = NULL;
> + ldapdb_rdatalist_t rdlist_search;
> + dns_rdatalist_t *rdlist_ptr = NULL;
> + char **vals = NULL;
>
> /*
> * Find parent zone entry and check if Dynamic Update is allowed.
> * @todo Try the cache first and improve split: SOA records are problematic.
> */
> + ISC_LIST_INIT(rdlist_search);
> CHECK(str_new(mctx, &owner_dn));
> CHECK(dnsname_to_dn(ldap_inst->zone_register, owner, owner_dn));
> char *zone_dn = strstr(str_buf(owner_dn),", ");
> @@ -2606,8 +2611,6 @@ modify_ldap_common(dns_name_t *owner, ldap_instance_t *ldap_inst,
> CHECK(dns_byaddr_createptrname2(&isc_ip, 0, dns_fixedname_name(&name)));
>
> /* Find PTR entry in LDAP. */
> - ldapdb_rdatalist_t rdlist_search;
> - dns_rdatalist_t *rdlist_ptr = NULL;
> result = ldapdb_rdatalist_get(mctx, ldap_inst, dns_fixedname_name(&name),
> NULL, &rdlist_search);
>
> @@ -2682,7 +2685,6 @@ modify_ldap_common(dns_name_t *owner, ldap_instance_t *ldap_inst,
> *
> * @example str_ptr = "host.example.com."
> */
> - ld_string_t *str_ptr = NULL;
> CHECK(str_new(mctx, &str_ptr));
> CHECK(dn_to_text(str_buf(owner_dn), str_ptr, NULL));
>
> @@ -2699,7 +2701,6 @@ modify_ldap_common(dns_name_t *owner, ldap_instance_t *ldap_inst,
> *
> */
> if (mod_op == LDAP_MOD_DELETE) {
> - char **vals = NULL;
> CHECK(ldap_rdata_to_char_array(mctx, HEAD(rdlist_ptr->rdata), &vals));
> if (vals != NULL && vals[0] != NULL && strcmp(vals[0], str_buf(str_ptr)) != 0) {
> log_debug(3,"Cannot delete PTR record, unexpected value found "
> @@ -2746,9 +2747,12 @@ cleanup:
> ldap_pool_putconnection(ldap_inst->pool, &ldap_conn);
> str_destroy(&owner_dn_ptr);
> str_destroy(&owner_dn);
> + str_destroy(&str_ptr);
> free_ldapmod(mctx, &change[0]);
> free_ldapmod(mctx, &change[1]);
> if (change_ptr != NULL) free_ldapmod(mctx, &change_ptr);
> + ldapdb_rdatalist_destroy(mctx, &rdlist_search);
> + free_char_array(mctx, &vals);
>
> return result;
> }
> --
> 1.7.11.4
>
--
Adam Tkac, Red Hat, Inc.
More information about the Freeipa-devel
mailing list