Browse Source

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"

https://fedorahosted.org/389/ticket/529

Reviewed by Rich (Thank you!!)
Noriko Hosoi 12 years ago
parent
commit
77e61a80d5

+ 5 - 6
ldap/servers/slapd/back-ldbm/import-threads.c

@@ -1780,11 +1780,10 @@ upgradedn_producer(void *param)
                 ID alt_id;
                 ID alt_id;
                 if (NULL == dn_norm_sp_conflicts) {
                 if (NULL == dn_norm_sp_conflicts) {
                     char buf[BUFSIZ];
                     char buf[BUFSIZ];
-                    char *p;
                     int my_max = 8;
                     int my_max = 8;
                     while (fgets(buf, BUFSIZ-1, job->upgradefd)) {
                     while (fgets(buf, BUFSIZ-1, job->upgradefd)) {
                         /* search "OID0: OID1 OID2 ... */
                         /* search "OID0: OID1 OID2 ... */
-                        if (!isdigit(*buf) || !(p = PL_strchr(buf, ':'))) {
+                        if (!isdigit(*buf) || (NULL == PL_strchr(buf, ':'))) {
                             continue;
                             continue;
                         }
                         }
                         if (add_IDs_to_IDarray(&dn_norm_sp_conflicts, &my_max,
                         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);
                 alt_id = is_conflict_ID(dn_norm_sp_conflicts, my_idx, temp_id);
                 if (alt_id) {
                 if (alt_id) {
-                    char *parentdn = NULL;
-                    char *newrdn = NULL;
                     if (alt_id != temp_id) {
                     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 */
                         /* This entry is a conflict of alt_id */
                         LDAPDebug(LDAP_DEBUG_ANY,
                         LDAPDebug(LDAP_DEBUG_ANY,
                                   "Entry %s (%lu) is a conflict of (%lu)\n",
                                   "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",
                         LDAPDebug2Args(LDAP_DEBUG_ANY, "Renaming \"%s\" to \"%s\"\n",
                                        rdn, newrdn);
                                        rdn, newrdn);
                         normdn = slapi_ch_smprintf("%s,%s", newrdn, parentdn);
                         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 */
                         /* Reset DN and RDN in the entry */
                         slapi_sdn_done(&(e->e_sdn));
                         slapi_sdn_done(&(e->e_sdn));
                         slapi_sdn_init_normdn_passin(&(e->e_sdn), normdn);
                         slapi_sdn_init_normdn_passin(&(e->e_sdn), normdn);

+ 0 - 2
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;
             corestate = current_worker->state & CORESTATE;
             if (current_worker->state == ABORTED) {
             if (current_worker->state == ABORTED) {
-LDAPDebug0Args(LDAP_DEBUG_ANY, "import_monitor_threads: current_worker->state is ABORTED\n");
                 goto error_abort;
                 goto error_abort;
             } else if ((corestate == QUIT) || (corestate == FINISHED)) {
             } 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)) {
                 if (DN_NORM_BT == (DN_NORM_BT & current_worker->state)) {
                     /* upgrading dn norm (both) is needed */
                     /* upgrading dn norm (both) is needed */
                     rc = NEED_DN_NORM_BT; /* Set the RC; Don't abort now;
                     rc = NEED_DN_NORM_BT; /* Set the RC; Don't abort now;