Browse Source

Bug 610119 - fix coverify Defect Type: Null pointer dereferences issues 12167 - 12199

https://bugzilla.redhat.com/show_bug.cgi?id=610119
Resolves: bug 610119
Bug description: Fix coverify Defect Type: Null pointer dereferences issues 12167 - 12199
Fix description: Catch possible NULL pointer in ldbm_instance_config_load_dse_info()
and ldbm_instance_modify_config_entry_callback().
Endi S. Dewata 15 years ago
parent
commit
a3238ff1aa
1 changed files with 22 additions and 5 deletions
  1. 22 5
      ldap/servers/slapd/back-ldbm/ldbm_instance_config.c

+ 22 - 5
ldap/servers/slapd/back-ldbm/ldbm_instance_config.c

@@ -512,7 +512,16 @@ ldbm_instance_config_load_dse_info(ldbm_instance *inst)
         rval = 1;
         goto bail;
     }
+
     search_pb = slapi_pblock_new();
+    if (!search_pb) {
+        LDAPDebug(LDAP_DEBUG_ANY,
+                       "ldbm_instance_config_load_dse_info: Out of memory\n",
+                       0, 0, 0);
+        rval = 1;
+        goto bail;
+    }
+
     slapi_search_internal_set_pb(search_pb, dn, LDAP_SCOPE_BASE, 
                                  "objectclass=*", NULL, 0, NULL, NULL,
                                  li->li_identity, 0);
@@ -741,7 +750,16 @@ ldbm_instance_modify_config_entry_callback(Slapi_PBlock *pb, Slapi_Entry* entryB
     PR_Lock(inst->inst_config_mutex);
 
     slapi_pblock_get( pb, SLAPI_MODIFY_MODS, &mods ); 
-    
+
+    if (!returntext) {
+        rc = LDAP_OPERATIONS_ERROR;
+        LDAPDebug(LDAP_DEBUG_ANY,
+                  "ldbm_instance_modify_config_entry_callback: "
+                  "NULL return text\n",
+                  0, 0, 0);
+        goto out;
+    }
+
     returntext[0] = '\0'; 
 
     /* 
@@ -755,10 +773,8 @@ ldbm_instance_modify_config_entry_callback(Slapi_PBlock *pb, Slapi_Entry* entryB
             if (strcasecmp(attr_name, CONFIG_INSTANCE_SUFFIX) == 0) {
                 /* naughty naughty, we don't allow this */
                 rc = LDAP_UNWILLING_TO_PERFORM;
-                if (returntext) {
-					PR_snprintf(returntext, SLAPI_DSE_RETURNTEXT_SIZE,
-								"Can't change the root suffix of a backend");
-                }
+		PR_snprintf(returntext, SLAPI_DSE_RETURNTEXT_SIZE,
+			"Can't change the root suffix of a backend");
                 LDAPDebug(LDAP_DEBUG_ANY,
                           "ldbm: modify attempted to change the root suffix "
                           "of a backend (which is not allowed)\n",
@@ -787,6 +803,7 @@ ldbm_instance_modify_config_entry_callback(Slapi_PBlock *pb, Slapi_Entry* entryB
         }
     }
 
+out:
     PR_Unlock(inst->inst_config_mutex);
 
     *returncode = rc;