From 50fa6937cf31065cd32feeb7ce211539394bca8e Mon Sep 17 00:00:00 2001 From: Noriko Hosoi Date: Mon, 24 Feb 2014 09:39:23 -0800 Subject: [PATCH 2/2] Ticket 525 - Replication retry time attributes cannot be added Description: Coverity CID 12434 Dereference before null check introduced by commit dde9abef5ca71fc0557c66cabb99cb0a6f5e0332. --- .../plugins/replication/repl5_replica_config.c | 24 ++++++++++++++-------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/ldap/servers/plugins/replication/repl5_replica_config.c b/ldap/servers/plugins/replication/repl5_replica_config.c index b1c700e..ae4a7d8 100644 --- a/ldap/servers/plugins/replication/repl5_replica_config.c +++ b/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; } -- 1.8.1.4