From 1e947b4219d56f9693228782346834a933a3750f Mon Sep 17 00:00:00 2001
From: Noriko Hosoi <nhosoi@redhat.com>
Date: Wed, 10 Apr 2013 10:35:12 -0700
Subject: [PATCH 1/2] Ticket #529 - dn normalization must handle multiple space
 characters in attributes

Description: commit 69ff83598d517bed84922b1c7dd67cab023b4d99
introduced 2 coverity defects:
  13162: Resource leak
         Free allocated strings: newrdn and parentdn
  13163: Unused pointer value
         Removed unused pointer "p"
---
 ldap/servers/slapd/back-ldbm/import-threads.c | 11 +++++------
 ldap/servers/slapd/back-ldbm/import.c         |  2 --
 2 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/ldap/servers/slapd/back-ldbm/import-threads.c b/ldap/servers/slapd/back-ldbm/import-threads.c
index 1c526ef..3cb25d3 100644
--- a/ldap/servers/slapd/back-ldbm/import-threads.c
+++ b/ldap/servers/slapd/back-ldbm/import-threads.c
@@ -1780,11 +1780,10 @@ upgradedn_producer(void *param)
                 ID alt_id;
                 if (NULL == dn_norm_sp_conflicts) {
                     char buf[BUFSIZ];
-                    char *p;
                     int my_max = 8;
                     while (fgets(buf, BUFSIZ-1, job->upgradefd)) {
                         /* search "OID0: OID1 OID2 ... */
-                        if (!isdigit(*buf) || !(p = PL_strchr(buf, ':'))) {
+                        if (!isdigit(*buf) || (NULL == PL_strchr(buf, ':'))) {
                             continue;
                         }
                         if (add_IDs_to_IDarray(&dn_norm_sp_conflicts, &my_max,
@@ -1799,11 +1798,9 @@ upgradedn_producer(void *param)
                 }
                 alt_id = is_conflict_ID(dn_norm_sp_conflicts, my_idx, temp_id);
                 if (alt_id) {
-                    char *parentdn = NULL;
-                    char *newrdn = NULL;
                     if (alt_id != temp_id) {
-                        parentdn = slapi_dn_parent(normdn);
-                        newrdn = slapi_create_dn_string("%s %u", rdn, temp_id);
+                        char *newrdn = slapi_create_dn_string("%s %u", rdn, temp_id);
+                        char *parentdn = slapi_dn_parent(normdn);
                         /* This entry is a conflict of alt_id */
                         LDAPDebug(LDAP_DEBUG_ANY,
                                   "Entry %s (%lu) is a conflict of (%lu)\n",
@@ -1811,6 +1808,8 @@ upgradedn_producer(void *param)
                         LDAPDebug2Args(LDAP_DEBUG_ANY, "Renaming \"%s\" to \"%s\"\n",
                                        rdn, newrdn);
                         normdn = slapi_ch_smprintf("%s,%s", newrdn, parentdn);
+                        slapi_ch_free_string(&newrdn);
+                        slapi_ch_free_string(&parentdn);
                         /* Reset DN and RDN in the entry */
                         slapi_sdn_done(&(e->e_sdn));
                         slapi_sdn_init_normdn_passin(&(e->e_sdn), normdn);
diff --git a/ldap/servers/slapd/back-ldbm/import.c b/ldap/servers/slapd/back-ldbm/import.c
index aedff9f..d341ea7 100644
--- a/ldap/servers/slapd/back-ldbm/import.c
+++ b/ldap/servers/slapd/back-ldbm/import.c
@@ -781,10 +781,8 @@ static int import_monitor_threads(ImportJob *job, int *status)
             }
             corestate = current_worker->state & CORESTATE;
             if (current_worker->state == ABORTED) {
-LDAPDebug0Args(LDAP_DEBUG_ANY, "import_monitor_threads: current_worker->state is ABORTED\n");
                 goto error_abort;
             } else if ((corestate == QUIT) || (corestate == FINISHED)) {
-LDAPDebug1Arg(LDAP_DEBUG_ANY, "import_monitor_threads: current_worker->state is %s\n", (corestate==QUIT)?"QUIT":"FINISHED");
                 if (DN_NORM_BT == (DN_NORM_BT & current_worker->state)) {
                     /* upgrading dn norm (both) is needed */
                     rc = NEED_DN_NORM_BT; /* Set the RC; Don't abort now;
-- 
1.8.1.4

