ldap/servers/plugins/replication/repl5_replica_config.c | 24 ++++++++++------
1 file changed, 15 insertions(+), 9 deletions(-)
New commits:
commit 4f9ec32b9904a359caf6a9c2f92f1c6e107727d4
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Mon Feb 24 10:22:52 2014 -0800
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 rmeggins(a)redhat.com (Thank you, Rich!!)
(cherry picked from commit bbe0a9974c673336f42788cecaebdb46ddad03f4)
(cherry picked from commit 981c951cfc485f62f7207d42bcc563f0e50260e7)
diff --git a/ldap/servers/plugins/replication/repl5_replica_config.c
b/ldap/servers/plugins/replication/repl5_replica_config.c
index 4e5d4f1..9f08138 100644
--- a/ldap/servers/plugins/replication/repl5_replica_config.c
+++ b/ldap/servers/plugins/replication/repl5_replica_config.c
@@ -428,6 +428,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)
{
@@ -467,7 +475,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]))
@@ -481,7 +489,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);
@@ -490,7 +498,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) ||
@@ -511,15 +519,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;
}
@@ -536,7 +542,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;
}
@@ -553,7 +559,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;
}