Browse Source

fix coverity issues with uninit vals, no return checking

12766 Uninitialized pointer read
In _entryrdn_replace_suffix_id(): Reads an uninitialized pointer or its target
12765 Uninitialized pointer read
In txn_test_threadmain(): Reads an uninitialized pointer or its target
12764 Unchecked return value
In txn_test_threadmain(): Value returned from a function is not checked for errors before being used
12763 Unchecked return value
In entrycache_replace(): Value returned from a function is not checked for errors before being used
12762 Unchecked return value
In entrycache_add_int(): Value returned from a function is not checked for errors before being used
Reviewed by: mreynolds (Thanks!)
(cherry picked from commit 98784ec829061e969c84b3cd5882326a0376ebd6)
Rich Megginson 13 years ago
parent
commit
44cdc84ddc

+ 6 - 2
ldap/servers/slapd/back-ldbm/cache.c

@@ -1058,7 +1058,9 @@ static int entrycache_replace(struct cache *cache, struct backentry *olde,
     }
     if (!add_hash(cache->c_idtable, &(newe->ep_id), sizeof(ID), newe, NULL)) {
        LOG("entry cache replace: can't add id\n", 0, 0, 0);
-       remove_hash(cache->c_dntable, (void *)newndn, strlen(newndn));
+       if (remove_hash(cache->c_dntable, (void *)newndn, strlen(newndn))) {
+           LOG("entry cache replace: can't remove dn after add id failed\n", 0, 0, 0);
+       }
        PR_Unlock(cache->c_mutex);
        return 1;
     }
@@ -1357,7 +1359,9 @@ entrycache_add_int(struct cache *cache, struct backentry *e, int state,
                 PR_Unlock(cache->c_mutex);
                 return 0;
             }
-            remove_hash(cache->c_dntable, (void *)ndn, strlen(ndn));
+            if (remove_hash(cache->c_dntable, (void *)ndn, strlen(ndn))) {
+                LOG("=>= entrycache_add_int could not remove existing id from dn cache\n", 0, 0, 0);
+            }
             e->ep_state |= ENTRY_STATE_NOTINCACHE;
             PR_Unlock(cache->c_mutex);
             return -1;

+ 4 - 5
ldap/servers/slapd/back-ldbm/dblayer.c

@@ -3897,12 +3897,12 @@ static int txn_test_threadmain(void *param)
 
     INCR_THREAD_COUNT(priv);
 
+    txn_test_init_cfg(&cfg);
+
     if (!priv->dblayer_enable_transactions) {
         goto end;
     }
 
-    txn_test_init_cfg(&cfg);
-
 wait_for_init:
     free_ttilist(&ttilist, &tticnt);
     DS_Sleep(PR_MillisecondsToInterval(1000));
@@ -3941,9 +3941,8 @@ wait_for_init:
                     object_release(inst_obj);
                     goto wait_for_init;
                 }
-                dblayer_get_index_file(be, ai, &db, 0);
-                if (NULL == db) {
-                    if (strcasecmp(*idx, TXN_TEST_IDX_OK_IF_NULL)) {
+                if (dblayer_get_index_file(be, ai, &db, 0) || (NULL == db)) {
+                    if ((NULL == db) && strcasecmp(*idx, TXN_TEST_IDX_OK_IF_NULL)) {
                         object_release(inst_obj);
                         goto wait_for_init;
                     }

+ 1 - 0
ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c

@@ -2179,6 +2179,7 @@ _entryrdn_replace_suffix_id(DBC *cursor, DBT *key, DBT *adddata,
     size_t curr_childnum = 0;
     int db_retry = 0;
 
+    memset(&moddata, 0, sizeof(moddata));
     /* temporary id added for the non exisiting suffix */
     /* Let's replace it with the real entry ID */
     /* SELF */