浏览代码

Bug 611790 - fix coverify Defect Type: Null pointer dereferences issues 11940 - 12166

https://bugzilla.redhat.com/show_bug.cgi?id=611790
Resolves: bug 611790
Bug description: Fix coverify Defect Type: Null pointer dereferences issues 11940 - 12166
Fix description: Catch possible NULL pointer in my_ber_scanf_value() and my_ber_scanf_attr().
Endi S. Dewata 15 年之前
父节点
当前提交
48d11ee1c3
共有 1 个文件被更改,包括 8 次插入3 次删除
  1. 8 3
      ldap/servers/plugins/replication/repl5_total.c

+ 8 - 3
ldap/servers/plugins/replication/repl5_total.c

@@ -481,14 +481,14 @@ my_ber_scanf_value(BerElement *ber, Slapi_Value **value, PRBool *deleted)
 
 	PR_ASSERT(ber && value && deleted);
 
-	*value = NULL;
-
 	if (NULL == ber && NULL == value)
 	{
 		slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name, "my_ber_scanf_value BAD 1\n");
 		goto loser;
 	}
 
+	*value = NULL;
+
 	/* Each value is a sequence */
 	if (ber_scanf(ber, "{O", &attrval) == LBER_ERROR)
 	{
@@ -593,11 +593,16 @@ my_ber_scanf_attr (BerElement *ber, Slapi_Attr **attr, PRBool *deleted)
     int rc;
     Slapi_Value *value = NULL;
 
+    if (attr == NULL)
+    {
+        goto loser;
+    }
+
     PR_ASSERT (ber && attr && deleted);
 
     /* allocate the attribute */
     *attr = slapi_attr_new ();
-    if (attr == NULL)
+    if (*attr == NULL)
     {
         goto loser;
     }