浏览代码

Ticket 525 - Replication retry time attributes cannot be added

Description: Coverity CID 12434 Dereference before null check
introduced by commit dde9abef5ca71fc0557c66cabb99cb0a6f5e0332.

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

Reviewed by [email protected] (Thank you, Rich!!)
Noriko Hosoi 11 年之前
父节点
当前提交
bbe0a9974c
共有 1 个文件被更改,包括 15 次插入9 次删除
  1. 15 9
      ldap/servers/plugins/replication/repl5_replica_config.c

+ 15 - 9
ldap/servers/plugins/replication/repl5_replica_config.c

@@ -429,6 +429,14 @@ replica_config_modify (Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entry*
             else    /* modify an attribute */
             {
                 config_attr_value = (char *) mods[i]->mod_bvalues[0]->bv_val;
+                if (NULL == config_attr_value) {
+                    *returncode = LDAP_UNWILLING_TO_PERFORM;
+                    PR_snprintf (errortext, SLAPI_DSE_RETURNTEXT_SIZE, "attribute %s value is NULL.\n",
+                                 config_attr);
+                    slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name, "replica_config_modify: %s\n",
+                                    errortext);
+                    break;
+                }
 
                 if (strcasecmp (config_attr, attr_replicaBindDn) == 0)
 			    {
@@ -468,7 +476,7 @@ replica_config_modify (Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entry*
                 }
 				else if (strcasecmp (config_attr, type_replicaPurgeDelay) == 0)
 				{
-					if (apply_mods && config_attr_value && config_attr_value[0])
+					if (apply_mods && config_attr_value[0])
 					{
 						PRUint32 delay;
 						if (isdigit (config_attr_value[0]))
@@ -482,7 +490,7 @@ replica_config_modify (Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entry*
 				}
 				else if (strcasecmp (config_attr, type_replicaTombstonePurgeInterval) == 0)
 				{
-					if (apply_mods && config_attr_value && config_attr_value[0])
+					if (apply_mods && config_attr_value[0])
 					{
 						long interval;
 						interval = atol (config_attr_value);
@@ -491,7 +499,7 @@ replica_config_modify (Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entry*
 				}
                 else if (strcasecmp (config_attr, type_replicaLegacyConsumer) == 0)
                 {
-                    if (apply_mods)
+					if (apply_mods && config_attr_value[0])
                     {
                         PRBool legacy = (strcasecmp (config_attr_value, "on") == 0) ||
                                         (strcasecmp (config_attr_value, "true") == 0) ||
@@ -512,15 +520,13 @@ replica_config_modify (Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entry*
                     {
                         PRUint64 ptimeout = 0;
 
-                        if(config_attr_value){
-                            ptimeout = atoll(config_attr_value);
-                        }
+                        ptimeout = atoll(config_attr_value);
 
                         if(ptimeout <= 0){
                             *returncode = LDAP_UNWILLING_TO_PERFORM;
                             PR_snprintf (errortext, SLAPI_DSE_RETURNTEXT_SIZE,
                                          "attribute %s value (%s) is invalid, must be a number greater than zero.\n",
-                                         config_attr, config_attr_value ? config_attr_value : "");
+                                         config_attr, config_attr_value);
                             slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name, "replica_config_modify: %s\n", errortext);
                             break;
                         }
@@ -537,7 +543,7 @@ replica_config_modify (Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entry*
                             *returncode = LDAP_UNWILLING_TO_PERFORM;
                             PR_snprintf (errortext, SLAPI_DSE_RETURNTEXT_SIZE,
                                     "attribute %s value (%s) is invalid, must be a number greater than zero.\n",
-                                    config_attr, config_attr_value ? config_attr_value : "");
+                                    config_attr, config_attr_value);
                             slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name, "replica_config_modify: %s\n", errortext);
                             break;
                         }
@@ -554,7 +560,7 @@ replica_config_modify (Slapi_PBlock *pb, Slapi_Entry* entryBefore, Slapi_Entry*
                             *returncode = LDAP_UNWILLING_TO_PERFORM;
                             PR_snprintf (errortext, SLAPI_DSE_RETURNTEXT_SIZE,
                                     "attribute %s value (%s) is invalid, must be a number greater than zero.\n",
-                                    config_attr, config_attr_value ? config_attr_value : "");
+                                    config_attr, config_attr_value);
                             slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name, "replica_config_modify: %s\n", errortext);
                             break;
                         }