From 603c5fcc52201d9eca690c5bef29e4e39e340f56 Mon Sep 17 00:00:00 2001 From: Noriko Hosoi Date: Thu, 8 Jul 2010 10:52:25 -0700 Subject: 610281 - fix coverity Defect Type: Control flow issues https://bugzilla.redhat.com/show_bug.cgi?id=610281 11831 DEADCODE Triaged Unassigned Bug Minor Fix Required config_set_value() ds/ldap/servers/slapd/libglobs.c Comment: The config_set_value meant to set various values (e.g. "off" and "unknown") depending upon the config_var_type, but this code overrides the spec and set the empty string to all cases. - /* for null values, just set the attr value to the empty - string */ - if (!value) { - slapi_entry_attr_set_charptr(e, cgas->attr_name, ""); - return; - } This patch removes the above blind empty string setting and relies on the values in each config_var_type case. Plus, adding the NULL value check to CONFIG_CHARRAY. --- ldap/servers/slapd/libglobs.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/ldap/servers/slapd/libglobs.c b/ldap/servers/slapd/libglobs.c index b8e26d1c..d10466d6 100644 --- a/ldap/servers/slapd/libglobs.c +++ b/ldap/servers/slapd/libglobs.c @@ -5604,13 +5604,6 @@ config_set_value( int ival = 0; uintptr_t pval; - /* for null values, just set the attr value to the empty - string */ - if (!value) { - slapi_entry_attr_set_charptr(e, cgas->attr_name, ""); - return; - } - switch (cgas->config_var_type) { case CONFIG_ON_OFF: /* convert 0,1 to "off","on" */ slapi_entry_attr_set_charptr(e, cgas->attr_name, @@ -5638,12 +5631,16 @@ config_set_value( break; case CONFIG_CHARRAY: - values = strarray2bervalarray((const char **)*((char ***)value)); - if (!values) { - slapi_entry_attr_set_charptr(e, cgas->attr_name, ""); + if (value) { + values = strarray2bervalarray((const char **)*((char ***)value)); + if (!values) { + slapi_entry_attr_set_charptr(e, cgas->attr_name, ""); + } else { + slapi_entry_attr_replace(e, cgas->attr_name, values); + bervalarray_free(values); + } } else { - slapi_entry_attr_replace(e, cgas->attr_name, values); - bervalarray_free(values); + slapi_entry_attr_set_charptr(e, cgas->attr_name, ""); } break; -- cgit