Browse Source

Bug 613056 - fix coverify Defect Type: Null pointer dereferences issues 11892 - 11939

https://bugzilla.redhat.com/show_bug.cgi?id=613056
Resolves: bug 613056
Bug description: Fix coverify Defect Type: Null pointer dereferences issues 11892 - 11939
description: The destroy_task() has been modified to return when the task is NULL. The
task_upgradedb_add() has been modified to return an error when be is NULL.
Endi S. Dewata 15 years ago
parent
commit
a82d3eede0
1 changed files with 13 additions and 2 deletions
  1. 13 2
      ldap/servers/slapd/task.c

+ 13 - 2
ldap/servers/slapd/task.c

@@ -538,7 +538,11 @@ destroy_task(time_t when, void *arg)
 {
     Slapi_Task *task = (Slapi_Task *)arg;
     Slapi_Task *t1;
-    Slapi_PBlock *pb = slapi_pblock_new();
+    Slapi_PBlock *pb;
+
+    if (task == NULL) return;
+
+    pb = slapi_pblock_new();
 
     /* Call the custom destructor callback if one was provided,
      * then perform the internal task destruction. */
@@ -1737,7 +1741,14 @@ task_upgradedb_add(Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Entry *eAfter,
         be = (backend *)slapi_get_next_backend (cookie);
     }
     slapi_ch_free((void **)&cookie);
-    if (NULL == be || NULL == be->be_database->plg_upgradedb ||
+    if (NULL == be) {
+        LDAPDebug(LDAP_DEBUG_ANY,
+                  "ERROR: no upgradedb is defined.\n", 0, 0, 0);
+        *returncode = LDAP_UNWILLING_TO_PERFORM;
+        rv = SLAPI_DSE_CALLBACK_ERROR;
+        goto out;
+    }
+    if (NULL == be->be_database->plg_upgradedb ||
         strcasecmp(database_type, be->be_database->plg_name)) {
         LDAPDebug(LDAP_DEBUG_ANY,
                   "ERROR: no upgradedb is defined in %s.\n",