Branch '389-ds-base-1.3.1' - ldap/servers lib/ldaputil lib/libaccess lib/libadmin
by Mark Reynolds
ldap/servers/plugins/acl/acl.h | 1
ldap/servers/plugins/acl/acllist.c | 7 +--
ldap/servers/plugins/acl/aclparse.c | 29 +++++++---------
ldap/servers/plugins/dna/dna.c | 7 +++
ldap/servers/plugins/linkedattrs/linked_attrs.c | 7 +++
ldap/servers/plugins/pam_passthru/pam_ptconfig.c | 6 +++
ldap/servers/plugins/replication/repl5_replica_config.c | 3 -
ldap/servers/plugins/replication/windows_inc_protocol.c | 1
ldap/servers/plugins/syntaxes/value.c | 14 +++++++
ldap/servers/slapd/agtmmap.c | 1
ldap/servers/slapd/back-ldbm/dblayer.c | 10 +++--
ldap/servers/slapd/entry.c | 7 +++
ldap/servers/slapd/schema.c | 6 ++-
ldap/servers/slapd/snmp_collator.c | 4 +-
ldap/servers/slapd/tools/ldclt/data.c | 2 +
ldap/servers/slapd/tools/mmldif.c | 6 +++
ldap/servers/snmp/main.c | 3 +
lib/ldaputil/dbconf.c | 7 ++-
lib/libaccess/register.cpp | 1
lib/libadmin/error.c | 7 ++-
20 files changed, 97 insertions(+), 32 deletions(-)
New commits:
commit 5c51891dfb6ebe3325af09cc94068f11f24dc2ca
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Wed Jun 5 16:19:57 2013 -0400
Coverity Fixes (Part 4)
11753 - Resource leak (aclparse.c)
11754 - Resource leak (dna.c)
11755 - Resource leak (dna.c)
11756 - Resource leak (linked_attrs.c)
11757 - Resource leak (pam_ptconfig.c)
11758 - Resource leak (repl5_replica_config.c)
11759 - Resource leak (windows_inc_protocol.c)
11760 - Resource leak (syntaxes/value.c)
11761 - Resource leak (dblayer.c)
11764 - Resource leak (dblayer.c)
11766 - Resource leak (dblayer.c)
11769 - Resource leak (entry.c)
11770 - Resource leak (entry.c)
11773 - Resource leak (schema.c)
11774 - Resource leak (snmp_collator.c)
11775 - Resource leak (ldclt/data.c)
11776 - Resource leak (tools/mmldif.c)
11777 - Resource leak (snmp/main.c)
11778 - Resource leak (lib/libutil/dbconf.c)
11779 - Resource leak (lib/libaccess/register.cpp)
11781 - Resource leak (lib/libadmin/error.c)
11872 - Resource leak (agtmmap.c)
https://bugzilla.redhat.com/show_bug.cgi?id=970221
Reviewed by: nhosoi(Thanks!)
diff --git a/ldap/servers/plugins/acl/acl.h b/ldap/servers/plugins/acl/acl.h
index 5e840a9..a346781 100644
--- a/ldap/servers/plugins/acl/acl.h
+++ b/ldap/servers/plugins/acl/acl.h
@@ -867,6 +867,7 @@ int acllist_moddn_aci_needsLock ( Slapi_DN *oldsdn, char *newdn );
void acllist_print_tree ( Avlnode *root, int *depth, char *start, char *side);
AciContainer *acllist_get_aciContainer_new ( );
void acllist_done_aciContainer ( AciContainer *);
+void free_targetattrfilters( Targetattrfilter ***attrFilterArray);
aclUserGroup* aclg_find_userGroup (const char *n_dn);
void aclg_regen_ugroup_signature( aclUserGroup *ugroup);
diff --git a/ldap/servers/plugins/acl/acllist.c b/ldap/servers/plugins/acl/acllist.c
index e8198af..623a739 100644
--- a/ldap/servers/plugins/acl/acllist.c
+++ b/ldap/servers/plugins/acl/acllist.c
@@ -94,7 +94,6 @@ static int __acllist_add_aci ( aci_t *aci );
static int __acllist_aciContainer_node_cmp ( caddr_t d1, caddr_t d2 );
static int __acllist_aciContainer_node_dup ( caddr_t d1, caddr_t d2 );
static void __acllist_free_aciContainer ( AciContainer **container);
-static void free_targetattrfilters( Targetattrfilter ***input_attrFilterArray);
void my_print( Avlnode *root );
@@ -565,8 +564,9 @@ acllist_free_aci(aci_t *item)
slapi_ch_free ( (void **) &item );
}
-static void free_targetattrfilters( Targetattrfilter ***attrFilterArray) {
-
+void
+free_targetattrfilters( Targetattrfilter ***attrFilterArray)
+{
if (*attrFilterArray) {
int i = 0;
Targetattrfilter *attrfilter;
@@ -592,7 +592,6 @@ static void free_targetattrfilters( Targetattrfilter ***attrFilterArray) {
/* Now free the array */
slapi_ch_free ( (void **) attrFilterArray );
}
-
}
/* SEARCH */
diff --git a/ldap/servers/plugins/acl/aclparse.c b/ldap/servers/plugins/acl/aclparse.c
index 28c01b9..cabc39f 100644
--- a/ldap/servers/plugins/acl/aclparse.c
+++ b/ldap/servers/plugins/acl/aclparse.c
@@ -1951,14 +1951,13 @@ static int __acl__init_targetattrfilters( aci_t *aci, char *input_str) {
* We need to put each component into a targetattrfilter component of
* the array.
*
-*/
-
+ */
static int process_filter_list( Targetattrfilter ***input_attrFilterArray,
char * input_str) {
char *str, *end_attr;
Targetattrfilter *attrfilter = NULL;
- int numattr=0;
+ int numattr=0, rc = 0;
Targetattrfilter **attrFilterArray = NULL;
str = input_str;
@@ -1990,22 +1989,20 @@ static int process_filter_list( Targetattrfilter ***input_attrFilterArray,
memset (attrfilter, 0, sizeof(Targetattrfilter));
if (strstr( str,":") != NULL) {
-
if ( __acl_init_targetattrfilter( attrfilter, str ) != 0 ) {
slapi_ch_free((void**)&attrfilter);
- return(ACL_SYNTAX_ERR);
+ rc = ACL_SYNTAX_ERR;
+ break;
}
} else {
slapi_ch_free((void**)&attrfilter);
- return(ACL_SYNTAX_ERR);
+ rc = ACL_SYNTAX_ERR;
+ break;
}
-
/*
- * Add the attrfilte to the targetAttrFilter list
- */
-
-
+ * Add the attrfilter to the targetAttrFilter list
+ */
attrFilterArray = (Targetattrfilter **) slapi_ch_realloc (
(void *) attrFilterArray,
((numattr+1)*sizeof(Targetattrfilter *)) );
@@ -2014,7 +2011,6 @@ static int process_filter_list( Targetattrfilter ***input_attrFilterArray,
/* Move on to the next attribute in the list */
str = end_attr;
-
}/* while */
/* NULL terminate the list */
@@ -2023,10 +2019,13 @@ static int process_filter_list( Targetattrfilter ***input_attrFilterArray,
(void *) attrFilterArray,
((numattr+1)*sizeof(Targetattrfilter *)) );
attrFilterArray[numattr] = NULL;
+ if(rc){
+ free_targetattrfilters(&attrFilterArray);
+ } else {
+ *input_attrFilterArray = attrFilterArray;
+ }
- *input_attrFilterArray = attrFilterArray;
- return 0;
-
+ return rc;
}
/*
diff --git a/ldap/servers/plugins/dna/dna.c b/ldap/servers/plugins/dna/dna.c
index e11dd99..48d539f 100644
--- a/ldap/servers/plugins/dna/dna.c
+++ b/ldap/servers/plugins/dna/dna.c
@@ -1515,11 +1515,13 @@ dna_get_shared_servers(struct configEntry *config_entry, PRCList **servers)
* to lowest. */
struct dnaServer *sitem;
PRCList* item = PR_LIST_HEAD(*servers);
+ int inserted = 0;
while (item != *servers) {
sitem = (struct dnaServer *)item;
if (server->remaining > sitem->remaining) {
PR_INSERT_BEFORE(&(server->list), item);
+ inserted = 1;
break;
}
@@ -1528,9 +1530,13 @@ dna_get_shared_servers(struct configEntry *config_entry, PRCList **servers)
if (*servers == item) {
/* add to tail */
PR_INSERT_BEFORE(&(server->list), item);
+ inserted = 1;
break;
}
}
+ if(!inserted){
+ dna_free_shared_server(&server);
+ }
}
}
}
@@ -3340,6 +3346,7 @@ dna_pre_op(Slapi_PBlock * pb, int modtype)
bail:
if (resulting_e)
slapi_entry_free(resulting_e);
+ slapi_mods_free(&smods);
if (ret) {
slapi_log_error(SLAPI_LOG_PLUGIN, DNA_PLUGIN_SUBSYSTEM,
diff --git a/ldap/servers/plugins/linkedattrs/linked_attrs.c b/ldap/servers/plugins/linkedattrs/linked_attrs.c
index 4bea10f..7d8370d 100644
--- a/ldap/servers/plugins/linkedattrs/linked_attrs.c
+++ b/ldap/servers/plugins/linkedattrs/linked_attrs.c
@@ -755,6 +755,7 @@ linked_attrs_insert_config_index(struct configEntry *entry)
struct configEntry *config_entry = NULL;
struct configIndex *index_entry = NULL;
PRCList *list = PR_LIST_HEAD(g_managed_config_index);
+ int inserted = 0;
index_entry = (struct configIndex *)slapi_ch_calloc(1, sizeof(struct configIndex));
index_entry->config = entry;
@@ -769,6 +770,7 @@ linked_attrs_insert_config_index(struct configEntry *entry)
slapi_log_error(SLAPI_LOG_CONFIG, LINK_PLUGIN_SUBSYSTEM,
"store [%s] before [%s] \n", entry->dn,
config_entry->dn);
+ inserted = 1;
break;
}
@@ -779,6 +781,7 @@ linked_attrs_insert_config_index(struct configEntry *entry)
PR_INSERT_BEFORE(&(index_entry->list), list);
slapi_log_error(SLAPI_LOG_CONFIG, LINK_PLUGIN_SUBSYSTEM,
"store [%s] at tail\n", entry->dn);
+ inserted = 1;
break;
}
}
@@ -787,6 +790,10 @@ linked_attrs_insert_config_index(struct configEntry *entry)
slapi_log_error(SLAPI_LOG_CONFIG, LINK_PLUGIN_SUBSYSTEM,
"store [%s] at head \n", entry->dn);
PR_INSERT_LINK(&(index_entry->list), g_managed_config_index);
+ inserted = 1;
+ }
+ if(!inserted){
+ slapi_ch_free((void **)&index_entry);
}
}
diff --git a/ldap/servers/plugins/pam_passthru/pam_ptconfig.c b/ldap/servers/plugins/pam_passthru/pam_ptconfig.c
index fb2dc2b..c40b87e 100644
--- a/ldap/servers/plugins/pam_passthru/pam_ptconfig.c
+++ b/ldap/servers/plugins/pam_passthru/pam_ptconfig.c
@@ -602,6 +602,7 @@ pam_passthru_apply_config (Slapi_Entry* e)
PRCList *list;
Slapi_Attr *a = NULL;
char *filter_str = NULL;
+ int inserted = 0;
pam_ident_attr = slapi_entry_attr_get_charptr(e, PAMPT_PAM_IDENT_ATTR);
map_method = slapi_entry_attr_get_charptr(e, PAMPT_MAP_METHOD_ATTR);
@@ -688,6 +689,7 @@ pam_passthru_apply_config (Slapi_Entry* e)
PR_INSERT_BEFORE(&(entry->list), list);
slapi_log_error(SLAPI_LOG_CONFIG, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
"store [%s] at tail\n", entry->dn);
+ inserted = 1;
break;
}
}
@@ -696,9 +698,13 @@ pam_passthru_apply_config (Slapi_Entry* e)
PR_INSERT_LINK(&(entry->list), pam_passthru_global_config);
slapi_log_error(SLAPI_LOG_CONFIG, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
"store [%s] at head \n", entry->dn);
+ inserted = 1;
}
bail:
+ if(!inserted){
+ pam_passthru_free_config_entry(&entry);
+ }
slapi_ch_free_string(&new_service);
slapi_ch_free_string(&map_method);
slapi_ch_free_string(&pam_ident_attr);
diff --git a/ldap/servers/plugins/replication/repl5_replica_config.c b/ldap/servers/plugins/replication/repl5_replica_config.c
index 99cef03..d4ff5c1 100644
--- a/ldap/servers/plugins/replication/repl5_replica_config.c
+++ b/ldap/servers/plugins/replication/repl5_replica_config.c
@@ -1772,7 +1772,7 @@ check_replicas_are_done_cleaning(cleanruv_data *data )
{
Object *agmt_obj;
Repl_Agmt *agmt;
- char *csnstr = NULL;
+ char csnstr[CSN_STRSIZE];
char *filter = NULL;
int not_all_cleaned = 1;
int interval = 10;
@@ -1815,7 +1815,6 @@ check_replicas_are_done_cleaning(cleanruv_data *data )
interval = 14400;
}
}
- slapi_ch_free_string(&csnstr);
slapi_ch_free_string(&filter);
}
diff --git a/ldap/servers/plugins/replication/windows_inc_protocol.c b/ldap/servers/plugins/replication/windows_inc_protocol.c
index cf979cc..e503f30 100644
--- a/ldap/servers/plugins/replication/windows_inc_protocol.c
+++ b/ldap/servers/plugins/replication/windows_inc_protocol.c
@@ -1024,6 +1024,7 @@ windows_inc_run(Private_Repl_Protocol *prp)
windows_conn_cancel_linger(prp->conn);
/* ... and disconnect, if currently connected */
windows_conn_disconnect(prp->conn);
+ ruv_destroy ( &ruv );
LDAPDebug0Args( LDAP_DEBUG_TRACE, "<= windows_inc_run\n" );
}
diff --git a/ldap/servers/plugins/syntaxes/value.c b/ldap/servers/plugins/syntaxes/value.c
index efef9a8..0335a89 100644
--- a/ldap/servers/plugins/syntaxes/value.c
+++ b/ldap/servers/plugins/syntaxes/value.c
@@ -282,10 +282,13 @@ value_cmp(
value_normalize_ext( v1->bv_val, syntax,
1 /* trim leading blanks */, &alt );
if (alt) {
+ int inserted = 0;
+
if (free_v1) {
slapi_ch_free_string(&v1->bv_val);
v1->bv_val = alt;
v1->bv_len = strlen(alt);
+ inserted = 1;
} else {
if (strlen(alt) < buffer_space) {
v1->bv_len = strlen(alt);
@@ -297,8 +300,12 @@ value_cmp(
v1 = (struct berval *)slapi_ch_malloc(sizeof(struct berval));
v1->bv_val = alt;
v1->bv_len = strlen(alt);
+ inserted = 1;
}
}
+ if(!inserted){
+ slapi_ch_free_string(&alt);
+ }
}
if (!free_v1) {
buffer_space -= v1->bv_len + 1;
@@ -320,10 +327,13 @@ value_cmp(
value_normalize_ext( v2->bv_val, syntax,
1 /* trim leading blanks */, &alt );
if (alt) {
+ int inserted = 0;
+
if (free_v2) {
slapi_ch_free_string(&v2->bv_val);
v2->bv_val = alt;
v2->bv_len = strlen(alt);
+ inserted = 1;
} else {
if (strlen(alt) < buffer_space) {
v2->bv_len = strlen(alt);
@@ -335,8 +345,12 @@ value_cmp(
v2 = (struct berval *)slapi_ch_malloc(sizeof(struct berval));
v2->bv_val = alt;
v2->bv_len = strlen(alt);
+ inserted = 1;
}
}
+ if(!inserted){
+ slapi_ch_free_string(&alt);
+ }
}
if (!free_v2) {
buffer_space -= v2->bv_len + 1;
diff --git a/ldap/servers/slapd/agtmmap.c b/ldap/servers/slapd/agtmmap.c
index f18138a..3922547 100644
--- a/ldap/servers/slapd/agtmmap.c
+++ b/ldap/servers/slapd/agtmmap.c
@@ -196,6 +196,7 @@ agt_mopen_stats (char * statsfile, int mode, int *hdl)
}
if(fstat (fd, &fileinfo) != 0){
+ close(fd);
rc = errno;
goto bail;
}
diff --git a/ldap/servers/slapd/back-ldbm/dblayer.c b/ldap/servers/slapd/back-ldbm/dblayer.c
index 5f94a29..302a07e 100644
--- a/ldap/servers/slapd/back-ldbm/dblayer.c
+++ b/ldap/servers/slapd/back-ldbm/dblayer.c
@@ -1926,7 +1926,7 @@ dblayer_get_id2entry_size(ldbm_instance *inst)
char *id2entry_file = NULL;
PRFileInfo64 info;
int rc;
- char inst_dir[MAXPATHLEN], *inst_dirp;
+ char inst_dir[MAXPATHLEN], *inst_dirp = NULL;
if (NULL == inst) {
return 0;
@@ -1935,6 +1935,9 @@ dblayer_get_id2entry_size(ldbm_instance *inst)
inst_dirp = dblayer_get_full_inst_dir(li, inst, inst_dir, MAXPATHLEN);
id2entry_file = slapi_ch_smprintf("%s/%s", inst_dirp,
ID2ENTRY LDBM_FILENAME_SUFFIX);
+ if(inst_dirp != inst_dir){
+ slapi_ch_free_string(&inst_dirp);
+ }
rc = PR_GetFileInfo64(id2entry_file, &info);
slapi_ch_free_string(&id2entry_file);
if (rc) {
@@ -3094,6 +3097,9 @@ dblayer_open_file(backend *be, char* indexname, int open_flag,
}
abs_file_name = slapi_ch_smprintf("%s%c%s",
inst_dirp, get_sep(inst_dirp), file_name);
+ if (inst_dirp != inst_dir){
+ slapi_ch_free_string(&inst_dirp);
+ }
DB_OPEN(pENV->dblayer_openflags,
dbp, NULL/* txnid */, abs_file_name, subname, DB_BTREE,
open_flags, priv->dblayer_file_mode, return_value);
@@ -3109,8 +3115,6 @@ dblayer_open_file(backend *be, char* indexname, int open_flag,
goto out;
slapi_ch_free_string(&abs_file_name);
- if (inst_dirp != inst_dir)
- slapi_ch_free_string(&inst_dirp);
}
DB_OPEN(pENV->dblayer_openflags,
dbp, NULL, /* txnid */ rel_path, subname, DB_BTREE,
diff --git a/ldap/servers/slapd/entry.c b/ldap/servers/slapd/entry.c
index d7dbf61..ba7f338 100644
--- a/ldap/servers/slapd/entry.c
+++ b/ldap/servers/slapd/entry.c
@@ -574,6 +574,7 @@ str2entry_fast( const char *rawdn, const Slapi_RDN *srdn, char *s, int flags, in
}
done:
+ csnset_free(&valuecsnset);
csn_free(&attributedeletioncsn);
csn_free(&maxcsn);
LDAPDebug( LDAP_DEBUG_TRACE, "<= str2entry_fast 0x%x\n",
@@ -766,6 +767,7 @@ str2entry_dupcheck( const char *rawdn, char *s, int flags, int read_stateinfo )
( 0 != ( flags & SLAPI_STR2ENTRY_REMOVEDUPVALS ));
Slapi_Value *value = 0;
CSN *attributedeletioncsn= NULL;
+ CSNSet *valuecsnset= NULL;
CSN *maxcsn= NULL;
char *normdn = NULL;
int strict = 0;
@@ -786,7 +788,6 @@ str2entry_dupcheck( const char *rawdn, char *s, int flags, int read_stateinfo )
}
while ( (s = ldif_getline( &next )) != NULL )
{
- CSNSet *valuecsnset= NULL;
int value_state= VALUE_NOTFOUND;
int attr_state= VALUE_NOTFOUND;
int freeval = 0;
@@ -842,6 +843,7 @@ str2entry_dupcheck( const char *rawdn, char *s, int flags, int read_stateinfo )
"str2entry_dupcheck: Invalid DN: %s\n", rawdn);
slapi_entry_free( e );
if (freeval) slapi_ch_free_string(&bvvalue.bv_val);
+ csnset_free(&valuecsnset);
csn_free(&attributedeletioncsn);
csn_free(&maxcsn);
return NULL;
@@ -864,6 +866,7 @@ str2entry_dupcheck( const char *rawdn, char *s, int flags, int read_stateinfo )
"str2entry_dupcheck: Invalid DN: %s\n", rawdn);
slapi_entry_free( e );
if (freeval) slapi_ch_free_string(&bvvalue.bv_val);
+ csnset_free(&valuecsnset);
csn_free(&attributedeletioncsn);
csn_free(&maxcsn);
return NULL;
@@ -977,6 +980,7 @@ str2entry_dupcheck( const char *rawdn, char *s, int flags, int read_stateinfo )
if (freeval) slapi_ch_free_string(&bvvalue.bv_val);
csn_free(&attributedeletioncsn);
csn_free(&maxcsn);
+ csnset_free(&valuecsnset);
return NULL;
}
for ( i = 0; i < nattrs; i++ )
@@ -1319,6 +1323,7 @@ free_and_return:
}
slapi_ch_free((void **) &dyn_attrs );
if (value) slapi_value_free(&value);
+ csnset_free(&valuecsnset);
csn_free(&attributedeletioncsn);
csn_free(&maxcsn);
diff --git a/ldap/servers/slapd/schema.c b/ldap/servers/slapd/schema.c
index dc56534..603ac08 100644
--- a/ldap/servers/slapd/schema.c
+++ b/ldap/servers/slapd/schema.c
@@ -3079,11 +3079,11 @@ read_oc_ldif ( const char *input, struct objclass **oc, char *errorbuf,
pnew_oc->oc_kind = kind;
*oc = pnew_oc;
+
return read_oc_ldif_return( LDAP_SUCCESS, pOcOid, psbOcName, pOcSup,
oc_origins, num_origins, pOcDesc );
}
-
static void
oc_free( struct objclass **ocp )
{
@@ -3965,7 +3965,9 @@ load_schema_dse(Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Entry *ignored,
if ( LDAP_SUCCESS != (*returncode = read_oc_ldif(s, &oc, returntext,
SLAPI_DSE_RETURNTEXT_SIZE, flags,
primary_file /* force user defined? */,
- schema_ds4x_compat))) {
+ schema_ds4x_compat)))
+ {
+ oc_free( &oc );
break;
}
if (flags & DSE_SCHEMA_NO_LOAD)
diff --git a/ldap/servers/slapd/snmp_collator.c b/ldap/servers/slapd/snmp_collator.c
index aeac7ae..b3d072a 100644
--- a/ldap/servers/slapd/snmp_collator.c
+++ b/ldap/servers/slapd/snmp_collator.c
@@ -738,8 +738,10 @@ snmp_update_cache_stats()
/* set the cache hits/cache entries info */
be = slapi_get_first_backend(&cookie);
- if (!be)
+ if (!be){
+ slapi_ch_free ((void **) &cookie);
return;
+ }
be_next = slapi_get_next_backend(cookie);
diff --git a/ldap/servers/slapd/tools/ldclt/data.c b/ldap/servers/slapd/tools/ldclt/data.c
index e0eac55..f6dd4ef 100644
--- a/ldap/servers/slapd/tools/ldclt/data.c
+++ b/ldap/servers/slapd/tools/ldclt/data.c
@@ -335,6 +335,8 @@ exit:
#ifdef _WIN32
if (findPath) free (findPath);
#endif
+ close(fd);
+
return rc;
}
diff --git a/ldap/servers/slapd/tools/mmldif.c b/ldap/servers/slapd/tools/mmldif.c
index 6d62338..fb97129 100644
--- a/ldap/servers/slapd/tools/mmldif.c
+++ b/ldap/servers/slapd/tools/mmldif.c
@@ -735,6 +735,7 @@ readrec(edfFILE * edf1, attrib1_t ** attrib)
attrib1_t * newlist = NULL;
attrib1_t * a;
int ignore_rec = FALSE;
+ int free_it = 0;
*attrib = NULL;
if (edf1->end) {
@@ -759,6 +760,9 @@ readrec(edfFILE * edf1, attrib1_t ** attrib)
/* that's for the case where the file */
/* has a trailing blank line */
freefreelist(freelist);
+ if(free_it){
+ freefreelist(att);
+ }
return IDDS_MM_EOF;
}
break; /* return */
@@ -790,9 +794,11 @@ readrec(edfFILE * edf1, attrib1_t ** attrib)
continue;
if (!freelist) {
att = (attrib1_t *)malloc(sizeof(attrib1_t));
+ free_it = 1;
} else {
att = freelist;
freelist = freelist->next;
+ free_it = 0;
}
att->namelen = vptr-line;
diff --git a/ldap/servers/snmp/main.c b/ldap/servers/snmp/main.c
index 53af972..ca3fc1c 100644
--- a/ldap/servers/snmp/main.c
+++ b/ldap/servers/snmp/main.c
@@ -311,6 +311,9 @@ load_config(char *conf_path)
/* load agentx-master setting */
p = p + 13;
if ((p = strtok(p, " \t\n")) != NULL) {
+ if (agentx_master){
+ free(agentx_master);
+ }
if ((agentx_master = (char *) malloc(strlen(p) + 1)) != NULL)
strcpy(agentx_master, p);
}
diff --git a/lib/ldaputil/dbconf.c b/lib/ldaputil/dbconf.c
index 746afc9..e6de3b7 100644
--- a/lib/ldaputil/dbconf.c
+++ b/lib/ldaputil/dbconf.c
@@ -263,7 +263,10 @@ static int dbconf_parse_propval (char *buf, char *ptr,
/* Success - we have prop & val */
propval = (DBPropVal_t *)malloc(sizeof(DBPropVal_t));
- if (!propval) return LDAPU_ERR_OUT_OF_MEMORY;
+ if (!propval){
+ if (encval) free(val);
+ return LDAPU_ERR_OUT_OF_MEMORY;
+ }
memset((void *)propval, 0, sizeof(DBPropVal_t));
propval->prop = strdup(prop);
propval->val = val ? strdup(val) : 0;
@@ -273,7 +276,7 @@ static int dbconf_parse_propval (char *buf, char *ptr,
return LDAPU_ERR_OUT_OF_MEMORY;
}
- if (encval) free(val); /* val was allocated by dbconf_decodeval */
+ if(encval) free(val); /* val was allocated by dbconf_decodeval */
insert_dbinfo_propval(db_info, propval);
return LDAPU_SUCCESS;
diff --git a/lib/libaccess/register.cpp b/lib/libaccess/register.cpp
index 3f2acc5..766436e 100644
--- a/lib/libaccess/register.cpp
+++ b/lib/libaccess/register.cpp
@@ -791,6 +791,7 @@ ACL_AttrGetterRegister(NSErr_t *errp, const char *attr, ACLAttrGetterFn_t fn,
if (*hep == 0) { /* New entry */
PR_INIT_CLIST(&getter->list);
if (NULL == PR_HashTableAdd(ACLAttrGetterHash, attr, (void *)getter)) {
+ FREE(getter);
ACL_CritExit();
return -1;
}
diff --git a/lib/libadmin/error.c b/lib/libadmin/error.c
index c0a1f80..4ba9803 100644
--- a/lib/libadmin/error.c
+++ b/lib/libadmin/error.c
@@ -126,10 +126,13 @@ NSAPI_PUBLIC void output_alert(int type, char *info, char *details, int wait)
fprintf(stdout, "%s:%s\\n%s", error_headers[type], info, wrapped);
if(type==FILE_ERROR || type==SYSTEM_ERROR) {
err = get_error();
- if(err != 0)
+ if(err != 0){
+ char *err_str = verbose_error();
fprintf(stdout,
"\\n\\nThe system returned error number %d, "
- "which is %s.", err, verbose_error());
+ "which is %s.", err, err_str);
+ FREE(err_str);
+ }
}
fprintf(stdout, "\");");
10 years, 10 months
ldap/servers lib/ldaputil lib/libaccess lib/libadmin
by Mark Reynolds
ldap/servers/plugins/acl/acl.h | 1
ldap/servers/plugins/acl/acllist.c | 7 -
ldap/servers/plugins/acl/aclparse.c | 29 +++----
ldap/servers/plugins/dna/dna.c | 7 +
ldap/servers/plugins/linkedattrs/linked_attrs.c | 7 +
ldap/servers/plugins/pam_passthru/pam_ptconfig.c | 6 +
ldap/servers/plugins/replication/repl5_replica_config.c | 3
ldap/servers/plugins/replication/windows_inc_protocol.c | 1
ldap/servers/plugins/syntaxes/value.c | 14 +++
ldap/servers/slapd/agtmmap.c | 1
ldap/servers/slapd/back-ldbm/dblayer.c | 10 +-
ldap/servers/slapd/entry.c | 7 +
ldap/servers/slapd/entrywsi.c | 62 +++++++++-------
ldap/servers/slapd/schema.c | 5 +
ldap/servers/slapd/snmp_collator.c | 4 -
ldap/servers/slapd/tools/ldclt/data.c | 2
ldap/servers/slapd/tools/mmldif.c | 6 +
ldap/servers/snmp/main.c | 3
lib/ldaputil/dbconf.c | 7 +
lib/libaccess/register.cpp | 1
lib/libadmin/error.c | 7 +
21 files changed, 132 insertions(+), 58 deletions(-)
New commits:
commit c99d4c0741aca2fb0f42dd34e147f65011537cb4
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Wed Jun 5 16:19:57 2013 -0400
Coverity Fixes (Part 4)
11753 - Resource leak (aclparse.c)
11754 - Resource leak (dna.c)
11755 - Resource leak (dna.c)
11756 - Resource leak (linked_attrs.c)
11757 - Resource leak (pam_ptconfig.c)
11758 - Resource leak (repl5_replica_config.c)
11759 - Resource leak (windows_inc_protocol.c)
11760 - Resource leak (syntaxes/value.c)
11761 - Resource leak (dblayer.c)
11764 - Resource leak (dblayer.c)
11766 - Resource leak (dblayer.c)
11769 - Resource leak (entry.c)
11770 - Resource leak (entry.c)
11771 - Resource leak (entrywsi.c)
11772 - Resource leak (entrywsi.c)
11773 - Resource leak (schema.c)
11774 - Resource leak (snmp_collator.c)
11775 - Resource leak (ldclt/data.c)
11776 - Resource leak (tools/mmldif.c)
11777 - Resource leak (snmp/main.c)
11778 - Resource leak (lib/libutil/dbconf.c)
11779 - Resource leak (lib/libaccess/register.cpp)
11781 - Resource leak (lib/libadmin/error.c)
11872 - Resource leak (agtmmap.c)
https://bugzilla.redhat.com/show_bug.cgi?id=970221
Reviewed by: nhosoi(Thanks!)
diff --git a/ldap/servers/plugins/acl/acl.h b/ldap/servers/plugins/acl/acl.h
index 6dbb68f..d69db30 100644
--- a/ldap/servers/plugins/acl/acl.h
+++ b/ldap/servers/plugins/acl/acl.h
@@ -870,6 +870,7 @@ int acllist_moddn_aci_needsLock ( Slapi_DN *oldsdn, char *newdn );
void acllist_print_tree ( Avlnode *root, int *depth, char *start, char *side);
AciContainer *acllist_get_aciContainer_new ( );
void acllist_done_aciContainer ( AciContainer *);
+void free_targetattrfilters( Targetattrfilter ***attrFilterArray);
aclUserGroup* aclg_find_userGroup (const char *n_dn);
void aclg_regen_ugroup_signature( aclUserGroup *ugroup);
diff --git a/ldap/servers/plugins/acl/acllist.c b/ldap/servers/plugins/acl/acllist.c
index e8198af..623a739 100644
--- a/ldap/servers/plugins/acl/acllist.c
+++ b/ldap/servers/plugins/acl/acllist.c
@@ -94,7 +94,6 @@ static int __acllist_add_aci ( aci_t *aci );
static int __acllist_aciContainer_node_cmp ( caddr_t d1, caddr_t d2 );
static int __acllist_aciContainer_node_dup ( caddr_t d1, caddr_t d2 );
static void __acllist_free_aciContainer ( AciContainer **container);
-static void free_targetattrfilters( Targetattrfilter ***input_attrFilterArray);
void my_print( Avlnode *root );
@@ -565,8 +564,9 @@ acllist_free_aci(aci_t *item)
slapi_ch_free ( (void **) &item );
}
-static void free_targetattrfilters( Targetattrfilter ***attrFilterArray) {
-
+void
+free_targetattrfilters( Targetattrfilter ***attrFilterArray)
+{
if (*attrFilterArray) {
int i = 0;
Targetattrfilter *attrfilter;
@@ -592,7 +592,6 @@ static void free_targetattrfilters( Targetattrfilter ***attrFilterArray) {
/* Now free the array */
slapi_ch_free ( (void **) attrFilterArray );
}
-
}
/* SEARCH */
diff --git a/ldap/servers/plugins/acl/aclparse.c b/ldap/servers/plugins/acl/aclparse.c
index 5941b2a..bf02764 100644
--- a/ldap/servers/plugins/acl/aclparse.c
+++ b/ldap/servers/plugins/acl/aclparse.c
@@ -1970,14 +1970,13 @@ static int __acl__init_targetattrfilters( aci_t *aci, char *input_str) {
* We need to put each component into a targetattrfilter component of
* the array.
*
-*/
-
+ */
static int process_filter_list( Targetattrfilter ***input_attrFilterArray,
char * input_str) {
char *str, *end_attr;
Targetattrfilter *attrfilter = NULL;
- int numattr=0;
+ int numattr=0, rc = 0;
Targetattrfilter **attrFilterArray = NULL;
str = input_str;
@@ -2009,22 +2008,20 @@ static int process_filter_list( Targetattrfilter ***input_attrFilterArray,
memset (attrfilter, 0, sizeof(Targetattrfilter));
if (strstr( str,":") != NULL) {
-
if ( __acl_init_targetattrfilter( attrfilter, str ) != 0 ) {
slapi_ch_free((void**)&attrfilter);
- return(ACL_SYNTAX_ERR);
+ rc = ACL_SYNTAX_ERR;
+ break;
}
} else {
slapi_ch_free((void**)&attrfilter);
- return(ACL_SYNTAX_ERR);
+ rc = ACL_SYNTAX_ERR;
+ break;
}
-
/*
- * Add the attrfilte to the targetAttrFilter list
- */
-
-
+ * Add the attrfilter to the targetAttrFilter list
+ */
attrFilterArray = (Targetattrfilter **) slapi_ch_realloc (
(void *) attrFilterArray,
((numattr+1)*sizeof(Targetattrfilter *)) );
@@ -2033,7 +2030,6 @@ static int process_filter_list( Targetattrfilter ***input_attrFilterArray,
/* Move on to the next attribute in the list */
str = end_attr;
-
}/* while */
/* NULL terminate the list */
@@ -2042,10 +2038,13 @@ static int process_filter_list( Targetattrfilter ***input_attrFilterArray,
(void *) attrFilterArray,
((numattr+1)*sizeof(Targetattrfilter *)) );
attrFilterArray[numattr] = NULL;
+ if(rc){
+ free_targetattrfilters(&attrFilterArray);
+ } else {
+ *input_attrFilterArray = attrFilterArray;
+ }
- *input_attrFilterArray = attrFilterArray;
- return 0;
-
+ return rc;
}
/*
diff --git a/ldap/servers/plugins/dna/dna.c b/ldap/servers/plugins/dna/dna.c
index e11dd99..48d539f 100644
--- a/ldap/servers/plugins/dna/dna.c
+++ b/ldap/servers/plugins/dna/dna.c
@@ -1515,11 +1515,13 @@ dna_get_shared_servers(struct configEntry *config_entry, PRCList **servers)
* to lowest. */
struct dnaServer *sitem;
PRCList* item = PR_LIST_HEAD(*servers);
+ int inserted = 0;
while (item != *servers) {
sitem = (struct dnaServer *)item;
if (server->remaining > sitem->remaining) {
PR_INSERT_BEFORE(&(server->list), item);
+ inserted = 1;
break;
}
@@ -1528,9 +1530,13 @@ dna_get_shared_servers(struct configEntry *config_entry, PRCList **servers)
if (*servers == item) {
/* add to tail */
PR_INSERT_BEFORE(&(server->list), item);
+ inserted = 1;
break;
}
}
+ if(!inserted){
+ dna_free_shared_server(&server);
+ }
}
}
}
@@ -3340,6 +3346,7 @@ dna_pre_op(Slapi_PBlock * pb, int modtype)
bail:
if (resulting_e)
slapi_entry_free(resulting_e);
+ slapi_mods_free(&smods);
if (ret) {
slapi_log_error(SLAPI_LOG_PLUGIN, DNA_PLUGIN_SUBSYSTEM,
diff --git a/ldap/servers/plugins/linkedattrs/linked_attrs.c b/ldap/servers/plugins/linkedattrs/linked_attrs.c
index 4bea10f..7d8370d 100644
--- a/ldap/servers/plugins/linkedattrs/linked_attrs.c
+++ b/ldap/servers/plugins/linkedattrs/linked_attrs.c
@@ -755,6 +755,7 @@ linked_attrs_insert_config_index(struct configEntry *entry)
struct configEntry *config_entry = NULL;
struct configIndex *index_entry = NULL;
PRCList *list = PR_LIST_HEAD(g_managed_config_index);
+ int inserted = 0;
index_entry = (struct configIndex *)slapi_ch_calloc(1, sizeof(struct configIndex));
index_entry->config = entry;
@@ -769,6 +770,7 @@ linked_attrs_insert_config_index(struct configEntry *entry)
slapi_log_error(SLAPI_LOG_CONFIG, LINK_PLUGIN_SUBSYSTEM,
"store [%s] before [%s] \n", entry->dn,
config_entry->dn);
+ inserted = 1;
break;
}
@@ -779,6 +781,7 @@ linked_attrs_insert_config_index(struct configEntry *entry)
PR_INSERT_BEFORE(&(index_entry->list), list);
slapi_log_error(SLAPI_LOG_CONFIG, LINK_PLUGIN_SUBSYSTEM,
"store [%s] at tail\n", entry->dn);
+ inserted = 1;
break;
}
}
@@ -787,6 +790,10 @@ linked_attrs_insert_config_index(struct configEntry *entry)
slapi_log_error(SLAPI_LOG_CONFIG, LINK_PLUGIN_SUBSYSTEM,
"store [%s] at head \n", entry->dn);
PR_INSERT_LINK(&(index_entry->list), g_managed_config_index);
+ inserted = 1;
+ }
+ if(!inserted){
+ slapi_ch_free((void **)&index_entry);
}
}
diff --git a/ldap/servers/plugins/pam_passthru/pam_ptconfig.c b/ldap/servers/plugins/pam_passthru/pam_ptconfig.c
index fb2dc2b..c40b87e 100644
--- a/ldap/servers/plugins/pam_passthru/pam_ptconfig.c
+++ b/ldap/servers/plugins/pam_passthru/pam_ptconfig.c
@@ -602,6 +602,7 @@ pam_passthru_apply_config (Slapi_Entry* e)
PRCList *list;
Slapi_Attr *a = NULL;
char *filter_str = NULL;
+ int inserted = 0;
pam_ident_attr = slapi_entry_attr_get_charptr(e, PAMPT_PAM_IDENT_ATTR);
map_method = slapi_entry_attr_get_charptr(e, PAMPT_MAP_METHOD_ATTR);
@@ -688,6 +689,7 @@ pam_passthru_apply_config (Slapi_Entry* e)
PR_INSERT_BEFORE(&(entry->list), list);
slapi_log_error(SLAPI_LOG_CONFIG, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
"store [%s] at tail\n", entry->dn);
+ inserted = 1;
break;
}
}
@@ -696,9 +698,13 @@ pam_passthru_apply_config (Slapi_Entry* e)
PR_INSERT_LINK(&(entry->list), pam_passthru_global_config);
slapi_log_error(SLAPI_LOG_CONFIG, PAM_PASSTHRU_PLUGIN_SUBSYSTEM,
"store [%s] at head \n", entry->dn);
+ inserted = 1;
}
bail:
+ if(!inserted){
+ pam_passthru_free_config_entry(&entry);
+ }
slapi_ch_free_string(&new_service);
slapi_ch_free_string(&map_method);
slapi_ch_free_string(&pam_ident_attr);
diff --git a/ldap/servers/plugins/replication/repl5_replica_config.c b/ldap/servers/plugins/replication/repl5_replica_config.c
index cc0a93f..7d83c99 100644
--- a/ldap/servers/plugins/replication/repl5_replica_config.c
+++ b/ldap/servers/plugins/replication/repl5_replica_config.c
@@ -1847,7 +1847,7 @@ check_replicas_are_done_cleaning(cleanruv_data *data )
{
Object *agmt_obj;
Repl_Agmt *agmt;
- char *csnstr = NULL;
+ char csnstr[CSN_STRSIZE];
char *filter = NULL;
int not_all_cleaned = 1;
int interval = 10;
@@ -1890,7 +1890,6 @@ check_replicas_are_done_cleaning(cleanruv_data *data )
interval = 14400;
}
}
- slapi_ch_free_string(&csnstr);
slapi_ch_free_string(&filter);
}
diff --git a/ldap/servers/plugins/replication/windows_inc_protocol.c b/ldap/servers/plugins/replication/windows_inc_protocol.c
index cf979cc..e503f30 100644
--- a/ldap/servers/plugins/replication/windows_inc_protocol.c
+++ b/ldap/servers/plugins/replication/windows_inc_protocol.c
@@ -1024,6 +1024,7 @@ windows_inc_run(Private_Repl_Protocol *prp)
windows_conn_cancel_linger(prp->conn);
/* ... and disconnect, if currently connected */
windows_conn_disconnect(prp->conn);
+ ruv_destroy ( &ruv );
LDAPDebug0Args( LDAP_DEBUG_TRACE, "<= windows_inc_run\n" );
}
diff --git a/ldap/servers/plugins/syntaxes/value.c b/ldap/servers/plugins/syntaxes/value.c
index efef9a8..0335a89 100644
--- a/ldap/servers/plugins/syntaxes/value.c
+++ b/ldap/servers/plugins/syntaxes/value.c
@@ -282,10 +282,13 @@ value_cmp(
value_normalize_ext( v1->bv_val, syntax,
1 /* trim leading blanks */, &alt );
if (alt) {
+ int inserted = 0;
+
if (free_v1) {
slapi_ch_free_string(&v1->bv_val);
v1->bv_val = alt;
v1->bv_len = strlen(alt);
+ inserted = 1;
} else {
if (strlen(alt) < buffer_space) {
v1->bv_len = strlen(alt);
@@ -297,8 +300,12 @@ value_cmp(
v1 = (struct berval *)slapi_ch_malloc(sizeof(struct berval));
v1->bv_val = alt;
v1->bv_len = strlen(alt);
+ inserted = 1;
}
}
+ if(!inserted){
+ slapi_ch_free_string(&alt);
+ }
}
if (!free_v1) {
buffer_space -= v1->bv_len + 1;
@@ -320,10 +327,13 @@ value_cmp(
value_normalize_ext( v2->bv_val, syntax,
1 /* trim leading blanks */, &alt );
if (alt) {
+ int inserted = 0;
+
if (free_v2) {
slapi_ch_free_string(&v2->bv_val);
v2->bv_val = alt;
v2->bv_len = strlen(alt);
+ inserted = 1;
} else {
if (strlen(alt) < buffer_space) {
v2->bv_len = strlen(alt);
@@ -335,8 +345,12 @@ value_cmp(
v2 = (struct berval *)slapi_ch_malloc(sizeof(struct berval));
v2->bv_val = alt;
v2->bv_len = strlen(alt);
+ inserted = 1;
}
}
+ if(!inserted){
+ slapi_ch_free_string(&alt);
+ }
}
if (!free_v2) {
buffer_space -= v2->bv_len + 1;
diff --git a/ldap/servers/slapd/agtmmap.c b/ldap/servers/slapd/agtmmap.c
index f18138a..3922547 100644
--- a/ldap/servers/slapd/agtmmap.c
+++ b/ldap/servers/slapd/agtmmap.c
@@ -196,6 +196,7 @@ agt_mopen_stats (char * statsfile, int mode, int *hdl)
}
if(fstat (fd, &fileinfo) != 0){
+ close(fd);
rc = errno;
goto bail;
}
diff --git a/ldap/servers/slapd/back-ldbm/dblayer.c b/ldap/servers/slapd/back-ldbm/dblayer.c
index 2f05668..e93f79a 100644
--- a/ldap/servers/slapd/back-ldbm/dblayer.c
+++ b/ldap/servers/slapd/back-ldbm/dblayer.c
@@ -1980,7 +1980,7 @@ dblayer_get_id2entry_size(ldbm_instance *inst)
char *id2entry_file = NULL;
PRFileInfo64 info;
int rc;
- char inst_dir[MAXPATHLEN], *inst_dirp;
+ char inst_dir[MAXPATHLEN], *inst_dirp = NULL;
if (NULL == inst) {
return 0;
@@ -1989,6 +1989,9 @@ dblayer_get_id2entry_size(ldbm_instance *inst)
inst_dirp = dblayer_get_full_inst_dir(li, inst, inst_dir, MAXPATHLEN);
id2entry_file = slapi_ch_smprintf("%s/%s", inst_dirp,
ID2ENTRY LDBM_FILENAME_SUFFIX);
+ if(inst_dirp != inst_dir){
+ slapi_ch_free_string(&inst_dirp);
+ }
rc = PR_GetFileInfo64(id2entry_file, &info);
slapi_ch_free_string(&id2entry_file);
if (rc) {
@@ -3160,6 +3163,9 @@ dblayer_open_file(backend *be, char* indexname, int open_flag,
}
abs_file_name = slapi_ch_smprintf("%s%c%s",
inst_dirp, get_sep(inst_dirp), file_name);
+ if (inst_dirp != inst_dir){
+ slapi_ch_free_string(&inst_dirp);
+ }
DB_OPEN(pENV->dblayer_openflags,
dbp, NULL/* txnid */, abs_file_name, subname, DB_BTREE,
open_flags, priv->dblayer_file_mode, return_value);
@@ -3175,8 +3181,6 @@ dblayer_open_file(backend *be, char* indexname, int open_flag,
goto out;
slapi_ch_free_string(&abs_file_name);
- if (inst_dirp != inst_dir)
- slapi_ch_free_string(&inst_dirp);
}
DB_OPEN(pENV->dblayer_openflags,
dbp, NULL, /* txnid */ rel_path, subname, DB_BTREE,
diff --git a/ldap/servers/slapd/entry.c b/ldap/servers/slapd/entry.c
index 06815fb..ea86fcc 100644
--- a/ldap/servers/slapd/entry.c
+++ b/ldap/servers/slapd/entry.c
@@ -574,6 +574,7 @@ str2entry_fast( const char *rawdn, const Slapi_RDN *srdn, char *s, int flags, in
}
done:
+ csnset_free(&valuecsnset);
csn_free(&attributedeletioncsn);
csn_free(&maxcsn);
LDAPDebug( LDAP_DEBUG_TRACE, "<= str2entry_fast 0x%x\n",
@@ -766,6 +767,7 @@ str2entry_dupcheck( const char *rawdn, char *s, int flags, int read_stateinfo )
( 0 != ( flags & SLAPI_STR2ENTRY_REMOVEDUPVALS ));
Slapi_Value *value = 0;
CSN *attributedeletioncsn= NULL;
+ CSNSet *valuecsnset= NULL;
CSN *maxcsn= NULL;
char *normdn = NULL;
int strict = 0;
@@ -786,7 +788,6 @@ str2entry_dupcheck( const char *rawdn, char *s, int flags, int read_stateinfo )
}
while ( (s = ldif_getline( &next )) != NULL )
{
- CSNSet *valuecsnset= NULL;
int value_state= VALUE_NOTFOUND;
int attr_state= VALUE_NOTFOUND;
int freeval = 0;
@@ -842,6 +843,7 @@ str2entry_dupcheck( const char *rawdn, char *s, int flags, int read_stateinfo )
"str2entry_dupcheck: Invalid DN: %s\n", rawdn);
slapi_entry_free( e );
if (freeval) slapi_ch_free_string(&bvvalue.bv_val);
+ csnset_free(&valuecsnset);
csn_free(&attributedeletioncsn);
csn_free(&maxcsn);
return NULL;
@@ -864,6 +866,7 @@ str2entry_dupcheck( const char *rawdn, char *s, int flags, int read_stateinfo )
"str2entry_dupcheck: Invalid DN: %s\n", rawdn);
slapi_entry_free( e );
if (freeval) slapi_ch_free_string(&bvvalue.bv_val);
+ csnset_free(&valuecsnset);
csn_free(&attributedeletioncsn);
csn_free(&maxcsn);
return NULL;
@@ -977,6 +980,7 @@ str2entry_dupcheck( const char *rawdn, char *s, int flags, int read_stateinfo )
if (freeval) slapi_ch_free_string(&bvvalue.bv_val);
csn_free(&attributedeletioncsn);
csn_free(&maxcsn);
+ csnset_free(&valuecsnset);
return NULL;
}
for ( i = 0; i < nattrs; i++ )
@@ -1319,6 +1323,7 @@ free_and_return:
}
slapi_ch_free((void **) &dyn_attrs );
if (value) slapi_value_free(&value);
+ csnset_free(&valuecsnset);
csn_free(&attributedeletioncsn);
csn_free(&maxcsn);
diff --git a/ldap/servers/slapd/entrywsi.c b/ldap/servers/slapd/entrywsi.c
index 411fb6f..00de193 100644
--- a/ldap/servers/slapd/entrywsi.c
+++ b/ldap/servers/slapd/entrywsi.c
@@ -447,18 +447,21 @@ entry_add_present_values_wsi(Slapi_Entry *e, const char *type, struct berval **b
}
return retVal;
}
+
static int
entry_add_present_values_wsi_single_valued(Slapi_Entry *e, const char *type, struct berval **bervals, const CSN *csn, int urp, long flags)
{
int retVal= LDAP_SUCCESS;
Slapi_Value **valuestoadd = NULL;
+
valuearray_init_bervalarray(bervals,&valuestoadd); /* JCM SLOW FUNCTION */
if(!valuearray_isempty(valuestoadd))
{
Slapi_Attr *a= NULL;
long a_flags_orig;
int attr_state= entry_attr_find_wsi(e, type, &a);
- a_flags_orig = a->a_flags;
+
+ a_flags_orig = a->a_flags;
a->a_flags |= flags;
/* Check if the type of the to-be-added values has DN syntax or not. */
if (slapi_attr_is_dn_syntax_attr(a)) {
@@ -476,7 +479,6 @@ entry_add_present_values_wsi_single_valued(Slapi_Entry *e, const char *type, str
valuearray_update_csn (valuestoadd,CSN_TYPE_VALUE_UPDATED,csn);
valueset_add_valuearray_ext(&a->a_present_values, valuestoadd, SLAPI_VALUE_FLAG_PASSIN);
slapi_ch_free ( (void **)&valuestoadd );
-
/*
* Now delete non-RDN values from a->a_present_values; and
* restore possible RDN values from a->a_deleted_values
@@ -489,16 +491,16 @@ entry_add_present_values_wsi_single_valued(Slapi_Entry *e, const char *type, str
Slapi_Value **deletedvalues= NULL;
switch(attr_state)
{
- case ATTRIBUTE_PRESENT:
- /* The attribute is already on the present list */
- break;
- case ATTRIBUTE_DELETED:
- /* Move the deleted attribute onto the present list */
- entry_deleted_attribute_to_present_attribute(e, a);
- break;
- case ATTRIBUTE_NOTFOUND:
- /* No-op - attribute was initialized & added to entry above */
- break;
+ case ATTRIBUTE_PRESENT:
+ /* The attribute is already on the present list */
+ break;
+ case ATTRIBUTE_DELETED:
+ /* Move the deleted attribute onto the present list */
+ entry_deleted_attribute_to_present_attribute(e, a);
+ break;
+ case ATTRIBUTE_NOTFOUND:
+ /* No-op - attribute was initialized & added to entry above */
+ break;
}
/* Check if any of the values to be added are on the deleted list */
valueset_remove_valuearray(&a->a_deleted_values,
@@ -522,24 +524,28 @@ entry_add_present_values_wsi_single_valued(Slapi_Entry *e, const char *type, str
}
valuearray_update_csn(valuestoadd,CSN_TYPE_VALUE_UPDATED,csn);
retVal= attr_add_valuearray(a, valuestoadd, slapi_entry_get_dn_const(e));
- valuearray_free(&valuestoadd);
}
a->a_flags = a_flags_orig;
}
+ valuearray_free(&valuestoadd);
+
return(retVal);
}
+
static int
entry_add_present_values_wsi_multi_valued(Slapi_Entry *e, const char *type, struct berval **bervals, const CSN *csn, int urp, long flags)
{
int retVal= LDAP_SUCCESS;
Slapi_Value **valuestoadd = NULL;
+
valuearray_init_bervalarray(bervals,&valuestoadd); /* JCM SLOW FUNCTION */
if(!valuearray_isempty(valuestoadd))
{
- Slapi_Attr *a= NULL;
+ Slapi_Attr *a = NULL;
long a_flags_orig;
- int attr_state= entry_attr_find_wsi(e, type, &a);
- a_flags_orig = a->a_flags;
+ int attr_state = entry_attr_find_wsi(e, type, &a);
+
+ a_flags_orig = a->a_flags;
a->a_flags |= flags;
/* Check if the type of the to-be-added values has DN syntax or not. */
if (slapi_attr_is_dn_syntax_attr(a)) {
@@ -577,18 +583,19 @@ entry_add_present_values_wsi_multi_valued(Slapi_Entry *e, const char *type, stru
else
{
Slapi_Value **deletedvalues= NULL;
+
switch(attr_state)
{
- case ATTRIBUTE_PRESENT:
- /* The attribute is already on the present list */
- break;
- case ATTRIBUTE_DELETED:
- /* Move the deleted attribute onto the present list */
- entry_deleted_attribute_to_present_attribute(e, a);
- break;
- case ATTRIBUTE_NOTFOUND:
- /* No-op - attribute was initialized & added to entry above */
- break;
+ case ATTRIBUTE_PRESENT:
+ /* The attribute is already on the present list */
+ break;
+ case ATTRIBUTE_DELETED:
+ /* Move the deleted attribute onto the present list */
+ entry_deleted_attribute_to_present_attribute(e, a);
+ break;
+ case ATTRIBUTE_NOTFOUND:
+ /* No-op - attribute was initialized & added to entry above */
+ break;
}
/* Check if any of the values to be added are on the deleted list */
valueset_remove_valuearray(&a->a_deleted_values,
@@ -612,10 +619,11 @@ entry_add_present_values_wsi_multi_valued(Slapi_Entry *e, const char *type, stru
}
valuearray_update_csn(valuestoadd,CSN_TYPE_VALUE_UPDATED,csn);
retVal= attr_add_valuearray(a, valuestoadd, slapi_entry_get_dn_const(e));
- valuearray_free(&valuestoadd);
}
a->a_flags = a_flags_orig;
}
+ valuearray_free(&valuestoadd);
+
return(retVal);
}
diff --git a/ldap/servers/slapd/schema.c b/ldap/servers/slapd/schema.c
index fa7e5aa..4962613 100644
--- a/ldap/servers/slapd/schema.c
+++ b/ldap/servers/slapd/schema.c
@@ -3238,6 +3238,7 @@ read_oc_ldif ( const char *input, struct objclass **oc, char *errorbuf,
pnew_oc->oc_kind = kind;
*oc = pnew_oc;
+
return read_oc_ldif_return( LDAP_SUCCESS, pOcOid, psbOcName, pOcSup, pOcDesc );
}
@@ -4750,7 +4751,9 @@ load_schema_dse(Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Entry *ignored,
if ( LDAP_SUCCESS != (*returncode = parse_oc_str(s, &oc, returntext,
SLAPI_DSE_RETURNTEXT_SIZE, flags,
primary_file /* force user defined? */,
- schema_ds4x_compat))) {
+ schema_ds4x_compat)))
+ {
+ oc_free( &oc );
break;
}
if (flags & DSE_SCHEMA_NO_LOAD)
diff --git a/ldap/servers/slapd/snmp_collator.c b/ldap/servers/slapd/snmp_collator.c
index aeac7ae..b3d072a 100644
--- a/ldap/servers/slapd/snmp_collator.c
+++ b/ldap/servers/slapd/snmp_collator.c
@@ -738,8 +738,10 @@ snmp_update_cache_stats()
/* set the cache hits/cache entries info */
be = slapi_get_first_backend(&cookie);
- if (!be)
+ if (!be){
+ slapi_ch_free ((void **) &cookie);
return;
+ }
be_next = slapi_get_next_backend(cookie);
diff --git a/ldap/servers/slapd/tools/ldclt/data.c b/ldap/servers/slapd/tools/ldclt/data.c
index e0eac55..f6dd4ef 100644
--- a/ldap/servers/slapd/tools/ldclt/data.c
+++ b/ldap/servers/slapd/tools/ldclt/data.c
@@ -335,6 +335,8 @@ exit:
#ifdef _WIN32
if (findPath) free (findPath);
#endif
+ close(fd);
+
return rc;
}
diff --git a/ldap/servers/slapd/tools/mmldif.c b/ldap/servers/slapd/tools/mmldif.c
index 6d62338..fb97129 100644
--- a/ldap/servers/slapd/tools/mmldif.c
+++ b/ldap/servers/slapd/tools/mmldif.c
@@ -735,6 +735,7 @@ readrec(edfFILE * edf1, attrib1_t ** attrib)
attrib1_t * newlist = NULL;
attrib1_t * a;
int ignore_rec = FALSE;
+ int free_it = 0;
*attrib = NULL;
if (edf1->end) {
@@ -759,6 +760,9 @@ readrec(edfFILE * edf1, attrib1_t ** attrib)
/* that's for the case where the file */
/* has a trailing blank line */
freefreelist(freelist);
+ if(free_it){
+ freefreelist(att);
+ }
return IDDS_MM_EOF;
}
break; /* return */
@@ -790,9 +794,11 @@ readrec(edfFILE * edf1, attrib1_t ** attrib)
continue;
if (!freelist) {
att = (attrib1_t *)malloc(sizeof(attrib1_t));
+ free_it = 1;
} else {
att = freelist;
freelist = freelist->next;
+ free_it = 0;
}
att->namelen = vptr-line;
diff --git a/ldap/servers/snmp/main.c b/ldap/servers/snmp/main.c
index 42dd76b..9a60f70 100644
--- a/ldap/servers/snmp/main.c
+++ b/ldap/servers/snmp/main.c
@@ -311,6 +311,9 @@ load_config(char *conf_path)
/* load agentx-master setting */
p = p + 13;
if ((p = strtok(p, " \t\n")) != NULL) {
+ if (agentx_master){
+ free(agentx_master);
+ }
if ((agentx_master = (char *) malloc(strlen(p) + 1)) != NULL)
strcpy(agentx_master, p);
}
diff --git a/lib/ldaputil/dbconf.c b/lib/ldaputil/dbconf.c
index 746afc9..e6de3b7 100644
--- a/lib/ldaputil/dbconf.c
+++ b/lib/ldaputil/dbconf.c
@@ -263,7 +263,10 @@ static int dbconf_parse_propval (char *buf, char *ptr,
/* Success - we have prop & val */
propval = (DBPropVal_t *)malloc(sizeof(DBPropVal_t));
- if (!propval) return LDAPU_ERR_OUT_OF_MEMORY;
+ if (!propval){
+ if (encval) free(val);
+ return LDAPU_ERR_OUT_OF_MEMORY;
+ }
memset((void *)propval, 0, sizeof(DBPropVal_t));
propval->prop = strdup(prop);
propval->val = val ? strdup(val) : 0;
@@ -273,7 +276,7 @@ static int dbconf_parse_propval (char *buf, char *ptr,
return LDAPU_ERR_OUT_OF_MEMORY;
}
- if (encval) free(val); /* val was allocated by dbconf_decodeval */
+ if(encval) free(val); /* val was allocated by dbconf_decodeval */
insert_dbinfo_propval(db_info, propval);
return LDAPU_SUCCESS;
diff --git a/lib/libaccess/register.cpp b/lib/libaccess/register.cpp
index 3f2acc5..766436e 100644
--- a/lib/libaccess/register.cpp
+++ b/lib/libaccess/register.cpp
@@ -791,6 +791,7 @@ ACL_AttrGetterRegister(NSErr_t *errp, const char *attr, ACLAttrGetterFn_t fn,
if (*hep == 0) { /* New entry */
PR_INIT_CLIST(&getter->list);
if (NULL == PR_HashTableAdd(ACLAttrGetterHash, attr, (void *)getter)) {
+ FREE(getter);
ACL_CritExit();
return -1;
}
diff --git a/lib/libadmin/error.c b/lib/libadmin/error.c
index c0a1f80..4ba9803 100644
--- a/lib/libadmin/error.c
+++ b/lib/libadmin/error.c
@@ -126,10 +126,13 @@ NSAPI_PUBLIC void output_alert(int type, char *info, char *details, int wait)
fprintf(stdout, "%s:%s\\n%s", error_headers[type], info, wrapped);
if(type==FILE_ERROR || type==SYSTEM_ERROR) {
err = get_error();
- if(err != 0)
+ if(err != 0){
+ char *err_str = verbose_error();
fprintf(stdout,
"\\n\\nThe system returned error number %d, "
- "which is %s.", err, verbose_error());
+ "which is %s.", err, err_str);
+ FREE(err_str);
+ }
}
fprintf(stdout, "\");");
10 years, 10 months
Branch '389-ds-base-1.2.11' - ldap/libraries ldap/servers lib/libaccess
by Mark Reynolds
ldap/libraries/libavl/avl.c | 7 +++--
ldap/servers/plugins/chainingdb/cb_conn_stateless.c | 2 -
ldap/servers/plugins/linkedattrs/linked_attrs.c | 17 ++++++++++--
ldap/servers/plugins/memberof/memberof.c | 18 ++++++++++---
ldap/servers/plugins/memberof/memberof_config.c | 2 -
ldap/servers/plugins/replication/cl5_api.c | 17 ++++++++++++
ldap/servers/plugins/replication/cl5_clcache.c | 11 ++++++--
ldap/servers/plugins/replication/repl5_replica_config.c | 5 +++
ldap/servers/plugins/syntaxes/string.c | 14 ++++++----
ldap/servers/slapd/back-ldbm/dbverify.c | 6 +++-
ldap/servers/slapd/back-ldbm/ldif2ldbm.c | 16 +++++++++---
ldap/servers/slapd/dn.c | 1
ldap/servers/slapd/plugin.c | 21 +++++++++++-----
ldap/servers/slapd/valueset.c | 17 +++++++-----
lib/libaccess/oneeval.cpp | 12 ++++-----
15 files changed, 121 insertions(+), 45 deletions(-)
New commits:
commit 36f25726b9723f743bc240cb44b88f74ad478ef2
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Wed Jun 5 12:15:05 2013 -0400
Coverity Fixes (Part 3)
11692 - Explicit null dereferenced (libavl/avl.c)
11695 - Explicit null dereferenced (cb_conn_stateless.c)
11696 - Explicit null dereferenced (memberof_config.c)
11697 - Explicit null dereferenced (memberof.c)
11698 - Explicit null dereferenced (memberof.c)
11699 - Explicit null dereferenced (memberof.c)
11700 - Explicit null dereferenced (memberof.c)
11701 - Explicit null dereferenced (cl5_api.c)
11702 - Explicit null dereferenced (cl5_api.c)
11703 - Dereference after null check (cl5_clcache.c)
11704 - Dereference after null check (repl5_replica_config.c)
11705 - Explicit null dereferenced (syntaxes/string.c)
11706 - Dereference after null check (plugin.c)
11707 - Dereference after null check (plugin.c)
11711 - Dereference after null check (ldif2ldbm.c)
11726 - Dereference after null check (valueset.c)
11729 - Explicit null dereferenced (libaccess/oneeval.cpp)
11744 - Explicit null dereferenced (dbverify.c)
11745 - Out-of-bounds read (linked_attrs.c)
11745 - Out-of-bounds read (memberof.c)
https://bugzilla.redhat.com/show_bug.cgi?id=970221
Reviewed by: richm(Thanks!)
diff --git a/ldap/libraries/libavl/avl.c b/ldap/libraries/libavl/avl.c
index 7577891..18c43e0 100644
--- a/ldap/libraries/libavl/avl.c
+++ b/ldap/libraries/libavl/avl.c
@@ -780,8 +780,11 @@ avl_getfirst( Avlnode *root )
return( 0 );
(void) avl_apply( root, avl_buildlist, (caddr_t) 0, -1, AVL_INORDER );
-
- return( avl_list[ avl_nextlist++ ] );
+ if(avl_list && avl_list[avl_nextlist++]){
+ return avl_list[avl_nextlist];
+ } else {
+ return( NULL );
+ }
}
caddr_t
diff --git a/ldap/servers/plugins/chainingdb/cb_conn_stateless.c b/ldap/servers/plugins/chainingdb/cb_conn_stateless.c
index a9abc31..a85b392 100644
--- a/ldap/servers/plugins/chainingdb/cb_conn_stateless.c
+++ b/ldap/servers/plugins/chainingdb/cb_conn_stateless.c
@@ -856,7 +856,7 @@ void cb_stale_all_connections( cb_backend_instance * cb)
else {
if (conn==pools[i]->conn.conn_list) {
pools[i]->conn.conn_list=next_conn;
- } else {
+ } else if(prev_conn){
prev_conn->next=next_conn;
}
cb_close_and_dispose_connection(conn);
diff --git a/ldap/servers/plugins/linkedattrs/linked_attrs.c b/ldap/servers/plugins/linkedattrs/linked_attrs.c
index ff3dc3a..4bea10f 100644
--- a/ldap/servers/plugins/linkedattrs/linked_attrs.c
+++ b/ldap/servers/plugins/linkedattrs/linked_attrs.c
@@ -1231,10 +1231,21 @@ linked_attrs_load_array(Slapi_Value **array, Slapi_Attr *attr)
int
linked_attrs_compare(const void *a, const void *b)
{
+ Slapi_Value *val1;
+ Slapi_Value *val2;
+ Slapi_Attr *linkattr;
int rc = 0;
- Slapi_Value *val1 = *((Slapi_Value **)a);
- Slapi_Value *val2 = *((Slapi_Value **)b);
- Slapi_Attr *linkattr = slapi_attr_new();
+
+ if(a == NULL && b != NULL){
+ return 1;
+ } else if(a != NULL && b == NULL){
+ return -1;
+ } else if(a == NULL && b == NULL){
+ return 0;
+ }
+ val1 = *((Slapi_Value **)a);
+ val2 = *((Slapi_Value **)b);
+ linkattr = slapi_attr_new();
slapi_attr_init(linkattr, "distinguishedName");
diff --git a/ldap/servers/plugins/memberof/memberof.c b/ldap/servers/plugins/memberof/memberof.c
index a3f875d..d11983b 100644
--- a/ldap/servers/plugins/memberof/memberof.c
+++ b/ldap/servers/plugins/memberof/memberof.c
@@ -460,7 +460,7 @@ memberof_del_dn_from_groups(Slapi_PBlock *pb, MemberOfConfig *config, Slapi_DN *
/* Loop through each grouping attribute to find groups that have
* dn as a member. For any matches, delete the dn value from the
* same grouping attribute. */
- for (i = 0; config->groupattrs[i]; i++)
+ for (i = 0; config->groupattrs && config->groupattrs[i]; i++)
{
memberof_del_dn_data data = {(char *)slapi_sdn_get_dn(sdn),
config->groupattrs[i]};
@@ -712,7 +712,7 @@ memberof_replace_dn_from_groups(Slapi_PBlock *pb, MemberOfConfig *config,
/* Loop through each grouping attribute to find groups that have
* pre_dn as a member. For any matches, replace pre_dn with post_dn
* using the same grouping attribute. */
- for (i = 0; config->groupattrs[i]; i++)
+ for (i = 0; config->groupattrs && config->groupattrs[i]; i++)
{
replace_dn_data data = {(char *)slapi_sdn_get_ndn(pre_sdn),
(char *)slapi_sdn_get_ndn(post_sdn),
@@ -2203,8 +2203,18 @@ void memberof_load_array(Slapi_Value **array, Slapi_Attr *attr)
*/
int memberof_compare(MemberOfConfig *config, const void *a, const void *b)
{
- Slapi_Value *val1 = *((Slapi_Value **)a);
- Slapi_Value *val2 = *((Slapi_Value **)b);
+ Slapi_Value *val1;
+ Slapi_Value *val2;
+
+ if(a == NULL && b != NULL){
+ return 1;
+ } else if(a != NULL && b == NULL){
+ return -1;
+ } else if(a == NULL && b == NULL){
+ return 0;
+ }
+ val1 = *((Slapi_Value **)a);
+ val2 = *((Slapi_Value **)b);
/* We only need to provide a Slapi_Attr here for it's syntax. We
* already validated all grouping attributes to use the Distinguished
diff --git a/ldap/servers/plugins/memberof/memberof_config.c b/ldap/servers/plugins/memberof/memberof_config.c
index b4d557a..3fd63a9 100644
--- a/ldap/servers/plugins/memberof/memberof_config.c
+++ b/ldap/servers/plugins/memberof/memberof_config.c
@@ -486,7 +486,7 @@ memberof_free_config(MemberOfConfig *config)
slapi_ch_array_free(config->groupattrs);
slapi_filter_free(config->group_filter, 1);
- for (i = 0; config->group_slapiattrs[i]; i++)
+ for (i = 0; config->group_slapiattrs && config->group_slapiattrs[i]; i++)
{
slapi_attr_free(&config->group_slapiattrs[i]);
}
diff --git a/ldap/servers/plugins/replication/cl5_api.c b/ldap/servers/plugins/replication/cl5_api.c
index 175eb80..f9934f3 100644
--- a/ldap/servers/plugins/replication/cl5_api.c
+++ b/ldap/servers/plugins/replication/cl5_api.c
@@ -3507,6 +3507,13 @@ static void _cl5TrimFile (Object *obj, long *numToTrim, ReplicaId cleaned_rid)
* This change can be trimmed if it exceeds purge
* parameters and has been seen by all consumers.
*/
+ if(op.csn == NULL){
+ slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl, "_cl5TrimFile: "
+ "Operation missing csn, moving on to next entry.\n");
+ cl5_operation_parameters_done (&op);
+ finished =_cl5GetNextEntry (&entry, it);
+ continue;
+ }
csn_rid = csn_get_replicaid (op.csn);
if ( (*numToTrim > 0 || _cl5CanTrim (entry.time, numToTrim)) &&
ruv_covers_csn_strict (ruv, op.csn) )
@@ -3836,7 +3843,15 @@ static int _cl5ConstructRUV (const char *replGen, Object *obj, PRBool purge)
rc = _cl5GetFirstEntry (obj, &entry, &iterator, NULL);
while (rc == CL5_SUCCESS)
{
- rid = csn_get_replicaid (op.csn);
+ if(op.csn){
+ rid = csn_get_replicaid (op.csn);
+ } else {
+ slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl, "_cl5ConstructRUV: "
+ "Operation missing csn, moving on to next entry.\n");
+ cl5_operation_parameters_done (&op);
+ rc = _cl5GetNextEntry (&entry, iterator);
+ continue;
+ }
if(is_cleaned_rid(rid)){
/* skip this entry as the rid is invalid */
slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl, "_cl5ConstructRUV: "
diff --git a/ldap/servers/plugins/replication/cl5_clcache.c b/ldap/servers/plugins/replication/cl5_clcache.c
index 202cb64..738e4cb 100644
--- a/ldap/servers/plugins/replication/cl5_clcache.c
+++ b/ldap/servers/plugins/replication/cl5_clcache.c
@@ -732,9 +732,14 @@ clcache_skip_change ( CLC_Buffer *buf )
*/
if ( csn_time_difference(buf->buf_current_csn, cscb->local_maxcsn) == 0 &&
(csn_get_seqnum(buf->buf_current_csn) ==
- csn_get_seqnum(cscb->local_maxcsn) + 1) ) {
- csn_init_by_csn ( cscb->local_maxcsn, buf->buf_current_csn );
- csn_init_by_csn ( cscb->consumer_maxcsn, buf->buf_current_csn );
+ csn_get_seqnum(cscb->local_maxcsn) + 1) )
+ {
+ if(cscb->local_maxcsn){
+ csn_init_by_csn ( cscb->local_maxcsn, buf->buf_current_csn );
+ }
+ if(cscb->consumer_maxcsn){
+ csn_init_by_csn ( cscb->consumer_maxcsn, buf->buf_current_csn );
+ }
skip = 0;
break;
}
diff --git a/ldap/servers/plugins/replication/repl5_replica_config.c b/ldap/servers/plugins/replication/repl5_replica_config.c
index bbbe87e..7bc6995 100644
--- a/ldap/servers/plugins/replication/repl5_replica_config.c
+++ b/ldap/servers/plugins/replication/repl5_replica_config.c
@@ -2364,6 +2364,11 @@ delete_cleaned_rid_config(cleanruv_data *clean_data)
int found = 0, i;
int rc, ret, rid;
+ if(clean_data == NULL){
+ slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name, "delete_cleaned_rid_config: cleanruv data is NULL, "
+ "failed to clean the config.\n");
+ return;
+ }
/*
* If there is no maxcsn, set the proper csnstr
*/
diff --git a/ldap/servers/plugins/syntaxes/string.c b/ldap/servers/plugins/syntaxes/string.c
index 54cd7c8..6c0da94 100644
--- a/ldap/servers/plugins/syntaxes/string.c
+++ b/ldap/servers/plugins/syntaxes/string.c
@@ -84,7 +84,11 @@ string_filter_ava( struct berval *bvfilter, Slapi_Value **bvals, int syntax,
bvfilter_norm.bv_val = alt;
alt = NULL;
}
- bvfilter_norm.bv_len = strlen(bvfilter_norm.bv_val);
+ if(bvfilter_norm.bv_val){
+ bvfilter_norm.bv_len = strlen(bvfilter_norm.bv_val);
+ } else {
+ bvfilter_norm.bv_len = 0;
+ }
}
for ( i = 0; (bvals != NULL) && (bvals[i] != NULL); i++ ) {
@@ -103,7 +107,7 @@ string_filter_ava( struct berval *bvfilter, Slapi_Value **bvals, int syntax,
if(retVal) {
*retVal = bvals[i];
}
- slapi_ch_free ((void**)&bvfilter_norm.bv_val);
+ slapi_ch_free_string(&bvfilter_norm.bv_val);
return( 0 );
}
break;
@@ -112,7 +116,7 @@ string_filter_ava( struct berval *bvfilter, Slapi_Value **bvals, int syntax,
if(retVal) {
*retVal = bvals[i];
}
- slapi_ch_free ((void**)&bvfilter_norm.bv_val);
+ slapi_ch_free_string(&bvfilter_norm.bv_val);
return( 0 );
}
break;
@@ -121,14 +125,14 @@ string_filter_ava( struct berval *bvfilter, Slapi_Value **bvals, int syntax,
if(retVal) {
*retVal = bvals[i];
}
- slapi_ch_free ((void**)&bvfilter_norm.bv_val);
+ slapi_ch_free_string(&bvfilter_norm.bv_val);
return( 0 );
}
break;
}
}
- slapi_ch_free ((void**)&bvfilter_norm.bv_val);
+ slapi_ch_free_string(&bvfilter_norm.bv_val);
return( -1 );
}
diff --git a/ldap/servers/slapd/back-ldbm/dbverify.c b/ldap/servers/slapd/back-ldbm/dbverify.c
index 43fc9d5..ffd5900 100644
--- a/ldap/servers/slapd/back-ldbm/dbverify.c
+++ b/ldap/servers/slapd/back-ldbm/dbverify.c
@@ -119,9 +119,11 @@ dbverify_ext( ldbm_instance *inst, int verbose )
char *p = NULL;
p = strstr(filep, LDBM_FILENAME_SUFFIX); /* since already checked,
it must have it */
- *p = '\0';
+ if(p)
+ *p = '\0';
ainfo_get( inst->inst_be, filep+1, &ai );
- *p = '.';
+ if(p)
+ *p = '.';
if (ai->ai_key_cmp_fn) {
dbp->app_private = (void *)ai->ai_key_cmp_fn;
dbp->set_bt_compare(dbp, dblayer_bt_compare);
diff --git a/ldap/servers/slapd/back-ldbm/ldif2ldbm.c b/ldap/servers/slapd/back-ldbm/ldif2ldbm.c
index c802ff2..47e0269 100644
--- a/ldap/servers/slapd/back-ldbm/ldif2ldbm.c
+++ b/ldap/servers/slapd/back-ldbm/ldif2ldbm.c
@@ -2246,15 +2246,23 @@ ldbm_back_ldbm2index(Slapi_PBlock *pb)
* Update the Virtual List View indexes
*/
for ( vlvidx = 0; vlvidx < numvlv; vlvidx++ ) {
+ char *ai = "Unknown index";
+
if ( g_get_shutdown() || c_get_shutdown() ) {
goto err_out;
}
+ if(indexAttrs){
+ if(indexAttrs[vlvidx]){
+ ai = indexAttrs[vlvidx];
+ }
+ }
if (!run_from_cmdline) {
rc = dblayer_txn_begin(li, NULL, &txn);
if (0 != rc) {
+
LDAPDebug(LDAP_DEBUG_ANY,
"%s: ERROR: failed to begin txn for update index '%s'\n",
- inst->inst_name, indexAttrs[vlvidx], 0);
+ inst->inst_name, ai, 0);
LDAPDebug(LDAP_DEBUG_ANY,
"%s: Error %d: %s\n", inst->inst_name, rc,
dblayer_strerror(rc));
@@ -2262,7 +2270,7 @@ ldbm_back_ldbm2index(Slapi_PBlock *pb)
slapi_task_log_notice(task,
"%s: ERROR: failed to begin txn for update index '%s' "
"(err %d: %s)", inst->inst_name,
- indexAttrs[vlvidx], rc, dblayer_strerror(rc));
+ ai, rc, dblayer_strerror(rc));
}
return_value = -2;
goto err_out;
@@ -2281,7 +2289,7 @@ ldbm_back_ldbm2index(Slapi_PBlock *pb)
if (0 != rc) {
LDAPDebug(LDAP_DEBUG_ANY,
"%s: ERROR: failed to commit txn for update index '%s'\n",
- inst->inst_name, indexAttrs[vlvidx], 0);
+ inst->inst_name, ai, 0);
LDAPDebug(LDAP_DEBUG_ANY,
"%s: Error %d: %s\n", inst->inst_name, rc,
dblayer_strerror(rc));
@@ -2289,7 +2297,7 @@ ldbm_back_ldbm2index(Slapi_PBlock *pb)
slapi_task_log_notice(task,
"%s: ERROR: failed to commit txn for update index '%s' "
"(err %d: %s)", inst->inst_name,
- indexAttrs[vlvidx], rc, dblayer_strerror(rc));
+ ai, rc, dblayer_strerror(rc));
}
return_value = -2;
goto err_out;
diff --git a/ldap/servers/slapd/dn.c b/ldap/servers/slapd/dn.c
index 35c0700..b40b6a0 100644
--- a/ldap/servers/slapd/dn.c
+++ b/ldap/servers/slapd/dn.c
@@ -2567,3 +2567,4 @@ slapi_sdn_get_size(const Slapi_DN *sdn)
sz += strlen(sdn->dn) + 1;
return sz;
}
+
diff --git a/ldap/servers/slapd/plugin.c b/ldap/servers/slapd/plugin.c
index 436cc02..0a4f4e0 100644
--- a/ldap/servers/slapd/plugin.c
+++ b/ldap/servers/slapd/plugin.c
@@ -1493,15 +1493,24 @@ int
slapi_berval_cmp (const struct berval* L, const struct berval* R) /* JCM - This does not belong here. But, where should it go? */
{
int result = 0;
+
+ if(L == NULL && R != NULL){
+ return 1;
+ } else if(L != NULL && R == NULL){
+ return -1;
+ } else if(L == NULL && R == NULL){
+ return 0;
+ }
if (L->bv_len < R->bv_len) {
- result = memcmp (L->bv_val, R->bv_val, L->bv_len);
- if (result == 0)
- result = -1;
+ result = memcmp (L->bv_val, R->bv_val, L->bv_len);
+ if (result == 0)
+ result = -1;
} else {
- result = memcmp (L->bv_val, R->bv_val, R->bv_len);
- if (result == 0 && (L->bv_len > R->bv_len))
- result = 1;
+ result = memcmp (L->bv_val, R->bv_val, R->bv_len);
+ if (result == 0 && (L->bv_len > R->bv_len))
+ result = 1;
}
+
return result;
}
diff --git a/ldap/servers/slapd/valueset.c b/ldap/servers/slapd/valueset.c
index a91256c..f04acc3 100644
--- a/ldap/servers/slapd/valueset.c
+++ b/ldap/servers/slapd/valueset.c
@@ -190,20 +190,23 @@ valuearray_add_valuearray(Slapi_Value ***vals, Slapi_Value **addvals, PRUint32 f
{
int valslen;
int addvalslen;
- int maxvals;
+ int maxvals;
- addvalslen= valuearray_count(addvals);
+ if(vals == NULL){
+ return;
+ }
+ addvalslen= valuearray_count(addvals);
if(*vals == NULL)
{
- valslen= 0;
- maxvals= 0;
+ valslen= 0;
+ maxvals= 0;
}
else
{
- valslen= valuearray_count(*vals);
- maxvals= valslen+1;
+ valslen= valuearray_count(*vals);
+ maxvals= valslen+1;
}
- valuearray_add_valuearray_fast(vals,addvals,valslen,addvalslen,&maxvals,1/*Exact*/,flags & SLAPI_VALUE_FLAG_PASSIN);
+ valuearray_add_valuearray_fast(vals,addvals,valslen,addvalslen,&maxvals,1/*Exact*/,flags & SLAPI_VALUE_FLAG_PASSIN);
}
int
diff --git a/lib/libaccess/oneeval.cpp b/lib/libaccess/oneeval.cpp
index eff4e10..a6d3bbd 100644
--- a/lib/libaccess/oneeval.cpp
+++ b/lib/libaccess/oneeval.cpp
@@ -381,20 +381,19 @@ ACLEvalBuildContext(
/* Loop through all the ACLs in the list */
while (wrapper)
{
- acl = wrapper->acl;
+ acl = wrapper->acl;
ace = acl->expr_list_head;
while (ace) /* Loop through all the ACEs in this ACL */
{
-
/* allocate a new ace list entry and link it in to the ordered
* list.
*/
new_ace = (ACLAceEntry_t *)PERM_CALLOC(sizeof(ACLAceEntry_t));
if (new_ace == (ACLAceEntry_t *)NULL) {
- nserrGenerate(errp, ACLERRNOMEM, ACLERR4020, ACL_Program, 1,
- XP_GetAdminStr(DBT_EvalBuildContextUnableToAllocAceEntry));
- goto error;
+ nserrGenerate(errp, ACLERRNOMEM, ACLERR4020, ACL_Program, 1,
+ XP_GetAdminStr(DBT_EvalBuildContextUnableToAllocAceEntry));
+ goto error;
}
new_ace->acep = ace;
ace_cnt++;
@@ -402,7 +401,8 @@ ACLEvalBuildContext(
if (cache->acelist == NULL)
cache->acelist = acelast = new_ace;
else {
- acelast->next = new_ace;
+ if(acelast)
+ acelast->next = new_ace;
acelast = new_ace;
new_ace->acep = ace;
}
10 years, 10 months
Branch '389-ds-base-1.3.0' - ldap/libraries ldap/servers lib/libaccess
by Mark Reynolds
ldap/libraries/libavl/avl.c | 7 +++--
ldap/servers/plugins/chainingdb/cb_conn_stateless.c | 2 -
ldap/servers/plugins/linkedattrs/linked_attrs.c | 17 ++++++++++--
ldap/servers/plugins/memberof/memberof.c | 18 ++++++++++---
ldap/servers/plugins/memberof/memberof_config.c | 2 -
ldap/servers/plugins/replication/cl5_api.c | 17 ++++++++++++
ldap/servers/plugins/replication/cl5_clcache.c | 11 ++++++--
ldap/servers/plugins/replication/repl5_replica_config.c | 5 +++
ldap/servers/plugins/syntaxes/string.c | 14 ++++++----
ldap/servers/slapd/back-ldbm/dbverify.c | 6 +++-
ldap/servers/slapd/back-ldbm/ldif2ldbm.c | 16 +++++++++---
ldap/servers/slapd/dn.c | 3 +-
ldap/servers/slapd/plugin.c | 21 +++++++++++-----
ldap/servers/slapd/valueset.c | 17 +++++++-----
lib/libaccess/oneeval.cpp | 12 ++++-----
15 files changed, 122 insertions(+), 46 deletions(-)
New commits:
commit 2eadec750eeff1845a8362e0c2f575fdfe931c78
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Wed Jun 5 12:15:05 2013 -0400
Coverity Fixes (Part 3)
11692 - Explicit null dereferenced (libavl/avl.c)
11695 - Explicit null dereferenced (cb_conn_stateless.c)
11696 - Explicit null dereferenced (memberof_config.c)
11697 - Explicit null dereferenced (memberof.c)
11698 - Explicit null dereferenced (memberof.c)
11699 - Explicit null dereferenced (memberof.c)
11700 - Explicit null dereferenced (memberof.c)
11701 - Explicit null dereferenced (cl5_api.c)
11702 - Explicit null dereferenced (cl5_api.c)
11703 - Dereference after null check (cl5_clcache.c)
11704 - Dereference after null check (repl5_replica_config.c)
11705 - Explicit null dereferenced (syntaxes/string.c)
11706 - Dereference after null check (plugin.c)
11707 - Dereference after null check (plugin.c)
11711 - Dereference after null check (ldif2ldbm.c)
11713 - Dereference after null check (dn.c)
11726 - Dereference after null check (valueset.c)
11729 - Explicit null dereferenced (libaccess/oneeval.cpp)
11744 - Explicit null dereferenced (dbverify.c)
11745 - Out-of-bounds read (linked_attrs.c)
11745 - Out-of-bounds read (memberof.c)
https://bugzilla.redhat.com/show_bug.cgi?id=970221
Reviewed by: richm(Thanks!)
(cherry picked from commit 916eb0da143eeb1745e9f67532255477eefbd3d7)
diff --git a/ldap/libraries/libavl/avl.c b/ldap/libraries/libavl/avl.c
index 7577891..18c43e0 100644
--- a/ldap/libraries/libavl/avl.c
+++ b/ldap/libraries/libavl/avl.c
@@ -780,8 +780,11 @@ avl_getfirst( Avlnode *root )
return( 0 );
(void) avl_apply( root, avl_buildlist, (caddr_t) 0, -1, AVL_INORDER );
-
- return( avl_list[ avl_nextlist++ ] );
+ if(avl_list && avl_list[avl_nextlist++]){
+ return avl_list[avl_nextlist];
+ } else {
+ return( NULL );
+ }
}
caddr_t
diff --git a/ldap/servers/plugins/chainingdb/cb_conn_stateless.c b/ldap/servers/plugins/chainingdb/cb_conn_stateless.c
index a9abc31..a85b392 100644
--- a/ldap/servers/plugins/chainingdb/cb_conn_stateless.c
+++ b/ldap/servers/plugins/chainingdb/cb_conn_stateless.c
@@ -856,7 +856,7 @@ void cb_stale_all_connections( cb_backend_instance * cb)
else {
if (conn==pools[i]->conn.conn_list) {
pools[i]->conn.conn_list=next_conn;
- } else {
+ } else if(prev_conn){
prev_conn->next=next_conn;
}
cb_close_and_dispose_connection(conn);
diff --git a/ldap/servers/plugins/linkedattrs/linked_attrs.c b/ldap/servers/plugins/linkedattrs/linked_attrs.c
index ff3dc3a..4bea10f 100644
--- a/ldap/servers/plugins/linkedattrs/linked_attrs.c
+++ b/ldap/servers/plugins/linkedattrs/linked_attrs.c
@@ -1231,10 +1231,21 @@ linked_attrs_load_array(Slapi_Value **array, Slapi_Attr *attr)
int
linked_attrs_compare(const void *a, const void *b)
{
+ Slapi_Value *val1;
+ Slapi_Value *val2;
+ Slapi_Attr *linkattr;
int rc = 0;
- Slapi_Value *val1 = *((Slapi_Value **)a);
- Slapi_Value *val2 = *((Slapi_Value **)b);
- Slapi_Attr *linkattr = slapi_attr_new();
+
+ if(a == NULL && b != NULL){
+ return 1;
+ } else if(a != NULL && b == NULL){
+ return -1;
+ } else if(a == NULL && b == NULL){
+ return 0;
+ }
+ val1 = *((Slapi_Value **)a);
+ val2 = *((Slapi_Value **)b);
+ linkattr = slapi_attr_new();
slapi_attr_init(linkattr, "distinguishedName");
diff --git a/ldap/servers/plugins/memberof/memberof.c b/ldap/servers/plugins/memberof/memberof.c
index 8fcc88c..4baad88 100644
--- a/ldap/servers/plugins/memberof/memberof.c
+++ b/ldap/servers/plugins/memberof/memberof.c
@@ -460,7 +460,7 @@ memberof_del_dn_from_groups(Slapi_PBlock *pb, MemberOfConfig *config, Slapi_DN *
/* Loop through each grouping attribute to find groups that have
* dn as a member. For any matches, delete the dn value from the
* same grouping attribute. */
- for (i = 0; config->groupattrs[i]; i++)
+ for (i = 0; config->groupattrs && config->groupattrs[i]; i++)
{
memberof_del_dn_data data = {(char *)slapi_sdn_get_dn(sdn),
config->groupattrs[i]};
@@ -724,7 +724,7 @@ memberof_replace_dn_from_groups(Slapi_PBlock *pb, MemberOfConfig *config,
/* Loop through each grouping attribute to find groups that have
* pre_dn as a member. For any matches, replace pre_dn with post_dn
* using the same grouping attribute. */
- for (i = 0; config->groupattrs[i]; i++)
+ for (i = 0; config->groupattrs && config->groupattrs[i]; i++)
{
replace_dn_data data = {(char *)slapi_sdn_get_ndn(pre_sdn),
(char *)slapi_sdn_get_ndn(post_sdn),
@@ -2218,8 +2218,18 @@ void memberof_load_array(Slapi_Value **array, Slapi_Attr *attr)
*/
int memberof_compare(MemberOfConfig *config, const void *a, const void *b)
{
- Slapi_Value *val1 = *((Slapi_Value **)a);
- Slapi_Value *val2 = *((Slapi_Value **)b);
+ Slapi_Value *val1;
+ Slapi_Value *val2;
+
+ if(a == NULL && b != NULL){
+ return 1;
+ } else if(a != NULL && b == NULL){
+ return -1;
+ } else if(a == NULL && b == NULL){
+ return 0;
+ }
+ val1 = *((Slapi_Value **)a);
+ val2 = *((Slapi_Value **)b);
/* We only need to provide a Slapi_Attr here for it's syntax. We
* already validated all grouping attributes to use the Distinguished
diff --git a/ldap/servers/plugins/memberof/memberof_config.c b/ldap/servers/plugins/memberof/memberof_config.c
index b4d557a..3fd63a9 100644
--- a/ldap/servers/plugins/memberof/memberof_config.c
+++ b/ldap/servers/plugins/memberof/memberof_config.c
@@ -486,7 +486,7 @@ memberof_free_config(MemberOfConfig *config)
slapi_ch_array_free(config->groupattrs);
slapi_filter_free(config->group_filter, 1);
- for (i = 0; config->group_slapiattrs[i]; i++)
+ for (i = 0; config->group_slapiattrs && config->group_slapiattrs[i]; i++)
{
slapi_attr_free(&config->group_slapiattrs[i]);
}
diff --git a/ldap/servers/plugins/replication/cl5_api.c b/ldap/servers/plugins/replication/cl5_api.c
index 175eb80..f9934f3 100644
--- a/ldap/servers/plugins/replication/cl5_api.c
+++ b/ldap/servers/plugins/replication/cl5_api.c
@@ -3507,6 +3507,13 @@ static void _cl5TrimFile (Object *obj, long *numToTrim, ReplicaId cleaned_rid)
* This change can be trimmed if it exceeds purge
* parameters and has been seen by all consumers.
*/
+ if(op.csn == NULL){
+ slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl, "_cl5TrimFile: "
+ "Operation missing csn, moving on to next entry.\n");
+ cl5_operation_parameters_done (&op);
+ finished =_cl5GetNextEntry (&entry, it);
+ continue;
+ }
csn_rid = csn_get_replicaid (op.csn);
if ( (*numToTrim > 0 || _cl5CanTrim (entry.time, numToTrim)) &&
ruv_covers_csn_strict (ruv, op.csn) )
@@ -3836,7 +3843,15 @@ static int _cl5ConstructRUV (const char *replGen, Object *obj, PRBool purge)
rc = _cl5GetFirstEntry (obj, &entry, &iterator, NULL);
while (rc == CL5_SUCCESS)
{
- rid = csn_get_replicaid (op.csn);
+ if(op.csn){
+ rid = csn_get_replicaid (op.csn);
+ } else {
+ slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl, "_cl5ConstructRUV: "
+ "Operation missing csn, moving on to next entry.\n");
+ cl5_operation_parameters_done (&op);
+ rc = _cl5GetNextEntry (&entry, iterator);
+ continue;
+ }
if(is_cleaned_rid(rid)){
/* skip this entry as the rid is invalid */
slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl, "_cl5ConstructRUV: "
diff --git a/ldap/servers/plugins/replication/cl5_clcache.c b/ldap/servers/plugins/replication/cl5_clcache.c
index 202cb64..738e4cb 100644
--- a/ldap/servers/plugins/replication/cl5_clcache.c
+++ b/ldap/servers/plugins/replication/cl5_clcache.c
@@ -732,9 +732,14 @@ clcache_skip_change ( CLC_Buffer *buf )
*/
if ( csn_time_difference(buf->buf_current_csn, cscb->local_maxcsn) == 0 &&
(csn_get_seqnum(buf->buf_current_csn) ==
- csn_get_seqnum(cscb->local_maxcsn) + 1) ) {
- csn_init_by_csn ( cscb->local_maxcsn, buf->buf_current_csn );
- csn_init_by_csn ( cscb->consumer_maxcsn, buf->buf_current_csn );
+ csn_get_seqnum(cscb->local_maxcsn) + 1) )
+ {
+ if(cscb->local_maxcsn){
+ csn_init_by_csn ( cscb->local_maxcsn, buf->buf_current_csn );
+ }
+ if(cscb->consumer_maxcsn){
+ csn_init_by_csn ( cscb->consumer_maxcsn, buf->buf_current_csn );
+ }
skip = 0;
break;
}
diff --git a/ldap/servers/plugins/replication/repl5_replica_config.c b/ldap/servers/plugins/replication/repl5_replica_config.c
index b5b4ee9..e7fe487 100644
--- a/ldap/servers/plugins/replication/repl5_replica_config.c
+++ b/ldap/servers/plugins/replication/repl5_replica_config.c
@@ -2364,6 +2364,11 @@ delete_cleaned_rid_config(cleanruv_data *clean_data)
int found = 0, i;
int rc, ret, rid;
+ if(clean_data == NULL){
+ slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name, "delete_cleaned_rid_config: cleanruv data is NULL, "
+ "failed to clean the config.\n");
+ return;
+ }
/*
* If there is no maxcsn, set the proper csnstr
*/
diff --git a/ldap/servers/plugins/syntaxes/string.c b/ldap/servers/plugins/syntaxes/string.c
index 54cd7c8..6c0da94 100644
--- a/ldap/servers/plugins/syntaxes/string.c
+++ b/ldap/servers/plugins/syntaxes/string.c
@@ -84,7 +84,11 @@ string_filter_ava( struct berval *bvfilter, Slapi_Value **bvals, int syntax,
bvfilter_norm.bv_val = alt;
alt = NULL;
}
- bvfilter_norm.bv_len = strlen(bvfilter_norm.bv_val);
+ if(bvfilter_norm.bv_val){
+ bvfilter_norm.bv_len = strlen(bvfilter_norm.bv_val);
+ } else {
+ bvfilter_norm.bv_len = 0;
+ }
}
for ( i = 0; (bvals != NULL) && (bvals[i] != NULL); i++ ) {
@@ -103,7 +107,7 @@ string_filter_ava( struct berval *bvfilter, Slapi_Value **bvals, int syntax,
if(retVal) {
*retVal = bvals[i];
}
- slapi_ch_free ((void**)&bvfilter_norm.bv_val);
+ slapi_ch_free_string(&bvfilter_norm.bv_val);
return( 0 );
}
break;
@@ -112,7 +116,7 @@ string_filter_ava( struct berval *bvfilter, Slapi_Value **bvals, int syntax,
if(retVal) {
*retVal = bvals[i];
}
- slapi_ch_free ((void**)&bvfilter_norm.bv_val);
+ slapi_ch_free_string(&bvfilter_norm.bv_val);
return( 0 );
}
break;
@@ -121,14 +125,14 @@ string_filter_ava( struct berval *bvfilter, Slapi_Value **bvals, int syntax,
if(retVal) {
*retVal = bvals[i];
}
- slapi_ch_free ((void**)&bvfilter_norm.bv_val);
+ slapi_ch_free_string(&bvfilter_norm.bv_val);
return( 0 );
}
break;
}
}
- slapi_ch_free ((void**)&bvfilter_norm.bv_val);
+ slapi_ch_free_string(&bvfilter_norm.bv_val);
return( -1 );
}
diff --git a/ldap/servers/slapd/back-ldbm/dbverify.c b/ldap/servers/slapd/back-ldbm/dbverify.c
index 43fc9d5..ffd5900 100644
--- a/ldap/servers/slapd/back-ldbm/dbverify.c
+++ b/ldap/servers/slapd/back-ldbm/dbverify.c
@@ -119,9 +119,11 @@ dbverify_ext( ldbm_instance *inst, int verbose )
char *p = NULL;
p = strstr(filep, LDBM_FILENAME_SUFFIX); /* since already checked,
it must have it */
- *p = '\0';
+ if(p)
+ *p = '\0';
ainfo_get( inst->inst_be, filep+1, &ai );
- *p = '.';
+ if(p)
+ *p = '.';
if (ai->ai_key_cmp_fn) {
dbp->app_private = (void *)ai->ai_key_cmp_fn;
dbp->set_bt_compare(dbp, dblayer_bt_compare);
diff --git a/ldap/servers/slapd/back-ldbm/ldif2ldbm.c b/ldap/servers/slapd/back-ldbm/ldif2ldbm.c
index 957ebf5..2694bac 100644
--- a/ldap/servers/slapd/back-ldbm/ldif2ldbm.c
+++ b/ldap/servers/slapd/back-ldbm/ldif2ldbm.c
@@ -2247,15 +2247,23 @@ ldbm_back_ldbm2index(Slapi_PBlock *pb)
* Update the Virtual List View indexes
*/
for ( vlvidx = 0; vlvidx < numvlv; vlvidx++ ) {
+ char *ai = "Unknown index";
+
if ( g_get_shutdown() || c_get_shutdown() ) {
goto err_out;
}
+ if(indexAttrs){
+ if(indexAttrs[vlvidx]){
+ ai = indexAttrs[vlvidx];
+ }
+ }
if (!run_from_cmdline) {
rc = dblayer_txn_begin(be, NULL, &txn);
if (0 != rc) {
+
LDAPDebug(LDAP_DEBUG_ANY,
"%s: ERROR: failed to begin txn for update index '%s'\n",
- inst->inst_name, indexAttrs[vlvidx], 0);
+ inst->inst_name, ai, 0);
LDAPDebug(LDAP_DEBUG_ANY,
"%s: Error %d: %s\n", inst->inst_name, rc,
dblayer_strerror(rc));
@@ -2263,7 +2271,7 @@ ldbm_back_ldbm2index(Slapi_PBlock *pb)
slapi_task_log_notice(task,
"%s: ERROR: failed to begin txn for update index '%s' "
"(err %d: %s)", inst->inst_name,
- indexAttrs[vlvidx], rc, dblayer_strerror(rc));
+ ai, rc, dblayer_strerror(rc));
}
return_value = -2;
goto err_out;
@@ -2282,7 +2290,7 @@ ldbm_back_ldbm2index(Slapi_PBlock *pb)
if (0 != rc) {
LDAPDebug(LDAP_DEBUG_ANY,
"%s: ERROR: failed to commit txn for update index '%s'\n",
- inst->inst_name, indexAttrs[vlvidx], 0);
+ inst->inst_name, ai, 0);
LDAPDebug(LDAP_DEBUG_ANY,
"%s: Error %d: %s\n", inst->inst_name, rc,
dblayer_strerror(rc));
@@ -2290,7 +2298,7 @@ ldbm_back_ldbm2index(Slapi_PBlock *pb)
slapi_task_log_notice(task,
"%s: ERROR: failed to commit txn for update index '%s' "
"(err %d: %s)", inst->inst_name,
- indexAttrs[vlvidx], rc, dblayer_strerror(rc));
+ ai, rc, dblayer_strerror(rc));
}
return_value = -2;
goto err_out;
diff --git a/ldap/servers/slapd/dn.c b/ldap/servers/slapd/dn.c
index d643d33..bb5973a 100644
--- a/ldap/servers/slapd/dn.c
+++ b/ldap/servers/slapd/dn.c
@@ -2844,7 +2844,8 @@ ndn_cache_add(char *dn, size_t dn_len, char *ndn, size_t ndn_len)
new_node->next = NULL;
} else {
new_node->next = ndn_cache->head;
- ndn_cache->head->prev = new_node;
+ if(ndn_cache->head)
+ ndn_cache->head->prev = new_node;
}
ndn_cache->head = new_node;
PR_Unlock(lru_lock);
diff --git a/ldap/servers/slapd/plugin.c b/ldap/servers/slapd/plugin.c
index f90bd0d..d19faa5 100644
--- a/ldap/servers/slapd/plugin.c
+++ b/ldap/servers/slapd/plugin.c
@@ -1493,15 +1493,24 @@ int
slapi_berval_cmp (const struct berval* L, const struct berval* R) /* JCM - This does not belong here. But, where should it go? */
{
int result = 0;
+
+ if(L == NULL && R != NULL){
+ return 1;
+ } else if(L != NULL && R == NULL){
+ return -1;
+ } else if(L == NULL && R == NULL){
+ return 0;
+ }
if (L->bv_len < R->bv_len) {
- result = memcmp (L->bv_val, R->bv_val, L->bv_len);
- if (result == 0)
- result = -1;
+ result = memcmp (L->bv_val, R->bv_val, L->bv_len);
+ if (result == 0)
+ result = -1;
} else {
- result = memcmp (L->bv_val, R->bv_val, R->bv_len);
- if (result == 0 && (L->bv_len > R->bv_len))
- result = 1;
+ result = memcmp (L->bv_val, R->bv_val, R->bv_len);
+ if (result == 0 && (L->bv_len > R->bv_len))
+ result = 1;
}
+
return result;
}
diff --git a/ldap/servers/slapd/valueset.c b/ldap/servers/slapd/valueset.c
index 6bc3ffa..dffcaeb 100644
--- a/ldap/servers/slapd/valueset.c
+++ b/ldap/servers/slapd/valueset.c
@@ -190,20 +190,23 @@ valuearray_add_valuearray(Slapi_Value ***vals, Slapi_Value **addvals, PRUint32 f
{
int valslen;
int addvalslen;
- int maxvals;
+ int maxvals;
- addvalslen= valuearray_count(addvals);
+ if(vals == NULL){
+ return;
+ }
+ addvalslen= valuearray_count(addvals);
if(*vals == NULL)
{
- valslen= 0;
- maxvals= 0;
+ valslen= 0;
+ maxvals= 0;
}
else
{
- valslen= valuearray_count(*vals);
- maxvals= valslen+1;
+ valslen= valuearray_count(*vals);
+ maxvals= valslen+1;
}
- valuearray_add_valuearray_fast(vals,addvals,valslen,addvalslen,&maxvals,1/*Exact*/,flags & SLAPI_VALUE_FLAG_PASSIN);
+ valuearray_add_valuearray_fast(vals,addvals,valslen,addvalslen,&maxvals,1/*Exact*/,flags & SLAPI_VALUE_FLAG_PASSIN);
}
int
diff --git a/lib/libaccess/oneeval.cpp b/lib/libaccess/oneeval.cpp
index eff4e10..a6d3bbd 100644
--- a/lib/libaccess/oneeval.cpp
+++ b/lib/libaccess/oneeval.cpp
@@ -381,20 +381,19 @@ ACLEvalBuildContext(
/* Loop through all the ACLs in the list */
while (wrapper)
{
- acl = wrapper->acl;
+ acl = wrapper->acl;
ace = acl->expr_list_head;
while (ace) /* Loop through all the ACEs in this ACL */
{
-
/* allocate a new ace list entry and link it in to the ordered
* list.
*/
new_ace = (ACLAceEntry_t *)PERM_CALLOC(sizeof(ACLAceEntry_t));
if (new_ace == (ACLAceEntry_t *)NULL) {
- nserrGenerate(errp, ACLERRNOMEM, ACLERR4020, ACL_Program, 1,
- XP_GetAdminStr(DBT_EvalBuildContextUnableToAllocAceEntry));
- goto error;
+ nserrGenerate(errp, ACLERRNOMEM, ACLERR4020, ACL_Program, 1,
+ XP_GetAdminStr(DBT_EvalBuildContextUnableToAllocAceEntry));
+ goto error;
}
new_ace->acep = ace;
ace_cnt++;
@@ -402,7 +401,8 @@ ACLEvalBuildContext(
if (cache->acelist == NULL)
cache->acelist = acelast = new_ace;
else {
- acelast->next = new_ace;
+ if(acelast)
+ acelast->next = new_ace;
acelast = new_ace;
new_ace->acep = ace;
}
10 years, 10 months
Branch '389-ds-base-1.3.1' - ldap/libraries ldap/servers lib/libaccess
by Mark Reynolds
ldap/libraries/libavl/avl.c | 7 +++--
ldap/servers/plugins/chainingdb/cb_conn_stateless.c | 2 -
ldap/servers/plugins/linkedattrs/linked_attrs.c | 17 ++++++++++--
ldap/servers/plugins/memberof/memberof.c | 18 ++++++++++---
ldap/servers/plugins/memberof/memberof_config.c | 2 -
ldap/servers/plugins/replication/cl5_api.c | 17 ++++++++++++
ldap/servers/plugins/replication/cl5_clcache.c | 11 ++++++--
ldap/servers/plugins/replication/repl5_replica_config.c | 5 +++
ldap/servers/plugins/syntaxes/string.c | 14 ++++++----
ldap/servers/slapd/back-ldbm/dbverify.c | 6 +++-
ldap/servers/slapd/back-ldbm/ldif2ldbm.c | 16 +++++++++---
ldap/servers/slapd/dn.c | 3 +-
ldap/servers/slapd/plugin.c | 21 +++++++++++-----
ldap/servers/slapd/valueset.c | 17 +++++++-----
lib/libaccess/oneeval.cpp | 12 ++++-----
15 files changed, 122 insertions(+), 46 deletions(-)
New commits:
commit ddc23f3acfeb40d1b58f3470a3765408b0c93b1d
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Wed Jun 5 12:15:05 2013 -0400
Coverity Fixes (Part 3)
11692 - Explicit null dereferenced (libavl/avl.c)
11695 - Explicit null dereferenced (cb_conn_stateless.c)
11696 - Explicit null dereferenced (memberof_config.c)
11697 - Explicit null dereferenced (memberof.c)
11698 - Explicit null dereferenced (memberof.c)
11699 - Explicit null dereferenced (memberof.c)
11700 - Explicit null dereferenced (memberof.c)
11701 - Explicit null dereferenced (cl5_api.c)
11702 - Explicit null dereferenced (cl5_api.c)
11703 - Dereference after null check (cl5_clcache.c)
11704 - Dereference after null check (repl5_replica_config.c)
11705 - Explicit null dereferenced (syntaxes/string.c)
11706 - Dereference after null check (plugin.c)
11707 - Dereference after null check (plugin.c)
11711 - Dereference after null check (ldif2ldbm.c)
11713 - Dereference after null check (dn.c)
11726 - Dereference after null check (valueset.c)
11729 - Explicit null dereferenced (libaccess/oneeval.cpp)
11744 - Explicit null dereferenced (dbverify.c)
11745 - Out-of-bounds read (linked_attrs.c)
11745 - Out-of-bounds read (memberof.c)
https://bugzilla.redhat.com/show_bug.cgi?id=970221
Reviewed by: richm(Thanks!)
(cherry picked from commit 916eb0da143eeb1745e9f67532255477eefbd3d7)
diff --git a/ldap/libraries/libavl/avl.c b/ldap/libraries/libavl/avl.c
index 7577891..18c43e0 100644
--- a/ldap/libraries/libavl/avl.c
+++ b/ldap/libraries/libavl/avl.c
@@ -780,8 +780,11 @@ avl_getfirst( Avlnode *root )
return( 0 );
(void) avl_apply( root, avl_buildlist, (caddr_t) 0, -1, AVL_INORDER );
-
- return( avl_list[ avl_nextlist++ ] );
+ if(avl_list && avl_list[avl_nextlist++]){
+ return avl_list[avl_nextlist];
+ } else {
+ return( NULL );
+ }
}
caddr_t
diff --git a/ldap/servers/plugins/chainingdb/cb_conn_stateless.c b/ldap/servers/plugins/chainingdb/cb_conn_stateless.c
index a9abc31..a85b392 100644
--- a/ldap/servers/plugins/chainingdb/cb_conn_stateless.c
+++ b/ldap/servers/plugins/chainingdb/cb_conn_stateless.c
@@ -856,7 +856,7 @@ void cb_stale_all_connections( cb_backend_instance * cb)
else {
if (conn==pools[i]->conn.conn_list) {
pools[i]->conn.conn_list=next_conn;
- } else {
+ } else if(prev_conn){
prev_conn->next=next_conn;
}
cb_close_and_dispose_connection(conn);
diff --git a/ldap/servers/plugins/linkedattrs/linked_attrs.c b/ldap/servers/plugins/linkedattrs/linked_attrs.c
index ff3dc3a..4bea10f 100644
--- a/ldap/servers/plugins/linkedattrs/linked_attrs.c
+++ b/ldap/servers/plugins/linkedattrs/linked_attrs.c
@@ -1231,10 +1231,21 @@ linked_attrs_load_array(Slapi_Value **array, Slapi_Attr *attr)
int
linked_attrs_compare(const void *a, const void *b)
{
+ Slapi_Value *val1;
+ Slapi_Value *val2;
+ Slapi_Attr *linkattr;
int rc = 0;
- Slapi_Value *val1 = *((Slapi_Value **)a);
- Slapi_Value *val2 = *((Slapi_Value **)b);
- Slapi_Attr *linkattr = slapi_attr_new();
+
+ if(a == NULL && b != NULL){
+ return 1;
+ } else if(a != NULL && b == NULL){
+ return -1;
+ } else if(a == NULL && b == NULL){
+ return 0;
+ }
+ val1 = *((Slapi_Value **)a);
+ val2 = *((Slapi_Value **)b);
+ linkattr = slapi_attr_new();
slapi_attr_init(linkattr, "distinguishedName");
diff --git a/ldap/servers/plugins/memberof/memberof.c b/ldap/servers/plugins/memberof/memberof.c
index 1c50b67..e362cab 100644
--- a/ldap/servers/plugins/memberof/memberof.c
+++ b/ldap/servers/plugins/memberof/memberof.c
@@ -460,7 +460,7 @@ memberof_del_dn_from_groups(Slapi_PBlock *pb, MemberOfConfig *config, Slapi_DN *
/* Loop through each grouping attribute to find groups that have
* dn as a member. For any matches, delete the dn value from the
* same grouping attribute. */
- for (i = 0; config->groupattrs[i]; i++)
+ for (i = 0; config->groupattrs && config->groupattrs[i]; i++)
{
memberof_del_dn_data data = {(char *)slapi_sdn_get_dn(sdn),
config->groupattrs[i]};
@@ -724,7 +724,7 @@ memberof_replace_dn_from_groups(Slapi_PBlock *pb, MemberOfConfig *config,
/* Loop through each grouping attribute to find groups that have
* pre_dn as a member. For any matches, replace pre_dn with post_dn
* using the same grouping attribute. */
- for (i = 0; config->groupattrs[i]; i++)
+ for (i = 0; config->groupattrs && config->groupattrs[i]; i++)
{
replace_dn_data data = {(char *)slapi_sdn_get_ndn(pre_sdn),
(char *)slapi_sdn_get_ndn(post_sdn),
@@ -2218,8 +2218,18 @@ void memberof_load_array(Slapi_Value **array, Slapi_Attr *attr)
*/
int memberof_compare(MemberOfConfig *config, const void *a, const void *b)
{
- Slapi_Value *val1 = *((Slapi_Value **)a);
- Slapi_Value *val2 = *((Slapi_Value **)b);
+ Slapi_Value *val1;
+ Slapi_Value *val2;
+
+ if(a == NULL && b != NULL){
+ return 1;
+ } else if(a != NULL && b == NULL){
+ return -1;
+ } else if(a == NULL && b == NULL){
+ return 0;
+ }
+ val1 = *((Slapi_Value **)a);
+ val2 = *((Slapi_Value **)b);
/* We only need to provide a Slapi_Attr here for it's syntax. We
* already validated all grouping attributes to use the Distinguished
diff --git a/ldap/servers/plugins/memberof/memberof_config.c b/ldap/servers/plugins/memberof/memberof_config.c
index b4d557a..3fd63a9 100644
--- a/ldap/servers/plugins/memberof/memberof_config.c
+++ b/ldap/servers/plugins/memberof/memberof_config.c
@@ -486,7 +486,7 @@ memberof_free_config(MemberOfConfig *config)
slapi_ch_array_free(config->groupattrs);
slapi_filter_free(config->group_filter, 1);
- for (i = 0; config->group_slapiattrs[i]; i++)
+ for (i = 0; config->group_slapiattrs && config->group_slapiattrs[i]; i++)
{
slapi_attr_free(&config->group_slapiattrs[i]);
}
diff --git a/ldap/servers/plugins/replication/cl5_api.c b/ldap/servers/plugins/replication/cl5_api.c
index 885e3a1..63b2b99 100644
--- a/ldap/servers/plugins/replication/cl5_api.c
+++ b/ldap/servers/plugins/replication/cl5_api.c
@@ -3547,6 +3547,13 @@ static void _cl5TrimFile (Object *obj, long *numToTrim, ReplicaId cleaned_rid)
* This change can be trimmed if it exceeds purge
* parameters and has been seen by all consumers.
*/
+ if(op.csn == NULL){
+ slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl, "_cl5TrimFile: "
+ "Operation missing csn, moving on to next entry.\n");
+ cl5_operation_parameters_done (&op);
+ finished =_cl5GetNextEntry (&entry, it);
+ continue;
+ }
csn_rid = csn_get_replicaid (op.csn);
if ( (*numToTrim > 0 || _cl5CanTrim (entry.time, numToTrim)) &&
ruv_covers_csn_strict (ruv, op.csn) )
@@ -3876,7 +3883,15 @@ static int _cl5ConstructRUV (const char *replGen, Object *obj, PRBool purge)
rc = _cl5GetFirstEntry (obj, &entry, &iterator, NULL);
while (rc == CL5_SUCCESS)
{
- rid = csn_get_replicaid (op.csn);
+ if(op.csn){
+ rid = csn_get_replicaid (op.csn);
+ } else {
+ slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl, "_cl5ConstructRUV: "
+ "Operation missing csn, moving on to next entry.\n");
+ cl5_operation_parameters_done (&op);
+ rc = _cl5GetNextEntry (&entry, iterator);
+ continue;
+ }
if(is_cleaned_rid(rid)){
/* skip this entry as the rid is invalid */
slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl, "_cl5ConstructRUV: "
diff --git a/ldap/servers/plugins/replication/cl5_clcache.c b/ldap/servers/plugins/replication/cl5_clcache.c
index 202cb64..738e4cb 100644
--- a/ldap/servers/plugins/replication/cl5_clcache.c
+++ b/ldap/servers/plugins/replication/cl5_clcache.c
@@ -732,9 +732,14 @@ clcache_skip_change ( CLC_Buffer *buf )
*/
if ( csn_time_difference(buf->buf_current_csn, cscb->local_maxcsn) == 0 &&
(csn_get_seqnum(buf->buf_current_csn) ==
- csn_get_seqnum(cscb->local_maxcsn) + 1) ) {
- csn_init_by_csn ( cscb->local_maxcsn, buf->buf_current_csn );
- csn_init_by_csn ( cscb->consumer_maxcsn, buf->buf_current_csn );
+ csn_get_seqnum(cscb->local_maxcsn) + 1) )
+ {
+ if(cscb->local_maxcsn){
+ csn_init_by_csn ( cscb->local_maxcsn, buf->buf_current_csn );
+ }
+ if(cscb->consumer_maxcsn){
+ csn_init_by_csn ( cscb->consumer_maxcsn, buf->buf_current_csn );
+ }
skip = 0;
break;
}
diff --git a/ldap/servers/plugins/replication/repl5_replica_config.c b/ldap/servers/plugins/replication/repl5_replica_config.c
index 77f748f..99cef03 100644
--- a/ldap/servers/plugins/replication/repl5_replica_config.c
+++ b/ldap/servers/plugins/replication/repl5_replica_config.c
@@ -2393,6 +2393,11 @@ delete_cleaned_rid_config(cleanruv_data *clean_data)
int found = 0, i;
int rc, ret, rid;
+ if(clean_data == NULL){
+ slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name, "delete_cleaned_rid_config: cleanruv data is NULL, "
+ "failed to clean the config.\n");
+ return;
+ }
/*
* If there is no maxcsn, set the proper csnstr
*/
diff --git a/ldap/servers/plugins/syntaxes/string.c b/ldap/servers/plugins/syntaxes/string.c
index 54cd7c8..6c0da94 100644
--- a/ldap/servers/plugins/syntaxes/string.c
+++ b/ldap/servers/plugins/syntaxes/string.c
@@ -84,7 +84,11 @@ string_filter_ava( struct berval *bvfilter, Slapi_Value **bvals, int syntax,
bvfilter_norm.bv_val = alt;
alt = NULL;
}
- bvfilter_norm.bv_len = strlen(bvfilter_norm.bv_val);
+ if(bvfilter_norm.bv_val){
+ bvfilter_norm.bv_len = strlen(bvfilter_norm.bv_val);
+ } else {
+ bvfilter_norm.bv_len = 0;
+ }
}
for ( i = 0; (bvals != NULL) && (bvals[i] != NULL); i++ ) {
@@ -103,7 +107,7 @@ string_filter_ava( struct berval *bvfilter, Slapi_Value **bvals, int syntax,
if(retVal) {
*retVal = bvals[i];
}
- slapi_ch_free ((void**)&bvfilter_norm.bv_val);
+ slapi_ch_free_string(&bvfilter_norm.bv_val);
return( 0 );
}
break;
@@ -112,7 +116,7 @@ string_filter_ava( struct berval *bvfilter, Slapi_Value **bvals, int syntax,
if(retVal) {
*retVal = bvals[i];
}
- slapi_ch_free ((void**)&bvfilter_norm.bv_val);
+ slapi_ch_free_string(&bvfilter_norm.bv_val);
return( 0 );
}
break;
@@ -121,14 +125,14 @@ string_filter_ava( struct berval *bvfilter, Slapi_Value **bvals, int syntax,
if(retVal) {
*retVal = bvals[i];
}
- slapi_ch_free ((void**)&bvfilter_norm.bv_val);
+ slapi_ch_free_string(&bvfilter_norm.bv_val);
return( 0 );
}
break;
}
}
- slapi_ch_free ((void**)&bvfilter_norm.bv_val);
+ slapi_ch_free_string(&bvfilter_norm.bv_val);
return( -1 );
}
diff --git a/ldap/servers/slapd/back-ldbm/dbverify.c b/ldap/servers/slapd/back-ldbm/dbverify.c
index 43fc9d5..ffd5900 100644
--- a/ldap/servers/slapd/back-ldbm/dbverify.c
+++ b/ldap/servers/slapd/back-ldbm/dbverify.c
@@ -119,9 +119,11 @@ dbverify_ext( ldbm_instance *inst, int verbose )
char *p = NULL;
p = strstr(filep, LDBM_FILENAME_SUFFIX); /* since already checked,
it must have it */
- *p = '\0';
+ if(p)
+ *p = '\0';
ainfo_get( inst->inst_be, filep+1, &ai );
- *p = '.';
+ if(p)
+ *p = '.';
if (ai->ai_key_cmp_fn) {
dbp->app_private = (void *)ai->ai_key_cmp_fn;
dbp->set_bt_compare(dbp, dblayer_bt_compare);
diff --git a/ldap/servers/slapd/back-ldbm/ldif2ldbm.c b/ldap/servers/slapd/back-ldbm/ldif2ldbm.c
index 85ad12d..bbc652f 100644
--- a/ldap/servers/slapd/back-ldbm/ldif2ldbm.c
+++ b/ldap/servers/slapd/back-ldbm/ldif2ldbm.c
@@ -2248,15 +2248,23 @@ ldbm_back_ldbm2index(Slapi_PBlock *pb)
* Update the Virtual List View indexes
*/
for ( vlvidx = 0; vlvidx < numvlv; vlvidx++ ) {
+ char *ai = "Unknown index";
+
if ( g_get_shutdown() || c_get_shutdown() ) {
goto err_out;
}
+ if(indexAttrs){
+ if(indexAttrs[vlvidx]){
+ ai = indexAttrs[vlvidx];
+ }
+ }
if (!run_from_cmdline) {
rc = dblayer_txn_begin(be, NULL, &txn);
if (0 != rc) {
+
LDAPDebug(LDAP_DEBUG_ANY,
"%s: ERROR: failed to begin txn for update index '%s'\n",
- inst->inst_name, indexAttrs[vlvidx], 0);
+ inst->inst_name, ai, 0);
LDAPDebug(LDAP_DEBUG_ANY,
"%s: Error %d: %s\n", inst->inst_name, rc,
dblayer_strerror(rc));
@@ -2264,7 +2272,7 @@ ldbm_back_ldbm2index(Slapi_PBlock *pb)
slapi_task_log_notice(task,
"%s: ERROR: failed to begin txn for update index '%s' "
"(err %d: %s)", inst->inst_name,
- indexAttrs[vlvidx], rc, dblayer_strerror(rc));
+ ai, rc, dblayer_strerror(rc));
}
return_value = -2;
goto err_out;
@@ -2283,7 +2291,7 @@ ldbm_back_ldbm2index(Slapi_PBlock *pb)
if (0 != rc) {
LDAPDebug(LDAP_DEBUG_ANY,
"%s: ERROR: failed to commit txn for update index '%s'\n",
- inst->inst_name, indexAttrs[vlvidx], 0);
+ inst->inst_name, ai, 0);
LDAPDebug(LDAP_DEBUG_ANY,
"%s: Error %d: %s\n", inst->inst_name, rc,
dblayer_strerror(rc));
@@ -2291,7 +2299,7 @@ ldbm_back_ldbm2index(Slapi_PBlock *pb)
slapi_task_log_notice(task,
"%s: ERROR: failed to commit txn for update index '%s' "
"(err %d: %s)", inst->inst_name,
- indexAttrs[vlvidx], rc, dblayer_strerror(rc));
+ ai, rc, dblayer_strerror(rc));
}
return_value = -2;
goto err_out;
diff --git a/ldap/servers/slapd/dn.c b/ldap/servers/slapd/dn.c
index 9261bd8..44459e1 100644
--- a/ldap/servers/slapd/dn.c
+++ b/ldap/servers/slapd/dn.c
@@ -2891,7 +2891,8 @@ ndn_cache_add(char *dn, size_t dn_len, char *ndn, size_t ndn_len)
new_node->next = NULL;
} else {
new_node->next = ndn_cache->head;
- ndn_cache->head->prev = new_node;
+ if(ndn_cache->head)
+ ndn_cache->head->prev = new_node;
}
ndn_cache->head = new_node;
PR_Unlock(lru_lock);
diff --git a/ldap/servers/slapd/plugin.c b/ldap/servers/slapd/plugin.c
index f90bd0d..d19faa5 100644
--- a/ldap/servers/slapd/plugin.c
+++ b/ldap/servers/slapd/plugin.c
@@ -1493,15 +1493,24 @@ int
slapi_berval_cmp (const struct berval* L, const struct berval* R) /* JCM - This does not belong here. But, where should it go? */
{
int result = 0;
+
+ if(L == NULL && R != NULL){
+ return 1;
+ } else if(L != NULL && R == NULL){
+ return -1;
+ } else if(L == NULL && R == NULL){
+ return 0;
+ }
if (L->bv_len < R->bv_len) {
- result = memcmp (L->bv_val, R->bv_val, L->bv_len);
- if (result == 0)
- result = -1;
+ result = memcmp (L->bv_val, R->bv_val, L->bv_len);
+ if (result == 0)
+ result = -1;
} else {
- result = memcmp (L->bv_val, R->bv_val, R->bv_len);
- if (result == 0 && (L->bv_len > R->bv_len))
- result = 1;
+ result = memcmp (L->bv_val, R->bv_val, R->bv_len);
+ if (result == 0 && (L->bv_len > R->bv_len))
+ result = 1;
}
+
return result;
}
diff --git a/ldap/servers/slapd/valueset.c b/ldap/servers/slapd/valueset.c
index 6bc3ffa..dffcaeb 100644
--- a/ldap/servers/slapd/valueset.c
+++ b/ldap/servers/slapd/valueset.c
@@ -190,20 +190,23 @@ valuearray_add_valuearray(Slapi_Value ***vals, Slapi_Value **addvals, PRUint32 f
{
int valslen;
int addvalslen;
- int maxvals;
+ int maxvals;
- addvalslen= valuearray_count(addvals);
+ if(vals == NULL){
+ return;
+ }
+ addvalslen= valuearray_count(addvals);
if(*vals == NULL)
{
- valslen= 0;
- maxvals= 0;
+ valslen= 0;
+ maxvals= 0;
}
else
{
- valslen= valuearray_count(*vals);
- maxvals= valslen+1;
+ valslen= valuearray_count(*vals);
+ maxvals= valslen+1;
}
- valuearray_add_valuearray_fast(vals,addvals,valslen,addvalslen,&maxvals,1/*Exact*/,flags & SLAPI_VALUE_FLAG_PASSIN);
+ valuearray_add_valuearray_fast(vals,addvals,valslen,addvalslen,&maxvals,1/*Exact*/,flags & SLAPI_VALUE_FLAG_PASSIN);
}
int
diff --git a/lib/libaccess/oneeval.cpp b/lib/libaccess/oneeval.cpp
index eff4e10..a6d3bbd 100644
--- a/lib/libaccess/oneeval.cpp
+++ b/lib/libaccess/oneeval.cpp
@@ -381,20 +381,19 @@ ACLEvalBuildContext(
/* Loop through all the ACLs in the list */
while (wrapper)
{
- acl = wrapper->acl;
+ acl = wrapper->acl;
ace = acl->expr_list_head;
while (ace) /* Loop through all the ACEs in this ACL */
{
-
/* allocate a new ace list entry and link it in to the ordered
* list.
*/
new_ace = (ACLAceEntry_t *)PERM_CALLOC(sizeof(ACLAceEntry_t));
if (new_ace == (ACLAceEntry_t *)NULL) {
- nserrGenerate(errp, ACLERRNOMEM, ACLERR4020, ACL_Program, 1,
- XP_GetAdminStr(DBT_EvalBuildContextUnableToAllocAceEntry));
- goto error;
+ nserrGenerate(errp, ACLERRNOMEM, ACLERR4020, ACL_Program, 1,
+ XP_GetAdminStr(DBT_EvalBuildContextUnableToAllocAceEntry));
+ goto error;
}
new_ace->acep = ace;
ace_cnt++;
@@ -402,7 +401,8 @@ ACLEvalBuildContext(
if (cache->acelist == NULL)
cache->acelist = acelast = new_ace;
else {
- acelast->next = new_ace;
+ if(acelast)
+ acelast->next = new_ace;
acelast = new_ace;
new_ace->acep = ace;
}
10 years, 10 months
ldap/libraries ldap/servers lib/libaccess
by Mark Reynolds
ldap/libraries/libavl/avl.c | 7 +++--
ldap/servers/plugins/chainingdb/cb_conn_stateless.c | 2 -
ldap/servers/plugins/linkedattrs/linked_attrs.c | 17 ++++++++++--
ldap/servers/plugins/memberof/memberof.c | 18 ++++++++++---
ldap/servers/plugins/memberof/memberof_config.c | 2 -
ldap/servers/plugins/replication/cl5_api.c | 17 ++++++++++++
ldap/servers/plugins/replication/cl5_clcache.c | 11 ++++++--
ldap/servers/plugins/replication/repl5_replica_config.c | 5 +++
ldap/servers/plugins/syntaxes/string.c | 14 ++++++----
ldap/servers/slapd/back-ldbm/dbverify.c | 6 +++-
ldap/servers/slapd/back-ldbm/ldif2ldbm.c | 16 +++++++++---
ldap/servers/slapd/dn.c | 3 +-
ldap/servers/slapd/plugin.c | 21 +++++++++++-----
ldap/servers/slapd/valueset.c | 17 +++++++-----
lib/libaccess/oneeval.cpp | 12 ++++-----
15 files changed, 122 insertions(+), 46 deletions(-)
New commits:
commit 916eb0da143eeb1745e9f67532255477eefbd3d7
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Wed Jun 5 12:15:05 2013 -0400
Coverity Fixes (Part 3)
11692 - Explicit null dereferenced (libavl/avl.c)
11695 - Explicit null dereferenced (cb_conn_stateless.c)
11696 - Explicit null dereferenced (memberof_config.c)
11697 - Explicit null dereferenced (memberof.c)
11698 - Explicit null dereferenced (memberof.c)
11699 - Explicit null dereferenced (memberof.c)
11700 - Explicit null dereferenced (memberof.c)
11701 - Explicit null dereferenced (cl5_api.c)
11702 - Explicit null dereferenced (cl5_api.c)
11703 - Dereference after null check (cl5_clcache.c)
11704 - Dereference after null check (repl5_replica_config.c)
11705 - Explicit null dereferenced (syntaxes/string.c)
11706 - Dereference after null check (plugin.c)
11707 - Dereference after null check (plugin.c)
11711 - Dereference after null check (ldif2ldbm.c)
11713 - Dereference after null check (dn.c)
11726 - Dereference after null check (valueset.c)
11729 - Explicit null dereferenced (libaccess/oneeval.cpp)
11744 - Explicit null dereferenced (dbverify.c)
11745 - Out-of-bounds read (linked_attrs.c)
11745 - Out-of-bounds read (memberof.c)
https://bugzilla.redhat.com/show_bug.cgi?id=970221
Reviewed by: richm(Thanks!)
diff --git a/ldap/libraries/libavl/avl.c b/ldap/libraries/libavl/avl.c
index 7577891..18c43e0 100644
--- a/ldap/libraries/libavl/avl.c
+++ b/ldap/libraries/libavl/avl.c
@@ -780,8 +780,11 @@ avl_getfirst( Avlnode *root )
return( 0 );
(void) avl_apply( root, avl_buildlist, (caddr_t) 0, -1, AVL_INORDER );
-
- return( avl_list[ avl_nextlist++ ] );
+ if(avl_list && avl_list[avl_nextlist++]){
+ return avl_list[avl_nextlist];
+ } else {
+ return( NULL );
+ }
}
caddr_t
diff --git a/ldap/servers/plugins/chainingdb/cb_conn_stateless.c b/ldap/servers/plugins/chainingdb/cb_conn_stateless.c
index a9abc31..a85b392 100644
--- a/ldap/servers/plugins/chainingdb/cb_conn_stateless.c
+++ b/ldap/servers/plugins/chainingdb/cb_conn_stateless.c
@@ -856,7 +856,7 @@ void cb_stale_all_connections( cb_backend_instance * cb)
else {
if (conn==pools[i]->conn.conn_list) {
pools[i]->conn.conn_list=next_conn;
- } else {
+ } else if(prev_conn){
prev_conn->next=next_conn;
}
cb_close_and_dispose_connection(conn);
diff --git a/ldap/servers/plugins/linkedattrs/linked_attrs.c b/ldap/servers/plugins/linkedattrs/linked_attrs.c
index ff3dc3a..4bea10f 100644
--- a/ldap/servers/plugins/linkedattrs/linked_attrs.c
+++ b/ldap/servers/plugins/linkedattrs/linked_attrs.c
@@ -1231,10 +1231,21 @@ linked_attrs_load_array(Slapi_Value **array, Slapi_Attr *attr)
int
linked_attrs_compare(const void *a, const void *b)
{
+ Slapi_Value *val1;
+ Slapi_Value *val2;
+ Slapi_Attr *linkattr;
int rc = 0;
- Slapi_Value *val1 = *((Slapi_Value **)a);
- Slapi_Value *val2 = *((Slapi_Value **)b);
- Slapi_Attr *linkattr = slapi_attr_new();
+
+ if(a == NULL && b != NULL){
+ return 1;
+ } else if(a != NULL && b == NULL){
+ return -1;
+ } else if(a == NULL && b == NULL){
+ return 0;
+ }
+ val1 = *((Slapi_Value **)a);
+ val2 = *((Slapi_Value **)b);
+ linkattr = slapi_attr_new();
slapi_attr_init(linkattr, "distinguishedName");
diff --git a/ldap/servers/plugins/memberof/memberof.c b/ldap/servers/plugins/memberof/memberof.c
index 1c50b67..e362cab 100644
--- a/ldap/servers/plugins/memberof/memberof.c
+++ b/ldap/servers/plugins/memberof/memberof.c
@@ -460,7 +460,7 @@ memberof_del_dn_from_groups(Slapi_PBlock *pb, MemberOfConfig *config, Slapi_DN *
/* Loop through each grouping attribute to find groups that have
* dn as a member. For any matches, delete the dn value from the
* same grouping attribute. */
- for (i = 0; config->groupattrs[i]; i++)
+ for (i = 0; config->groupattrs && config->groupattrs[i]; i++)
{
memberof_del_dn_data data = {(char *)slapi_sdn_get_dn(sdn),
config->groupattrs[i]};
@@ -724,7 +724,7 @@ memberof_replace_dn_from_groups(Slapi_PBlock *pb, MemberOfConfig *config,
/* Loop through each grouping attribute to find groups that have
* pre_dn as a member. For any matches, replace pre_dn with post_dn
* using the same grouping attribute. */
- for (i = 0; config->groupattrs[i]; i++)
+ for (i = 0; config->groupattrs && config->groupattrs[i]; i++)
{
replace_dn_data data = {(char *)slapi_sdn_get_ndn(pre_sdn),
(char *)slapi_sdn_get_ndn(post_sdn),
@@ -2218,8 +2218,18 @@ void memberof_load_array(Slapi_Value **array, Slapi_Attr *attr)
*/
int memberof_compare(MemberOfConfig *config, const void *a, const void *b)
{
- Slapi_Value *val1 = *((Slapi_Value **)a);
- Slapi_Value *val2 = *((Slapi_Value **)b);
+ Slapi_Value *val1;
+ Slapi_Value *val2;
+
+ if(a == NULL && b != NULL){
+ return 1;
+ } else if(a != NULL && b == NULL){
+ return -1;
+ } else if(a == NULL && b == NULL){
+ return 0;
+ }
+ val1 = *((Slapi_Value **)a);
+ val2 = *((Slapi_Value **)b);
/* We only need to provide a Slapi_Attr here for it's syntax. We
* already validated all grouping attributes to use the Distinguished
diff --git a/ldap/servers/plugins/memberof/memberof_config.c b/ldap/servers/plugins/memberof/memberof_config.c
index b4d557a..3fd63a9 100644
--- a/ldap/servers/plugins/memberof/memberof_config.c
+++ b/ldap/servers/plugins/memberof/memberof_config.c
@@ -486,7 +486,7 @@ memberof_free_config(MemberOfConfig *config)
slapi_ch_array_free(config->groupattrs);
slapi_filter_free(config->group_filter, 1);
- for (i = 0; config->group_slapiattrs[i]; i++)
+ for (i = 0; config->group_slapiattrs && config->group_slapiattrs[i]; i++)
{
slapi_attr_free(&config->group_slapiattrs[i]);
}
diff --git a/ldap/servers/plugins/replication/cl5_api.c b/ldap/servers/plugins/replication/cl5_api.c
index 885e3a1..63b2b99 100644
--- a/ldap/servers/plugins/replication/cl5_api.c
+++ b/ldap/servers/plugins/replication/cl5_api.c
@@ -3547,6 +3547,13 @@ static void _cl5TrimFile (Object *obj, long *numToTrim, ReplicaId cleaned_rid)
* This change can be trimmed if it exceeds purge
* parameters and has been seen by all consumers.
*/
+ if(op.csn == NULL){
+ slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl, "_cl5TrimFile: "
+ "Operation missing csn, moving on to next entry.\n");
+ cl5_operation_parameters_done (&op);
+ finished =_cl5GetNextEntry (&entry, it);
+ continue;
+ }
csn_rid = csn_get_replicaid (op.csn);
if ( (*numToTrim > 0 || _cl5CanTrim (entry.time, numToTrim)) &&
ruv_covers_csn_strict (ruv, op.csn) )
@@ -3876,7 +3883,15 @@ static int _cl5ConstructRUV (const char *replGen, Object *obj, PRBool purge)
rc = _cl5GetFirstEntry (obj, &entry, &iterator, NULL);
while (rc == CL5_SUCCESS)
{
- rid = csn_get_replicaid (op.csn);
+ if(op.csn){
+ rid = csn_get_replicaid (op.csn);
+ } else {
+ slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl, "_cl5ConstructRUV: "
+ "Operation missing csn, moving on to next entry.\n");
+ cl5_operation_parameters_done (&op);
+ rc = _cl5GetNextEntry (&entry, iterator);
+ continue;
+ }
if(is_cleaned_rid(rid)){
/* skip this entry as the rid is invalid */
slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl, "_cl5ConstructRUV: "
diff --git a/ldap/servers/plugins/replication/cl5_clcache.c b/ldap/servers/plugins/replication/cl5_clcache.c
index 202cb64..738e4cb 100644
--- a/ldap/servers/plugins/replication/cl5_clcache.c
+++ b/ldap/servers/plugins/replication/cl5_clcache.c
@@ -732,9 +732,14 @@ clcache_skip_change ( CLC_Buffer *buf )
*/
if ( csn_time_difference(buf->buf_current_csn, cscb->local_maxcsn) == 0 &&
(csn_get_seqnum(buf->buf_current_csn) ==
- csn_get_seqnum(cscb->local_maxcsn) + 1) ) {
- csn_init_by_csn ( cscb->local_maxcsn, buf->buf_current_csn );
- csn_init_by_csn ( cscb->consumer_maxcsn, buf->buf_current_csn );
+ csn_get_seqnum(cscb->local_maxcsn) + 1) )
+ {
+ if(cscb->local_maxcsn){
+ csn_init_by_csn ( cscb->local_maxcsn, buf->buf_current_csn );
+ }
+ if(cscb->consumer_maxcsn){
+ csn_init_by_csn ( cscb->consumer_maxcsn, buf->buf_current_csn );
+ }
skip = 0;
break;
}
diff --git a/ldap/servers/plugins/replication/repl5_replica_config.c b/ldap/servers/plugins/replication/repl5_replica_config.c
index 58285f9..cc0a93f 100644
--- a/ldap/servers/plugins/replication/repl5_replica_config.c
+++ b/ldap/servers/plugins/replication/repl5_replica_config.c
@@ -2468,6 +2468,11 @@ delete_cleaned_rid_config(cleanruv_data *clean_data)
int found = 0, i;
int rc, ret, rid;
+ if(clean_data == NULL){
+ slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name, "delete_cleaned_rid_config: cleanruv data is NULL, "
+ "failed to clean the config.\n");
+ return;
+ }
/*
* If there is no maxcsn, set the proper csnstr
*/
diff --git a/ldap/servers/plugins/syntaxes/string.c b/ldap/servers/plugins/syntaxes/string.c
index 54cd7c8..6c0da94 100644
--- a/ldap/servers/plugins/syntaxes/string.c
+++ b/ldap/servers/plugins/syntaxes/string.c
@@ -84,7 +84,11 @@ string_filter_ava( struct berval *bvfilter, Slapi_Value **bvals, int syntax,
bvfilter_norm.bv_val = alt;
alt = NULL;
}
- bvfilter_norm.bv_len = strlen(bvfilter_norm.bv_val);
+ if(bvfilter_norm.bv_val){
+ bvfilter_norm.bv_len = strlen(bvfilter_norm.bv_val);
+ } else {
+ bvfilter_norm.bv_len = 0;
+ }
}
for ( i = 0; (bvals != NULL) && (bvals[i] != NULL); i++ ) {
@@ -103,7 +107,7 @@ string_filter_ava( struct berval *bvfilter, Slapi_Value **bvals, int syntax,
if(retVal) {
*retVal = bvals[i];
}
- slapi_ch_free ((void**)&bvfilter_norm.bv_val);
+ slapi_ch_free_string(&bvfilter_norm.bv_val);
return( 0 );
}
break;
@@ -112,7 +116,7 @@ string_filter_ava( struct berval *bvfilter, Slapi_Value **bvals, int syntax,
if(retVal) {
*retVal = bvals[i];
}
- slapi_ch_free ((void**)&bvfilter_norm.bv_val);
+ slapi_ch_free_string(&bvfilter_norm.bv_val);
return( 0 );
}
break;
@@ -121,14 +125,14 @@ string_filter_ava( struct berval *bvfilter, Slapi_Value **bvals, int syntax,
if(retVal) {
*retVal = bvals[i];
}
- slapi_ch_free ((void**)&bvfilter_norm.bv_val);
+ slapi_ch_free_string(&bvfilter_norm.bv_val);
return( 0 );
}
break;
}
}
- slapi_ch_free ((void**)&bvfilter_norm.bv_val);
+ slapi_ch_free_string(&bvfilter_norm.bv_val);
return( -1 );
}
diff --git a/ldap/servers/slapd/back-ldbm/dbverify.c b/ldap/servers/slapd/back-ldbm/dbverify.c
index 43fc9d5..ffd5900 100644
--- a/ldap/servers/slapd/back-ldbm/dbverify.c
+++ b/ldap/servers/slapd/back-ldbm/dbverify.c
@@ -119,9 +119,11 @@ dbverify_ext( ldbm_instance *inst, int verbose )
char *p = NULL;
p = strstr(filep, LDBM_FILENAME_SUFFIX); /* since already checked,
it must have it */
- *p = '\0';
+ if(p)
+ *p = '\0';
ainfo_get( inst->inst_be, filep+1, &ai );
- *p = '.';
+ if(p)
+ *p = '.';
if (ai->ai_key_cmp_fn) {
dbp->app_private = (void *)ai->ai_key_cmp_fn;
dbp->set_bt_compare(dbp, dblayer_bt_compare);
diff --git a/ldap/servers/slapd/back-ldbm/ldif2ldbm.c b/ldap/servers/slapd/back-ldbm/ldif2ldbm.c
index 85ad12d..bbc652f 100644
--- a/ldap/servers/slapd/back-ldbm/ldif2ldbm.c
+++ b/ldap/servers/slapd/back-ldbm/ldif2ldbm.c
@@ -2248,15 +2248,23 @@ ldbm_back_ldbm2index(Slapi_PBlock *pb)
* Update the Virtual List View indexes
*/
for ( vlvidx = 0; vlvidx < numvlv; vlvidx++ ) {
+ char *ai = "Unknown index";
+
if ( g_get_shutdown() || c_get_shutdown() ) {
goto err_out;
}
+ if(indexAttrs){
+ if(indexAttrs[vlvidx]){
+ ai = indexAttrs[vlvidx];
+ }
+ }
if (!run_from_cmdline) {
rc = dblayer_txn_begin(be, NULL, &txn);
if (0 != rc) {
+
LDAPDebug(LDAP_DEBUG_ANY,
"%s: ERROR: failed to begin txn for update index '%s'\n",
- inst->inst_name, indexAttrs[vlvidx], 0);
+ inst->inst_name, ai, 0);
LDAPDebug(LDAP_DEBUG_ANY,
"%s: Error %d: %s\n", inst->inst_name, rc,
dblayer_strerror(rc));
@@ -2264,7 +2272,7 @@ ldbm_back_ldbm2index(Slapi_PBlock *pb)
slapi_task_log_notice(task,
"%s: ERROR: failed to begin txn for update index '%s' "
"(err %d: %s)", inst->inst_name,
- indexAttrs[vlvidx], rc, dblayer_strerror(rc));
+ ai, rc, dblayer_strerror(rc));
}
return_value = -2;
goto err_out;
@@ -2283,7 +2291,7 @@ ldbm_back_ldbm2index(Slapi_PBlock *pb)
if (0 != rc) {
LDAPDebug(LDAP_DEBUG_ANY,
"%s: ERROR: failed to commit txn for update index '%s'\n",
- inst->inst_name, indexAttrs[vlvidx], 0);
+ inst->inst_name, ai, 0);
LDAPDebug(LDAP_DEBUG_ANY,
"%s: Error %d: %s\n", inst->inst_name, rc,
dblayer_strerror(rc));
@@ -2291,7 +2299,7 @@ ldbm_back_ldbm2index(Slapi_PBlock *pb)
slapi_task_log_notice(task,
"%s: ERROR: failed to commit txn for update index '%s' "
"(err %d: %s)", inst->inst_name,
- indexAttrs[vlvidx], rc, dblayer_strerror(rc));
+ ai, rc, dblayer_strerror(rc));
}
return_value = -2;
goto err_out;
diff --git a/ldap/servers/slapd/dn.c b/ldap/servers/slapd/dn.c
index 9261bd8..44459e1 100644
--- a/ldap/servers/slapd/dn.c
+++ b/ldap/servers/slapd/dn.c
@@ -2891,7 +2891,8 @@ ndn_cache_add(char *dn, size_t dn_len, char *ndn, size_t ndn_len)
new_node->next = NULL;
} else {
new_node->next = ndn_cache->head;
- ndn_cache->head->prev = new_node;
+ if(ndn_cache->head)
+ ndn_cache->head->prev = new_node;
}
ndn_cache->head = new_node;
PR_Unlock(lru_lock);
diff --git a/ldap/servers/slapd/plugin.c b/ldap/servers/slapd/plugin.c
index f90bd0d..d19faa5 100644
--- a/ldap/servers/slapd/plugin.c
+++ b/ldap/servers/slapd/plugin.c
@@ -1493,15 +1493,24 @@ int
slapi_berval_cmp (const struct berval* L, const struct berval* R) /* JCM - This does not belong here. But, where should it go? */
{
int result = 0;
+
+ if(L == NULL && R != NULL){
+ return 1;
+ } else if(L != NULL && R == NULL){
+ return -1;
+ } else if(L == NULL && R == NULL){
+ return 0;
+ }
if (L->bv_len < R->bv_len) {
- result = memcmp (L->bv_val, R->bv_val, L->bv_len);
- if (result == 0)
- result = -1;
+ result = memcmp (L->bv_val, R->bv_val, L->bv_len);
+ if (result == 0)
+ result = -1;
} else {
- result = memcmp (L->bv_val, R->bv_val, R->bv_len);
- if (result == 0 && (L->bv_len > R->bv_len))
- result = 1;
+ result = memcmp (L->bv_val, R->bv_val, R->bv_len);
+ if (result == 0 && (L->bv_len > R->bv_len))
+ result = 1;
}
+
return result;
}
diff --git a/ldap/servers/slapd/valueset.c b/ldap/servers/slapd/valueset.c
index afde14b..c4e3d5d 100644
--- a/ldap/servers/slapd/valueset.c
+++ b/ldap/servers/slapd/valueset.c
@@ -190,20 +190,23 @@ valuearray_add_valuearray(Slapi_Value ***vals, Slapi_Value **addvals, PRUint32 f
{
int valslen;
int addvalslen;
- int maxvals;
+ int maxvals;
- addvalslen= valuearray_count(addvals);
+ if(vals == NULL){
+ return;
+ }
+ addvalslen= valuearray_count(addvals);
if(*vals == NULL)
{
- valslen= 0;
- maxvals= 0;
+ valslen= 0;
+ maxvals= 0;
}
else
{
- valslen= valuearray_count(*vals);
- maxvals= valslen+1;
+ valslen= valuearray_count(*vals);
+ maxvals= valslen+1;
}
- valuearray_add_valuearray_fast(vals,addvals,valslen,addvalslen,&maxvals,1/*Exact*/,flags & SLAPI_VALUE_FLAG_PASSIN);
+ valuearray_add_valuearray_fast(vals,addvals,valslen,addvalslen,&maxvals,1/*Exact*/,flags & SLAPI_VALUE_FLAG_PASSIN);
}
int
diff --git a/lib/libaccess/oneeval.cpp b/lib/libaccess/oneeval.cpp
index eff4e10..a6d3bbd 100644
--- a/lib/libaccess/oneeval.cpp
+++ b/lib/libaccess/oneeval.cpp
@@ -381,20 +381,19 @@ ACLEvalBuildContext(
/* Loop through all the ACLs in the list */
while (wrapper)
{
- acl = wrapper->acl;
+ acl = wrapper->acl;
ace = acl->expr_list_head;
while (ace) /* Loop through all the ACEs in this ACL */
{
-
/* allocate a new ace list entry and link it in to the ordered
* list.
*/
new_ace = (ACLAceEntry_t *)PERM_CALLOC(sizeof(ACLAceEntry_t));
if (new_ace == (ACLAceEntry_t *)NULL) {
- nserrGenerate(errp, ACLERRNOMEM, ACLERR4020, ACL_Program, 1,
- XP_GetAdminStr(DBT_EvalBuildContextUnableToAllocAceEntry));
- goto error;
+ nserrGenerate(errp, ACLERRNOMEM, ACLERR4020, ACL_Program, 1,
+ XP_GetAdminStr(DBT_EvalBuildContextUnableToAllocAceEntry));
+ goto error;
}
new_ace->acep = ace;
ace_cnt++;
@@ -402,7 +401,8 @@ ACLEvalBuildContext(
if (cache->acelist == NULL)
cache->acelist = acelast = new_ace;
else {
- acelast->next = new_ace;
+ if(acelast)
+ acelast->next = new_ace;
acelast = new_ace;
new_ace->acep = ace;
}
10 years, 10 months
ldap/servers
by thierry bordaz
ldap/servers/plugins/replication/repl5_replica_config.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
New commits:
commit ab7bab02e7d240da9736290b7b35ee69f7b569b5
Author: Thierry bordaz (tbordaz) <tbordaz(a)redhat.com>
Date: Wed Jun 5 14:49:20 2013 +0200
Compilation warnings (ticket 47350)
Bug Description:
Get rid of the following warnings:
repl5_replica_config.c:543:14: warning: variable 'r' set but not used [-Wunused-but-set-variable]
repl5_replica_config.c:721: warning: implicit declaration of function 'valuearray_free'
repl5_replica_config.c: In function 'replica_config_search':
repl5_replica_config.c:799: warning: passing argument 2 of 'search_requested_attr' discards qualifiers from pointer target type
repl5_replica_config.c:753: note: expected 'char *' but argument is of type 'const char *'
repl5_replica_config.c:804: warning: passing argument 2 of 'search_requested_attr' discards qualifiers from pointer target type
repl5_replica_config.c:753: note: expected 'char *' but argument is of type 'const char *'
Fix Description:
https://fedorahosted.org/389/ticket/47350
Reviewed by: Mark Reynolds
Platforms tested: fedora
Flag Day: no
Doc impact: no
diff --git a/ldap/servers/plugins/replication/repl5_replica_config.c b/ldap/servers/plugins/replication/repl5_replica_config.c
index 9dc9169..58285f9 100644
--- a/ldap/servers/plugins/replication/repl5_replica_config.c
+++ b/ldap/servers/plugins/replication/repl5_replica_config.c
@@ -47,6 +47,7 @@
#include "repl5.h"
#include "cl5_api.h"
#include "cl5.h"
+#include "slap.h"
/* CONFIG_BASE: no need to optimize */
#define CONFIG_BASE "cn=mapping tree,cn=config"
@@ -540,7 +541,6 @@ replica_config_post_modify(Slapi_PBlock *pb,
LDAPMod **mods;
int i, apply_mods;
multimaster_mtnode_extension *mtnode_ext;
- Replica *r = NULL;
char *replica_root = NULL;
char buf [SLAPI_DSE_RETURNTEXT_SIZE];
char *errortext = returntext ? returntext : buf;
@@ -587,8 +587,7 @@ replica_config_post_modify(Slapi_PBlock *pb,
goto done;
}
- r = object_get_data (mtnode_ext->replica);
- PR_ASSERT (r);
+ PR_ASSERT (object_get_data (mtnode_ext->replica) != NULL);
slapi_pblock_get(pb, SLAPI_MODIFY_MODS, &mods);
for (apply_mods = 0; apply_mods <= 1; apply_mods++)
@@ -750,7 +749,7 @@ replica_config_search_ruv(Slapi_PBlock *pb, Slapi_Entry* e, Replica *replica)
* else it returns PR_FALSE
*/
static PRBool
-search_requested_attr(Slapi_PBlock *pb, char *attr)
+search_requested_attr(Slapi_PBlock *pb, const char *attr)
{
char **attrs = NULL;
int i;
10 years, 10 months
Branch '389-ds-base-1.2.11' - ldap/servers
by Mark Reynolds
ldap/servers/plugins/collation/collate.c | 24 +++----
ldap/servers/plugins/replication/windows_protocol_util.c | 9 +-
ldap/servers/slapd/back-ldbm/index.c | 17 ++---
ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c | 24 +------
ldap/servers/slapd/back-ldbm/ldbm_search.c | 2
ldap/servers/slapd/back-ldbm/seq.c | 2
ldap/servers/slapd/bind.c | 2
ldap/servers/slapd/log.c | 46 +++------------
8 files changed, 40 insertions(+), 86 deletions(-)
New commits:
commit 41a882743c7c21575ed5365fe0484bc8d96edc6f
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Tue Jun 4 13:25:22 2013 -0400
Coverity Fixes (Part 2)
11674 - logically dead code (collate.c)
11675 - logically dead code (windows_protocol_util.c)
11676 - logically dead code (index.c)
11677 - logically dead code (ldbm_entryrdn.c)
11678 - logically dead code (ldbm_entryrdn.c)
11680 - logically dead code (ldbm_search.c)
11681 - Dead default in switch (seq.c)
11683 - logically dead code (bind.c)
11684 - logically dead code (connection.c)
11686 - Dead default in switch (log.c)
11687 - Dead default in switch (log.c)
11688 - Dead default in switch (log.c)
11689 - Dead default in switch (log.c)
11690 - Dead default in switch (log.c)
11691 - Dead default in switch (log.c)
https://bugzilla.redhat.com/show_bug.cgi?id=970221
Reviewed by: nhosoi(Thanks!)
(cherry picked from commit db673270e9a01e48adb22d94e676f25a223f407b)
diff --git a/ldap/servers/plugins/collation/collate.c b/ldap/servers/plugins/collation/collate.c
index 240da70..2a73ee1 100644
--- a/ldap/servers/plugins/collation/collate.c
+++ b/ldap/servers/plugins/collation/collate.c
@@ -437,11 +437,7 @@ collation_indexer_create (const char* oid)
profile->variant == NULL);
UErrorCode err = U_ZERO_ERROR;
if ( ! is_default) {
- if (locale) {
- PR_smprintf_free(locale);
- locale = NULL;
- }
- err = s_newNamedLocaleFromComponents(&locale,
+ err = s_newNamedLocaleFromComponents(&locale,
profile->language,
profile->country,
profile->variant);
@@ -460,27 +456,27 @@ collation_indexer_create (const char* oid)
ucol_setAttribute (coll, UCOL_STRENGTH, profile->strength, &err);
if (err != U_ZERO_ERROR && err != U_USING_FALLBACK_WARNING
&& (err != U_USING_DEFAULT_WARNING || !is_default)) {
- LDAPDebug (LDAP_DEBUG_ANY, "collation_indexer_create: could not "
+ LDAPDebug (LDAP_DEBUG_ANY, "collation_indexer_create: could not "
"set the collator strength for oid %s to %d: err %d\n",
oid, profile->strength, err);
}
ucol_setAttribute (coll, UCOL_DECOMPOSITION_MODE, profile->decomposition, &err);
if (err != U_ZERO_ERROR && err != U_USING_FALLBACK_WARNING
&& (err != U_USING_DEFAULT_WARNING || !is_default)) {
- LDAPDebug (LDAP_DEBUG_ANY, "collation_indexer_create: could not "
+ LDAPDebug (LDAP_DEBUG_ANY, "collation_indexer_create: could not "
"set the collator decomposition mode for oid %s to %d: err %d\n",
oid, profile->decomposition, err);
}
etc->collator = coll;
for (id = collation_id; *id; ++id) {
- if ((*id)->profile == profile) {
- break; /* found the 'official' id */
- }
+ if ((*id)->profile == profile) {
+ break; /* found the 'official' id */
+ }
}
- if (!*id) {
- LDAPDebug (LDAP_DEBUG_ANY, "collation_indexer_create: id not found\n", 0, 0, 0);
- goto error;
- }
+ if (!*id) {
+ LDAPDebug (LDAP_DEBUG_ANY, "collation_indexer_create: id not found\n", 0, 0, 0);
+ goto error;
+ }
ix->ix_etc = etc;
ix->ix_oid = (*id)->oid;
diff --git a/ldap/servers/plugins/replication/windows_protocol_util.c b/ldap/servers/plugins/replication/windows_protocol_util.c
index 1bafa9a..0b3c575 100644
--- a/ldap/servers/plugins/replication/windows_protocol_util.c
+++ b/ldap/servers/plugins/replication/windows_protocol_util.c
@@ -4190,7 +4190,7 @@ windows_generate_update_mods(Private_Repl_Protocol *prp,Slapi_Entry *remote_entr
windows_is_remote_entry_user_or_group(remote_entry,&is_user,&is_group);
}
- for (rc = slapi_entry_first_attr(remote_entry, &attr); rc == 0;
+ for (rc = slapi_entry_first_attr(remote_entry, &attr); rc == 0;
rc = slapi_entry_next_attr(remote_entry, attr, &attr))
{
int is_present_local = 0;
@@ -4201,7 +4201,6 @@ windows_generate_update_mods(Private_Repl_Protocol *prp,Slapi_Entry *remote_entr
int is_guid = 0;
int mapdn = 0;
-
slapi_attr_get_type( attr, &type );
slapi_attr_get_valueset(attr,&vs);
@@ -4360,7 +4359,7 @@ windows_generate_update_mods(Private_Repl_Protocol *prp,Slapi_Entry *remote_entr
"windows_generate_update_mods: no restricted local values found for "
"local attribute %s in local entry %s for remote attribute "
"%s in remote entry %s\n",
- local_type ? local_type : "NULL",
+ local_type,
slapi_entry_get_dn(local_entry),
type ? type : "NULL",
slapi_entry_get_dn(remote_entry));
@@ -4372,7 +4371,7 @@ windows_generate_update_mods(Private_Repl_Protocol *prp,Slapi_Entry *remote_entr
"windows_generate_update_mods: no local values found for "
"local attribute %s in local entry %s for remote attribute "
"%s in remote entry %s\n",
- local_type ? local_type : "NULL",
+ local_type,
slapi_entry_get_dn(local_entry),
type ? type : "NULL",
slapi_entry_get_dn(remote_entry));
@@ -4384,7 +4383,7 @@ windows_generate_update_mods(Private_Repl_Protocol *prp,Slapi_Entry *remote_entr
"windows_generate_update_mods: could not map the values in "
"local attribute %s in local entry %s for remote attribute "
"%s in remote entry %s\n",
- local_type ? local_type : "NULL",
+ local_type,
slapi_entry_get_dn(local_entry),
type ? type : "NULL",
slapi_entry_get_dn(remote_entry));
diff --git a/ldap/servers/slapd/back-ldbm/index.c b/ldap/servers/slapd/back-ldbm/index.c
index 5948717..f90a47c 100644
--- a/ldap/servers/slapd/back-ldbm/index.c
+++ b/ldap/servers/slapd/back-ldbm/index.c
@@ -649,18 +649,17 @@ index_add_mods(
mods[i]->mod_op |= LDAP_MOD_IGNORE;
}
}
- if (mods_valueArray) {
- rc = index_addordel_values_sv( be,
- mods[i]->mod_type,
- mods_valueArray, NULL,
- id, BE_INDEX_ADD, txn );
- if (rc) {
- ldbm_nasty(errmsg, 1042, rc);
- goto error;
- }
+ if(mods_valueArray[0]){
+ rc = index_addordel_values_sv( be, mods[i]->mod_type,
+ mods_valueArray, NULL,
+ id, BE_INDEX_ADD, txn );
} else {
rc = 0;
}
+ if (rc) {
+ ldbm_nasty(errmsg, 1042, rc);
+ goto error;
+ }
}
}
break;
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c b/ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c
index e50b930..f3823cb 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c
@@ -809,14 +809,8 @@ entryrdn_rename_subtree(backend *be,
renamedata.data = (void *)oldsupelem;
}
} else {
- if (mynewsupsdn) {
- renamedata.ulen = renamedata.size = newsupelemlen;
- renamedata.data = (void *)newsupelem;
- } else {
- /* never comes here */
- rc = -1;
- goto bail;
- }
+ renamedata.ulen = renamedata.size = newsupelemlen;
+ renamedata.data = (void *)newsupelem;
}
rc = _entryrdn_put_data(cursor, &key, &renamedata, RDN_INDEX_PARENT, db_txn);
if (rc) {
@@ -901,16 +895,10 @@ entryrdn_rename_subtree(backend *be,
renamedata.data = (void *)targetelem;
}
} else {
- if (mynewsrdn) {
- memset(&renamedata, 0, sizeof(renamedata));
- renamedata.ulen = renamedata.size = newelemlen;
- renamedata.data = (void *)newelem;
- renamedata.flags = DB_DBT_USERMEM;
- } else {
- /* never comes here */
- rc = -1;
- goto bail;
- }
+ memset(&renamedata, 0, sizeof(renamedata));
+ renamedata.ulen = renamedata.size = newelemlen;
+ renamedata.data = (void *)newelem;
+ renamedata.flags = DB_DBT_USERMEM;
}
rc = _entryrdn_put_data(cursor, &key, &renamedata, RDN_INDEX_CHILD, db_txn);
if (rc) {
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_search.c b/ldap/servers/slapd/back-ldbm/ldbm_search.c
index b9f8688..c61dcce 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_search.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_search.c
@@ -573,7 +573,7 @@ ldbm_back_search( Slapi_PBlock *pb )
/* This candidate list is for vlv, no need for sort only. */
switch (vlv_search_build_candidate_list(pb, basesdn, &vlv_rc,
sort_control,
- (vlv ? &vlv_request_control : NULL),
+ &vlv_request_control,
&candidates, &vlv_response_control)) {
case VLV_ACCESS_DENIED:
return ldbm_back_search_cleanup(pb, li, sort_control,
diff --git a/ldap/servers/slapd/back-ldbm/seq.c b/ldap/servers/slapd/back-ldbm/seq.c
index 1435ba2..ab473bd 100644
--- a/ldap/servers/slapd/back-ldbm/seq.c
+++ b/ldap/servers/slapd/back-ldbm/seq.c
@@ -221,8 +221,6 @@ ldbm_back_seq( Slapi_PBlock *pb )
}
}
break;
- default:
- PR_ASSERT(0);
}
dbc->c_close(dbc);
diff --git a/ldap/servers/slapd/bind.c b/ldap/servers/slapd/bind.c
index e92add5..ec874cc 100644
--- a/ldap/servers/slapd/bind.c
+++ b/ldap/servers/slapd/bind.c
@@ -178,7 +178,7 @@ do_bind( Slapi_PBlock *pb )
/* check that the dn is formatted correctly */
rc = slapi_dn_syntax_check(pb, rawdn, 1);
if (rc) { /* syntax check failed */
- op_shared_log_error_access(pb, "BIND", rawdn?rawdn:"",
+ op_shared_log_error_access(pb, "BIND", rawdn,
"strict: invalid bind dn");
send_ldap_result(pb, LDAP_INVALID_DN_SYNTAX,
NULL, "invalid bind dn", 0, NULL);
diff --git a/ldap/servers/slapd/log.c b/ldap/servers/slapd/log.c
index 83a445c..6be5b1e 100644
--- a/ldap/servers/slapd/log.c
+++ b/ldap/servers/slapd/log.c
@@ -1002,8 +1002,6 @@ log_set_rotationsynchour(const char *attrname, char *rhour_str, int logtype, cha
fe_cfg->auditlog_rotationsynchour = rhour;
LOG_AUDIT_UNLOCK_WRITE();
break;
- default:
- rv = 1;
}
return rv;
@@ -1056,8 +1054,6 @@ log_set_rotationsyncmin(const char *attrname, char *rmin_str, int logtype, char
loginfo.log_audit_rotationsyncclock = log_get_rotationsyncclock( loginfo.log_audit_rotationsynchour, rmin );
LOG_AUDIT_UNLOCK_WRITE();
break;
- default:
- rv = 1;
}
return rv;
@@ -1113,8 +1109,6 @@ log_set_rotationtime(const char *attrname, char *rtime_str, int logtype, char *r
loginfo.log_audit_rotationtime = rtime;
runit = loginfo.log_audit_rotationunit;
break;
- default:
- rv = 1;
}
/* find out the rotation unit we have se right now */
@@ -1142,19 +1136,17 @@ log_set_rotationtime(const char *attrname, char *rtime_str, int logtype, char *r
fe_cfg->accesslog_rotationtime = rtime;
loginfo.log_access_rotationtime_secs = value;
LOG_ACCESS_UNLOCK_WRITE();
- break;
+ break;
case SLAPD_ERROR_LOG:
fe_cfg->errorlog_rotationtime = rtime;
- loginfo.log_error_rotationtime_secs = value;
- LOG_ERROR_UNLOCK_WRITE();
- break;
+ loginfo.log_error_rotationtime_secs = value;
+ LOG_ERROR_UNLOCK_WRITE();
+ break;
case SLAPD_AUDIT_LOG:
fe_cfg->auditlog_rotationtime = rtime;
- loginfo.log_audit_rotationtime_secs = value;
- LOG_AUDIT_UNLOCK_WRITE();
- break;
- default:
- rv = 1;
+ loginfo.log_audit_rotationtime_secs = value;
+ LOG_AUDIT_UNLOCK_WRITE();
+ break;
}
return rv;
}
@@ -1210,8 +1202,6 @@ int log_set_rotationtimeunit(const char *attrname, char *runit, int logtype, cha
LOG_AUDIT_LOCK_WRITE( );
origvalue = loginfo.log_audit_rotationtime;
break;
- default:
- rv = 1;
}
if (strcasecmp(runit, "month") == 0) {
@@ -1261,8 +1251,6 @@ int log_set_rotationtimeunit(const char *attrname, char *runit, int logtype, cha
fe_cfg->auditlog_rotationunit = slapi_ch_strdup ( runit );
LOG_AUDIT_UNLOCK_WRITE();
break;
- default:
- rv = 1;
}
return rv;
}
@@ -1312,9 +1300,6 @@ log_set_maxdiskspace(const char *attrname, char *maxdiskspace_str, int logtype,
LOG_AUDIT_LOCK_WRITE( );
mlogsize = loginfo.log_audit_maxlogsize;
break;
- default:
- rv = 1;
- mlogsize = -1;
}
maxdiskspace = (PRInt64)s_maxdiskspace * LOG_MB_IN_BYTES;
if (maxdiskspace < 0) {
@@ -1348,11 +1333,6 @@ log_set_maxdiskspace(const char *attrname, char *maxdiskspace_str, int logtype,
}
LOG_AUDIT_UNLOCK_WRITE();
break;
- default:
- PR_snprintf( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "%s: invalid log type (%d) for setting maximum disk space: %d MB\n",
- attrname, logtype, s_maxdiskspace);
- rv = LDAP_OPERATIONS_ERROR;
}
return rv;
@@ -1572,10 +1552,6 @@ log_set_expirationtimeunit(const char *attrname, char *expunit, int logtype, cha
rsecs = loginfo.log_audit_rotationtime_secs;
exptimeunitp = &(loginfo.log_audit_exptimeunit);
break;
- default:
- rv = 1;
- exptime = -1;
- rsecs = -1;
}
value = -1;
@@ -1625,8 +1601,6 @@ log_set_expirationtimeunit(const char *attrname, char *expunit, int logtype, cha
fe_cfg->auditlog_exptimeunit = slapi_ch_strdup ( expunit );
LOG_AUDIT_UNLOCK_WRITE();
break;
- default:
- rv = 1;
}
return rv;
@@ -1748,8 +1722,8 @@ slapd_log_audit_proc (
char *buffer,
int buf_len)
{
- int err;
if ( (loginfo.log_audit_state & LOGGING_ENABLED) && (loginfo.log_audit_file != NULL) ){
+ int err;
LOG_AUDIT_LOCK_WRITE( );
if (log__needrotation(loginfo.log_audit_fdes,
SLAPD_AUDIT_LOG) == LOG_ROTATE) {
@@ -4168,9 +4142,9 @@ static void log_append_buffer2(time_t tnl, LogBufferInfo *lbi, char *msg1, size_
static void log_flush_buffer(LogBufferInfo *lbi, int type, int sync_now)
{
slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- int err = 0;
-
+
if (type == SLAPD_ACCESS_LOG) {
+ int err = 0;
/* It is only safe to flush once any other threads which are copying are finished */
while (lbi->refcount > 0) {
10 years, 10 months
Branch '389-ds-base-1.3.0' - ldap/servers
by Mark Reynolds
ldap/servers/plugins/collation/collate.c | 24 +++----
ldap/servers/plugins/replication/windows_protocol_util.c | 9 +-
ldap/servers/slapd/back-ldbm/index.c | 17 ++---
ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c | 24 +------
ldap/servers/slapd/back-ldbm/ldbm_search.c | 2
ldap/servers/slapd/back-ldbm/seq.c | 2
ldap/servers/slapd/bind.c | 2
ldap/servers/slapd/log.c | 46 +++------------
8 files changed, 40 insertions(+), 86 deletions(-)
New commits:
commit 15af6f7058032d5b55afd21e25beefb3ce4c6c21
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Tue Jun 4 13:25:22 2013 -0400
Coverity Fixes (Part 2)
11674 - logically dead code (collate.c)
11675 - logically dead code (windows_protocol_util.c)
11676 - logically dead code (index.c)
11677 - logically dead code (ldbm_entryrdn.c)
11678 - logically dead code (ldbm_entryrdn.c)
11680 - logically dead code (ldbm_search.c)
11681 - Dead default in switch (seq.c)
11683 - logically dead code (bind.c)
11684 - logically dead code (connection.c)
11686 - Dead default in switch (log.c)
11687 - Dead default in switch (log.c)
11688 - Dead default in switch (log.c)
11689 - Dead default in switch (log.c)
11690 - Dead default in switch (log.c)
11691 - Dead default in switch (log.c)
https://bugzilla.redhat.com/show_bug.cgi?id=970221
Reviewed by: nhosoi(Thanks!)
(cherry picked from commit db673270e9a01e48adb22d94e676f25a223f407b)
diff --git a/ldap/servers/plugins/collation/collate.c b/ldap/servers/plugins/collation/collate.c
index 240da70..2a73ee1 100644
--- a/ldap/servers/plugins/collation/collate.c
+++ b/ldap/servers/plugins/collation/collate.c
@@ -437,11 +437,7 @@ collation_indexer_create (const char* oid)
profile->variant == NULL);
UErrorCode err = U_ZERO_ERROR;
if ( ! is_default) {
- if (locale) {
- PR_smprintf_free(locale);
- locale = NULL;
- }
- err = s_newNamedLocaleFromComponents(&locale,
+ err = s_newNamedLocaleFromComponents(&locale,
profile->language,
profile->country,
profile->variant);
@@ -460,27 +456,27 @@ collation_indexer_create (const char* oid)
ucol_setAttribute (coll, UCOL_STRENGTH, profile->strength, &err);
if (err != U_ZERO_ERROR && err != U_USING_FALLBACK_WARNING
&& (err != U_USING_DEFAULT_WARNING || !is_default)) {
- LDAPDebug (LDAP_DEBUG_ANY, "collation_indexer_create: could not "
+ LDAPDebug (LDAP_DEBUG_ANY, "collation_indexer_create: could not "
"set the collator strength for oid %s to %d: err %d\n",
oid, profile->strength, err);
}
ucol_setAttribute (coll, UCOL_DECOMPOSITION_MODE, profile->decomposition, &err);
if (err != U_ZERO_ERROR && err != U_USING_FALLBACK_WARNING
&& (err != U_USING_DEFAULT_WARNING || !is_default)) {
- LDAPDebug (LDAP_DEBUG_ANY, "collation_indexer_create: could not "
+ LDAPDebug (LDAP_DEBUG_ANY, "collation_indexer_create: could not "
"set the collator decomposition mode for oid %s to %d: err %d\n",
oid, profile->decomposition, err);
}
etc->collator = coll;
for (id = collation_id; *id; ++id) {
- if ((*id)->profile == profile) {
- break; /* found the 'official' id */
- }
+ if ((*id)->profile == profile) {
+ break; /* found the 'official' id */
+ }
}
- if (!*id) {
- LDAPDebug (LDAP_DEBUG_ANY, "collation_indexer_create: id not found\n", 0, 0, 0);
- goto error;
- }
+ if (!*id) {
+ LDAPDebug (LDAP_DEBUG_ANY, "collation_indexer_create: id not found\n", 0, 0, 0);
+ goto error;
+ }
ix->ix_etc = etc;
ix->ix_oid = (*id)->oid;
diff --git a/ldap/servers/plugins/replication/windows_protocol_util.c b/ldap/servers/plugins/replication/windows_protocol_util.c
index 03d6ff3..964566a 100644
--- a/ldap/servers/plugins/replication/windows_protocol_util.c
+++ b/ldap/servers/plugins/replication/windows_protocol_util.c
@@ -4249,7 +4249,7 @@ windows_generate_update_mods(Private_Repl_Protocol *prp,Slapi_Entry *remote_entr
windows_is_remote_entry_user_or_group(remote_entry,&is_user,&is_group);
}
- for (rc = slapi_entry_first_attr(remote_entry, &attr); rc == 0;
+ for (rc = slapi_entry_first_attr(remote_entry, &attr); rc == 0;
rc = slapi_entry_next_attr(remote_entry, attr, &attr))
{
int is_present_local = 0;
@@ -4260,7 +4260,6 @@ windows_generate_update_mods(Private_Repl_Protocol *prp,Slapi_Entry *remote_entr
int is_guid = 0;
int mapdn = 0;
-
slapi_attr_get_type( attr, &type );
slapi_attr_get_valueset(attr,&vs);
@@ -4419,7 +4418,7 @@ windows_generate_update_mods(Private_Repl_Protocol *prp,Slapi_Entry *remote_entr
"windows_generate_update_mods: no restricted local values found for "
"local attribute %s in local entry %s for remote attribute "
"%s in remote entry %s\n",
- local_type ? local_type : "NULL",
+ local_type,
slapi_entry_get_dn(local_entry),
type ? type : "NULL",
slapi_entry_get_dn(remote_entry));
@@ -4431,7 +4430,7 @@ windows_generate_update_mods(Private_Repl_Protocol *prp,Slapi_Entry *remote_entr
"windows_generate_update_mods: no local values found for "
"local attribute %s in local entry %s for remote attribute "
"%s in remote entry %s\n",
- local_type ? local_type : "NULL",
+ local_type,
slapi_entry_get_dn(local_entry),
type ? type : "NULL",
slapi_entry_get_dn(remote_entry));
@@ -4443,7 +4442,7 @@ windows_generate_update_mods(Private_Repl_Protocol *prp,Slapi_Entry *remote_entr
"windows_generate_update_mods: could not map the values in "
"local attribute %s in local entry %s for remote attribute "
"%s in remote entry %s\n",
- local_type ? local_type : "NULL",
+ local_type,
slapi_entry_get_dn(local_entry),
type ? type : "NULL",
slapi_entry_get_dn(remote_entry));
diff --git a/ldap/servers/slapd/back-ldbm/index.c b/ldap/servers/slapd/back-ldbm/index.c
index 5948717..f90a47c 100644
--- a/ldap/servers/slapd/back-ldbm/index.c
+++ b/ldap/servers/slapd/back-ldbm/index.c
@@ -649,18 +649,17 @@ index_add_mods(
mods[i]->mod_op |= LDAP_MOD_IGNORE;
}
}
- if (mods_valueArray) {
- rc = index_addordel_values_sv( be,
- mods[i]->mod_type,
- mods_valueArray, NULL,
- id, BE_INDEX_ADD, txn );
- if (rc) {
- ldbm_nasty(errmsg, 1042, rc);
- goto error;
- }
+ if(mods_valueArray[0]){
+ rc = index_addordel_values_sv( be, mods[i]->mod_type,
+ mods_valueArray, NULL,
+ id, BE_INDEX_ADD, txn );
} else {
rc = 0;
}
+ if (rc) {
+ ldbm_nasty(errmsg, 1042, rc);
+ goto error;
+ }
}
}
break;
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c b/ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c
index 82806db..1b74fa0 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c
@@ -809,14 +809,8 @@ entryrdn_rename_subtree(backend *be,
renamedata.data = (void *)oldsupelem;
}
} else {
- if (mynewsupsdn) {
- renamedata.ulen = renamedata.size = newsupelemlen;
- renamedata.data = (void *)newsupelem;
- } else {
- /* never comes here */
- rc = -1;
- goto bail;
- }
+ renamedata.ulen = renamedata.size = newsupelemlen;
+ renamedata.data = (void *)newsupelem;
}
rc = _entryrdn_put_data(cursor, &key, &renamedata, RDN_INDEX_PARENT, db_txn);
if (rc) {
@@ -901,16 +895,10 @@ entryrdn_rename_subtree(backend *be,
renamedata.data = (void *)targetelem;
}
} else {
- if (mynewsrdn) {
- memset(&renamedata, 0, sizeof(renamedata));
- renamedata.ulen = renamedata.size = newelemlen;
- renamedata.data = (void *)newelem;
- renamedata.flags = DB_DBT_USERMEM;
- } else {
- /* never comes here */
- rc = -1;
- goto bail;
- }
+ memset(&renamedata, 0, sizeof(renamedata));
+ renamedata.ulen = renamedata.size = newelemlen;
+ renamedata.data = (void *)newelem;
+ renamedata.flags = DB_DBT_USERMEM;
}
rc = _entryrdn_put_data(cursor, &key, &renamedata, RDN_INDEX_CHILD, db_txn);
if (rc) {
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_search.c b/ldap/servers/slapd/back-ldbm/ldbm_search.c
index 059a151..c4d3797 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_search.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_search.c
@@ -581,7 +581,7 @@ ldbm_back_search( Slapi_PBlock *pb )
/* This candidate list is for vlv, no need for sort only. */
switch (vlv_search_build_candidate_list(pb, basesdn, &vlv_rc,
sort_control,
- (vlv ? &vlv_request_control : NULL),
+ &vlv_request_control,
&candidates, &vlv_response_control)) {
case VLV_ACCESS_DENIED:
return ldbm_back_search_cleanup(pb, li, sort_control,
diff --git a/ldap/servers/slapd/back-ldbm/seq.c b/ldap/servers/slapd/back-ldbm/seq.c
index 1435ba2..ab473bd 100644
--- a/ldap/servers/slapd/back-ldbm/seq.c
+++ b/ldap/servers/slapd/back-ldbm/seq.c
@@ -221,8 +221,6 @@ ldbm_back_seq( Slapi_PBlock *pb )
}
}
break;
- default:
- PR_ASSERT(0);
}
dbc->c_close(dbc);
diff --git a/ldap/servers/slapd/bind.c b/ldap/servers/slapd/bind.c
index e92add5..ec874cc 100644
--- a/ldap/servers/slapd/bind.c
+++ b/ldap/servers/slapd/bind.c
@@ -178,7 +178,7 @@ do_bind( Slapi_PBlock *pb )
/* check that the dn is formatted correctly */
rc = slapi_dn_syntax_check(pb, rawdn, 1);
if (rc) { /* syntax check failed */
- op_shared_log_error_access(pb, "BIND", rawdn?rawdn:"",
+ op_shared_log_error_access(pb, "BIND", rawdn,
"strict: invalid bind dn");
send_ldap_result(pb, LDAP_INVALID_DN_SYNTAX,
NULL, "invalid bind dn", 0, NULL);
diff --git a/ldap/servers/slapd/log.c b/ldap/servers/slapd/log.c
index f483a57..0cf08f0 100644
--- a/ldap/servers/slapd/log.c
+++ b/ldap/servers/slapd/log.c
@@ -1002,8 +1002,6 @@ log_set_rotationsynchour(const char *attrname, char *rhour_str, int logtype, cha
fe_cfg->auditlog_rotationsynchour = rhour;
LOG_AUDIT_UNLOCK_WRITE();
break;
- default:
- rv = 1;
}
return rv;
@@ -1056,8 +1054,6 @@ log_set_rotationsyncmin(const char *attrname, char *rmin_str, int logtype, char
loginfo.log_audit_rotationsyncclock = log_get_rotationsyncclock( loginfo.log_audit_rotationsynchour, rmin );
LOG_AUDIT_UNLOCK_WRITE();
break;
- default:
- rv = 1;
}
return rv;
@@ -1113,8 +1109,6 @@ log_set_rotationtime(const char *attrname, char *rtime_str, int logtype, char *r
loginfo.log_audit_rotationtime = rtime;
runit = loginfo.log_audit_rotationunit;
break;
- default:
- rv = 1;
}
/* find out the rotation unit we have se right now */
@@ -1142,19 +1136,17 @@ log_set_rotationtime(const char *attrname, char *rtime_str, int logtype, char *r
fe_cfg->accesslog_rotationtime = rtime;
loginfo.log_access_rotationtime_secs = value;
LOG_ACCESS_UNLOCK_WRITE();
- break;
+ break;
case SLAPD_ERROR_LOG:
fe_cfg->errorlog_rotationtime = rtime;
- loginfo.log_error_rotationtime_secs = value;
- LOG_ERROR_UNLOCK_WRITE();
- break;
+ loginfo.log_error_rotationtime_secs = value;
+ LOG_ERROR_UNLOCK_WRITE();
+ break;
case SLAPD_AUDIT_LOG:
fe_cfg->auditlog_rotationtime = rtime;
- loginfo.log_audit_rotationtime_secs = value;
- LOG_AUDIT_UNLOCK_WRITE();
- break;
- default:
- rv = 1;
+ loginfo.log_audit_rotationtime_secs = value;
+ LOG_AUDIT_UNLOCK_WRITE();
+ break;
}
return rv;
}
@@ -1210,8 +1202,6 @@ int log_set_rotationtimeunit(const char *attrname, char *runit, int logtype, cha
LOG_AUDIT_LOCK_WRITE( );
origvalue = loginfo.log_audit_rotationtime;
break;
- default:
- rv = 1;
}
if (strcasecmp(runit, "month") == 0) {
@@ -1261,8 +1251,6 @@ int log_set_rotationtimeunit(const char *attrname, char *runit, int logtype, cha
fe_cfg->auditlog_rotationunit = slapi_ch_strdup ( runit );
LOG_AUDIT_UNLOCK_WRITE();
break;
- default:
- rv = 1;
}
return rv;
}
@@ -1312,9 +1300,6 @@ log_set_maxdiskspace(const char *attrname, char *maxdiskspace_str, int logtype,
LOG_AUDIT_LOCK_WRITE( );
mlogsize = loginfo.log_audit_maxlogsize;
break;
- default:
- rv = 1;
- mlogsize = -1;
}
maxdiskspace = (PRInt64)s_maxdiskspace * LOG_MB_IN_BYTES;
if (maxdiskspace < 0) {
@@ -1348,11 +1333,6 @@ log_set_maxdiskspace(const char *attrname, char *maxdiskspace_str, int logtype,
}
LOG_AUDIT_UNLOCK_WRITE();
break;
- default:
- PR_snprintf( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "%s: invalid log type (%d) for setting maximum disk space: %d MB\n",
- attrname, logtype, s_maxdiskspace);
- rv = LDAP_OPERATIONS_ERROR;
}
return rv;
@@ -1572,10 +1552,6 @@ log_set_expirationtimeunit(const char *attrname, char *expunit, int logtype, cha
rsecs = loginfo.log_audit_rotationtime_secs;
exptimeunitp = &(loginfo.log_audit_exptimeunit);
break;
- default:
- rv = 1;
- exptime = -1;
- rsecs = -1;
}
value = -1;
@@ -1625,8 +1601,6 @@ log_set_expirationtimeunit(const char *attrname, char *expunit, int logtype, cha
fe_cfg->auditlog_exptimeunit = slapi_ch_strdup ( expunit );
LOG_AUDIT_UNLOCK_WRITE();
break;
- default:
- rv = 1;
}
return rv;
@@ -1748,8 +1722,8 @@ slapd_log_audit_proc (
char *buffer,
int buf_len)
{
- int err;
if ( (loginfo.log_audit_state & LOGGING_ENABLED) && (loginfo.log_audit_file != NULL) ){
+ int err;
LOG_AUDIT_LOCK_WRITE( );
if (log__needrotation(loginfo.log_audit_fdes,
SLAPD_AUDIT_LOG) == LOG_ROTATE) {
@@ -4168,9 +4142,9 @@ static void log_append_buffer2(time_t tnl, LogBufferInfo *lbi, char *msg1, size_
static void log_flush_buffer(LogBufferInfo *lbi, int type, int sync_now)
{
slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- int err = 0;
-
+
if (type == SLAPD_ACCESS_LOG) {
+ int err = 0;
/* It is only safe to flush once any other threads which are copying are finished */
while (lbi->refcount > 0) {
10 years, 10 months
Branch '389-ds-base-1.3.1' - ldap/servers
by Mark Reynolds
ldap/servers/plugins/collation/collate.c | 24 +++----
ldap/servers/plugins/replication/windows_protocol_util.c | 9 +-
ldap/servers/slapd/back-ldbm/index.c | 17 ++---
ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c | 24 +------
ldap/servers/slapd/back-ldbm/ldbm_search.c | 2
ldap/servers/slapd/back-ldbm/seq.c | 2
ldap/servers/slapd/bind.c | 2
ldap/servers/slapd/log.c | 46 +++------------
8 files changed, 40 insertions(+), 86 deletions(-)
New commits:
commit 46e4297f97b4be7a43b087b37e857ee48b0354ff
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Tue Jun 4 13:25:22 2013 -0400
Coverity Fixes (Part 2)
11674 - logically dead code (collate.c)
11675 - logically dead code (windows_protocol_util.c)
11676 - logically dead code (index.c)
11677 - logically dead code (ldbm_entryrdn.c)
11678 - logically dead code (ldbm_entryrdn.c)
11680 - logically dead code (ldbm_search.c)
11681 - Dead default in switch (seq.c)
11683 - logically dead code (bind.c)
11684 - logically dead code (connection.c)
11686 - Dead default in switch (log.c)
11687 - Dead default in switch (log.c)
11688 - Dead default in switch (log.c)
11689 - Dead default in switch (log.c)
11690 - Dead default in switch (log.c)
11691 - Dead default in switch (log.c)
https://bugzilla.redhat.com/show_bug.cgi?id=970221
Reviewed by: nhosoi(Thanks!)
(cherry picked from commit db673270e9a01e48adb22d94e676f25a223f407b)
diff --git a/ldap/servers/plugins/collation/collate.c b/ldap/servers/plugins/collation/collate.c
index 240da70..2a73ee1 100644
--- a/ldap/servers/plugins/collation/collate.c
+++ b/ldap/servers/plugins/collation/collate.c
@@ -437,11 +437,7 @@ collation_indexer_create (const char* oid)
profile->variant == NULL);
UErrorCode err = U_ZERO_ERROR;
if ( ! is_default) {
- if (locale) {
- PR_smprintf_free(locale);
- locale = NULL;
- }
- err = s_newNamedLocaleFromComponents(&locale,
+ err = s_newNamedLocaleFromComponents(&locale,
profile->language,
profile->country,
profile->variant);
@@ -460,27 +456,27 @@ collation_indexer_create (const char* oid)
ucol_setAttribute (coll, UCOL_STRENGTH, profile->strength, &err);
if (err != U_ZERO_ERROR && err != U_USING_FALLBACK_WARNING
&& (err != U_USING_DEFAULT_WARNING || !is_default)) {
- LDAPDebug (LDAP_DEBUG_ANY, "collation_indexer_create: could not "
+ LDAPDebug (LDAP_DEBUG_ANY, "collation_indexer_create: could not "
"set the collator strength for oid %s to %d: err %d\n",
oid, profile->strength, err);
}
ucol_setAttribute (coll, UCOL_DECOMPOSITION_MODE, profile->decomposition, &err);
if (err != U_ZERO_ERROR && err != U_USING_FALLBACK_WARNING
&& (err != U_USING_DEFAULT_WARNING || !is_default)) {
- LDAPDebug (LDAP_DEBUG_ANY, "collation_indexer_create: could not "
+ LDAPDebug (LDAP_DEBUG_ANY, "collation_indexer_create: could not "
"set the collator decomposition mode for oid %s to %d: err %d\n",
oid, profile->decomposition, err);
}
etc->collator = coll;
for (id = collation_id; *id; ++id) {
- if ((*id)->profile == profile) {
- break; /* found the 'official' id */
- }
+ if ((*id)->profile == profile) {
+ break; /* found the 'official' id */
+ }
}
- if (!*id) {
- LDAPDebug (LDAP_DEBUG_ANY, "collation_indexer_create: id not found\n", 0, 0, 0);
- goto error;
- }
+ if (!*id) {
+ LDAPDebug (LDAP_DEBUG_ANY, "collation_indexer_create: id not found\n", 0, 0, 0);
+ goto error;
+ }
ix->ix_etc = etc;
ix->ix_oid = (*id)->oid;
diff --git a/ldap/servers/plugins/replication/windows_protocol_util.c b/ldap/servers/plugins/replication/windows_protocol_util.c
index 03d6ff3..964566a 100644
--- a/ldap/servers/plugins/replication/windows_protocol_util.c
+++ b/ldap/servers/plugins/replication/windows_protocol_util.c
@@ -4249,7 +4249,7 @@ windows_generate_update_mods(Private_Repl_Protocol *prp,Slapi_Entry *remote_entr
windows_is_remote_entry_user_or_group(remote_entry,&is_user,&is_group);
}
- for (rc = slapi_entry_first_attr(remote_entry, &attr); rc == 0;
+ for (rc = slapi_entry_first_attr(remote_entry, &attr); rc == 0;
rc = slapi_entry_next_attr(remote_entry, attr, &attr))
{
int is_present_local = 0;
@@ -4260,7 +4260,6 @@ windows_generate_update_mods(Private_Repl_Protocol *prp,Slapi_Entry *remote_entr
int is_guid = 0;
int mapdn = 0;
-
slapi_attr_get_type( attr, &type );
slapi_attr_get_valueset(attr,&vs);
@@ -4419,7 +4418,7 @@ windows_generate_update_mods(Private_Repl_Protocol *prp,Slapi_Entry *remote_entr
"windows_generate_update_mods: no restricted local values found for "
"local attribute %s in local entry %s for remote attribute "
"%s in remote entry %s\n",
- local_type ? local_type : "NULL",
+ local_type,
slapi_entry_get_dn(local_entry),
type ? type : "NULL",
slapi_entry_get_dn(remote_entry));
@@ -4431,7 +4430,7 @@ windows_generate_update_mods(Private_Repl_Protocol *prp,Slapi_Entry *remote_entr
"windows_generate_update_mods: no local values found for "
"local attribute %s in local entry %s for remote attribute "
"%s in remote entry %s\n",
- local_type ? local_type : "NULL",
+ local_type,
slapi_entry_get_dn(local_entry),
type ? type : "NULL",
slapi_entry_get_dn(remote_entry));
@@ -4443,7 +4442,7 @@ windows_generate_update_mods(Private_Repl_Protocol *prp,Slapi_Entry *remote_entr
"windows_generate_update_mods: could not map the values in "
"local attribute %s in local entry %s for remote attribute "
"%s in remote entry %s\n",
- local_type ? local_type : "NULL",
+ local_type,
slapi_entry_get_dn(local_entry),
type ? type : "NULL",
slapi_entry_get_dn(remote_entry));
diff --git a/ldap/servers/slapd/back-ldbm/index.c b/ldap/servers/slapd/back-ldbm/index.c
index a10c67a..e45aba8 100644
--- a/ldap/servers/slapd/back-ldbm/index.c
+++ b/ldap/servers/slapd/back-ldbm/index.c
@@ -649,18 +649,17 @@ index_add_mods(
mods[i]->mod_op |= LDAP_MOD_IGNORE;
}
}
- if (mods_valueArray) {
- rc = index_addordel_values_sv( be,
- mods[i]->mod_type,
- mods_valueArray, NULL,
- id, BE_INDEX_ADD, txn );
- if (rc) {
- ldbm_nasty(errmsg, 1042, rc);
- goto error;
- }
+ if(mods_valueArray[0]){
+ rc = index_addordel_values_sv( be, mods[i]->mod_type,
+ mods_valueArray, NULL,
+ id, BE_INDEX_ADD, txn );
} else {
rc = 0;
}
+ if (rc) {
+ ldbm_nasty(errmsg, 1042, rc);
+ goto error;
+ }
}
}
break;
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c b/ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c
index a3ea091..57b3a20 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_entryrdn.c
@@ -810,14 +810,8 @@ entryrdn_rename_subtree(backend *be,
renamedata.data = (void *)oldsupelem;
}
} else {
- if (mynewsupsdn) {
- renamedata.ulen = renamedata.size = newsupelemlen;
- renamedata.data = (void *)newsupelem;
- } else {
- /* never comes here */
- rc = -1;
- goto bail;
- }
+ renamedata.ulen = renamedata.size = newsupelemlen;
+ renamedata.data = (void *)newsupelem;
}
rc = _entryrdn_put_data(cursor, &key, &renamedata, RDN_INDEX_PARENT, db_txn);
if (rc) {
@@ -902,16 +896,10 @@ entryrdn_rename_subtree(backend *be,
renamedata.data = (void *)targetelem;
}
} else {
- if (mynewsrdn) {
- memset(&renamedata, 0, sizeof(renamedata));
- renamedata.ulen = renamedata.size = newelemlen;
- renamedata.data = (void *)newelem;
- renamedata.flags = DB_DBT_USERMEM;
- } else {
- /* never comes here */
- rc = -1;
- goto bail;
- }
+ memset(&renamedata, 0, sizeof(renamedata));
+ renamedata.ulen = renamedata.size = newelemlen;
+ renamedata.data = (void *)newelem;
+ renamedata.flags = DB_DBT_USERMEM;
}
rc = _entryrdn_put_data(cursor, &key, &renamedata, RDN_INDEX_CHILD, db_txn);
if (rc) {
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_search.c b/ldap/servers/slapd/back-ldbm/ldbm_search.c
index be4b63c..a84689c 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_search.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_search.c
@@ -620,7 +620,7 @@ ldbm_back_search( Slapi_PBlock *pb )
/* This candidate list is for vlv, no need for sort only. */
switch (vlv_search_build_candidate_list(pb, basesdn, &vlv_rc,
sort_control,
- (vlv ? &vlv_request_control : NULL),
+ &vlv_request_control,
&candidates, &vlv_response_control)) {
case VLV_ACCESS_DENIED:
return ldbm_back_search_cleanup(pb, li, sort_control,
diff --git a/ldap/servers/slapd/back-ldbm/seq.c b/ldap/servers/slapd/back-ldbm/seq.c
index 1435ba2..ab473bd 100644
--- a/ldap/servers/slapd/back-ldbm/seq.c
+++ b/ldap/servers/slapd/back-ldbm/seq.c
@@ -221,8 +221,6 @@ ldbm_back_seq( Slapi_PBlock *pb )
}
}
break;
- default:
- PR_ASSERT(0);
}
dbc->c_close(dbc);
diff --git a/ldap/servers/slapd/bind.c b/ldap/servers/slapd/bind.c
index e92add5..ec874cc 100644
--- a/ldap/servers/slapd/bind.c
+++ b/ldap/servers/slapd/bind.c
@@ -178,7 +178,7 @@ do_bind( Slapi_PBlock *pb )
/* check that the dn is formatted correctly */
rc = slapi_dn_syntax_check(pb, rawdn, 1);
if (rc) { /* syntax check failed */
- op_shared_log_error_access(pb, "BIND", rawdn?rawdn:"",
+ op_shared_log_error_access(pb, "BIND", rawdn,
"strict: invalid bind dn");
send_ldap_result(pb, LDAP_INVALID_DN_SYNTAX,
NULL, "invalid bind dn", 0, NULL);
diff --git a/ldap/servers/slapd/log.c b/ldap/servers/slapd/log.c
index f483a57..0cf08f0 100644
--- a/ldap/servers/slapd/log.c
+++ b/ldap/servers/slapd/log.c
@@ -1002,8 +1002,6 @@ log_set_rotationsynchour(const char *attrname, char *rhour_str, int logtype, cha
fe_cfg->auditlog_rotationsynchour = rhour;
LOG_AUDIT_UNLOCK_WRITE();
break;
- default:
- rv = 1;
}
return rv;
@@ -1056,8 +1054,6 @@ log_set_rotationsyncmin(const char *attrname, char *rmin_str, int logtype, char
loginfo.log_audit_rotationsyncclock = log_get_rotationsyncclock( loginfo.log_audit_rotationsynchour, rmin );
LOG_AUDIT_UNLOCK_WRITE();
break;
- default:
- rv = 1;
}
return rv;
@@ -1113,8 +1109,6 @@ log_set_rotationtime(const char *attrname, char *rtime_str, int logtype, char *r
loginfo.log_audit_rotationtime = rtime;
runit = loginfo.log_audit_rotationunit;
break;
- default:
- rv = 1;
}
/* find out the rotation unit we have se right now */
@@ -1142,19 +1136,17 @@ log_set_rotationtime(const char *attrname, char *rtime_str, int logtype, char *r
fe_cfg->accesslog_rotationtime = rtime;
loginfo.log_access_rotationtime_secs = value;
LOG_ACCESS_UNLOCK_WRITE();
- break;
+ break;
case SLAPD_ERROR_LOG:
fe_cfg->errorlog_rotationtime = rtime;
- loginfo.log_error_rotationtime_secs = value;
- LOG_ERROR_UNLOCK_WRITE();
- break;
+ loginfo.log_error_rotationtime_secs = value;
+ LOG_ERROR_UNLOCK_WRITE();
+ break;
case SLAPD_AUDIT_LOG:
fe_cfg->auditlog_rotationtime = rtime;
- loginfo.log_audit_rotationtime_secs = value;
- LOG_AUDIT_UNLOCK_WRITE();
- break;
- default:
- rv = 1;
+ loginfo.log_audit_rotationtime_secs = value;
+ LOG_AUDIT_UNLOCK_WRITE();
+ break;
}
return rv;
}
@@ -1210,8 +1202,6 @@ int log_set_rotationtimeunit(const char *attrname, char *runit, int logtype, cha
LOG_AUDIT_LOCK_WRITE( );
origvalue = loginfo.log_audit_rotationtime;
break;
- default:
- rv = 1;
}
if (strcasecmp(runit, "month") == 0) {
@@ -1261,8 +1251,6 @@ int log_set_rotationtimeunit(const char *attrname, char *runit, int logtype, cha
fe_cfg->auditlog_rotationunit = slapi_ch_strdup ( runit );
LOG_AUDIT_UNLOCK_WRITE();
break;
- default:
- rv = 1;
}
return rv;
}
@@ -1312,9 +1300,6 @@ log_set_maxdiskspace(const char *attrname, char *maxdiskspace_str, int logtype,
LOG_AUDIT_LOCK_WRITE( );
mlogsize = loginfo.log_audit_maxlogsize;
break;
- default:
- rv = 1;
- mlogsize = -1;
}
maxdiskspace = (PRInt64)s_maxdiskspace * LOG_MB_IN_BYTES;
if (maxdiskspace < 0) {
@@ -1348,11 +1333,6 @@ log_set_maxdiskspace(const char *attrname, char *maxdiskspace_str, int logtype,
}
LOG_AUDIT_UNLOCK_WRITE();
break;
- default:
- PR_snprintf( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,
- "%s: invalid log type (%d) for setting maximum disk space: %d MB\n",
- attrname, logtype, s_maxdiskspace);
- rv = LDAP_OPERATIONS_ERROR;
}
return rv;
@@ -1572,10 +1552,6 @@ log_set_expirationtimeunit(const char *attrname, char *expunit, int logtype, cha
rsecs = loginfo.log_audit_rotationtime_secs;
exptimeunitp = &(loginfo.log_audit_exptimeunit);
break;
- default:
- rv = 1;
- exptime = -1;
- rsecs = -1;
}
value = -1;
@@ -1625,8 +1601,6 @@ log_set_expirationtimeunit(const char *attrname, char *expunit, int logtype, cha
fe_cfg->auditlog_exptimeunit = slapi_ch_strdup ( expunit );
LOG_AUDIT_UNLOCK_WRITE();
break;
- default:
- rv = 1;
}
return rv;
@@ -1748,8 +1722,8 @@ slapd_log_audit_proc (
char *buffer,
int buf_len)
{
- int err;
if ( (loginfo.log_audit_state & LOGGING_ENABLED) && (loginfo.log_audit_file != NULL) ){
+ int err;
LOG_AUDIT_LOCK_WRITE( );
if (log__needrotation(loginfo.log_audit_fdes,
SLAPD_AUDIT_LOG) == LOG_ROTATE) {
@@ -4168,9 +4142,9 @@ static void log_append_buffer2(time_t tnl, LogBufferInfo *lbi, char *msg1, size_
static void log_flush_buffer(LogBufferInfo *lbi, int type, int sync_now)
{
slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
- int err = 0;
-
+
if (type == SLAPD_ACCESS_LOG) {
+ int err = 0;
/* It is only safe to flush once any other threads which are copying are finished */
while (lbi->refcount > 0) {
10 years, 10 months