summaryrefslogtreecommitdiffstats
path: root/ldap
diff options
context:
space:
mode:
authorRich Megginson <rmeggins@redhat.com>2010-07-06 16:47:45 -0600
committerRich Megginson <rmeggins@redhat.com>2010-07-06 17:41:20 -0600
commit85eb9216d5d4163139a90432084452cf81c8444e (patch)
treea1f1306ce6cb9f2d346eaddefcf75a29d29f91f0 /ldap
parent7a9c069a7d64c1370353278c34bf9065aeb604ea (diff)
downloadds-85eb9216d5d4163139a90432084452cf81c8444e.tar.gz
ds-85eb9216d5d4163139a90432084452cf81c8444e.tar.xz
ds-85eb9216d5d4163139a90432084452cf81c8444e.zip
Bug 611850 - fix coverity Defect Type: Error handling issues
https://bugzilla.redhat.com/show_bug.cgi?id=611850 Resolves: bug 611850 Bug Description: fix coverity Defect Type: Error handling issues Reviewed by: nhosoi (Thanks!) Branch: HEAD Fix Description: Check the error return from the functions. In some cases, I was able to figure out that the calling function should perform additional error handling (return early, goto error label), but in general the code just logs an appropriate error message and continues. I was able to get rid of some more libacl code. I removed an unused variable from modify.c Platforms tested: RHEL5 x86_64 Flag Day: no Doc impact: no
Diffstat (limited to 'ldap')
-rw-r--r--ldap/servers/plugins/chainingdb/cb_controls.c7
-rw-r--r--ldap/servers/plugins/replication/cl5_api.c6
-rw-r--r--ldap/servers/plugins/replication/windows_connection.c20
-rw-r--r--ldap/servers/slapd/back-ldbm/archive.c28
-rw-r--r--ldap/servers/slapd/back-ldbm/misc.c5
-rw-r--r--ldap/servers/slapd/eventq.c4
-rw-r--r--ldap/servers/slapd/modify.c1
-rw-r--r--ldap/servers/snmp/main.c5
8 files changed, 65 insertions, 11 deletions
diff --git a/ldap/servers/plugins/chainingdb/cb_controls.c b/ldap/servers/plugins/chainingdb/cb_controls.c
index ca64595c..142284a9 100644
--- a/ldap/servers/plugins/chainingdb/cb_controls.c
+++ b/ldap/servers/plugins/chainingdb/cb_controls.c
@@ -224,12 +224,15 @@ int cb_update_controls( Slapi_PBlock * pb,
if (!strcmp(reqControls[cCount]->ldctl_oid,CB_LDAP_CONTROL_CHAIN_SERVER)) {
/* Max hop count reached ? */
- /* Checked realier by a call to cb_forward_operation() */
+ /* Checked earlier by a call to cb_forward_operation() */
BerElement *ber = NULL;
ber = ber_init(&(reqControls[cCount]->ldctl_value));
- ber_scanf(ber,"i",&hops);
+ if (LBER_ERROR == ber_scanf(ber,"i",&hops)) {
+ slapi_log_error( SLAPI_LOG_PLUGIN,CB_PLUGIN_SUBSYSTEM,
+ "Unable to get number of hops from the chaining control\n");
+ }
ber_free(ber,1);
useloop=1;
diff --git a/ldap/servers/plugins/replication/cl5_api.c b/ldap/servers/plugins/replication/cl5_api.c
index b4ec5e45..56cc9711 100644
--- a/ldap/servers/plugins/replication/cl5_api.c
+++ b/ldap/servers/plugins/replication/cl5_api.c
@@ -1475,7 +1475,11 @@ int cl5ConfigTrimming (int maxEntries, const char *maxAge)
/* make sure changelog is not closed while trimming configuration
is updated.*/
- _cl5AddThread ();
+ if (CL5_SUCCESS != _cl5AddThread ()) {
+ slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl,
+ "cl5ConfigTrimming: could not start changelog trimming thread\n");
+ return CL5_BAD_STATE;
+ }
PR_Lock (s_cl5Desc.dbTrim.lock);
diff --git a/ldap/servers/plugins/replication/windows_connection.c b/ldap/servers/plugins/replication/windows_connection.c
index 8aabfdbb..2e24bfed 100644
--- a/ldap/servers/plugins/replication/windows_connection.c
+++ b/ldap/servers/plugins/replication/windows_connection.c
@@ -885,7 +885,10 @@ Slapi_Entry * windows_conn_get_search_result(Repl_Connection *conn)
LDAPControl **returned_controls = NULL;
int code = 0;
/* Purify says this is a leak : */
- ldap_parse_result( conn->ld, res, &code, NULL, NULL, NULL, &returned_controls, 0 );
+ if (LDAP_SUCCESS != (rc = ldap_parse_result( conn->ld, res, &code, NULL, NULL, NULL, &returned_controls, 0 ))) {
+ slapi_log_error(SLAPI_LOG_FATAL, windows_repl_plugin_name,
+ "error reading search result in windows_conn_get_search_result, rc=%d:%s\n", rc, ldap_err2string(rc));
+ }
if (returned_controls)
{
windows_private_update_dirsync_control(conn->agmt, returned_controls);
@@ -1818,7 +1821,20 @@ windows_check_user_password(Repl_Connection *conn, Slapi_DN *sdn, char *password
/* Attempt to do a bind on the existing connection
* using the dn and password that were passed in. */
msgid = do_simple_bind(conn, conn->ld, (char *) binddn, password);
- ldap_result(conn->ld, msgid, LDAP_MSG_ALL, NULL, &res);
+ rc = ldap_result(conn->ld, msgid, LDAP_MSG_ALL, NULL, &res);
+ if (0 > rc) { /* error */
+ rc = slapi_ldap_get_lderrno(conn->ld, NULL, NULL);
+ slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name,
+ "Error reading bind response for id "
+ "[%s]: error %d (%s)\n",
+ binddn ? binddn : "(anon)",
+ rc, ldap_err2string(rc));
+ } else if (rc == 0) { /* timeout */
+ slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name,
+ "Error: timeout reading "
+ "bind response for [%s]\n",
+ binddn ? binddn : "(anon)");
+ }
ldap_parse_result( conn->ld, res, &rc, NULL, NULL, NULL, NULL, 1 /* Free res */);
/* rebind as the DN specified in the sync agreement */
diff --git a/ldap/servers/slapd/back-ldbm/archive.c b/ldap/servers/slapd/back-ldbm/archive.c
index 1f3587a7..54274539 100644
--- a/ldap/servers/slapd/back-ldbm/archive.c
+++ b/ldap/servers/slapd/back-ldbm/archive.c
@@ -235,7 +235,15 @@ int ldbm_back_archive2ldbm( Slapi_PBlock *pb )
if (0 != return_value) {
/* error case (607331)
* just to go back to the previous state if possible */
- dblayer_start(li, DBLAYER_NORMAL_MODE);
+ if ((return_value = dblayer_start(li, DBLAYER_NORMAL_MODE))) {
+ LDAPDebug1Arg(LDAP_DEBUG_ANY,
+ "archive2db: Unable to to start database in [%s]\n", li->li_directory);
+ if (task) {
+ slapi_task_log_notice(task, "Failed to start the database in "
+ "%s", li->li_directory);
+ }
+ goto out;
+ }
}
/* bring all backends back online */
for (inst_obj = objset_first_obj(li->li_instance_set); inst_obj;
@@ -441,7 +449,23 @@ err:
dir_bak, directory);
}
ldbm_delete_dirs(directory);
- PR_Rename(dir_bak, directory);
+ if (PR_SUCCESS != PR_Rename(dir_bak, directory)) {
+ PRErrorCode prerr = PR_GetError();
+ LDAPDebug(LDAP_DEBUG_ANY,
+ "db2archive: Failed to rename \"%s\" to \"%s\".\n",
+ dir_bak, directory, 0);
+ LDAPDebug(LDAP_DEBUG_ANY,
+ SLAPI_COMPONENT_NAME_NSPR " error %d (%s)\n",
+ prerr, slapd_pr_strerror(prerr), 0);
+ if (task) {
+ slapi_task_log_notice(task,
+ "Failed to rename \"%s\" to \"%s\".",
+ dir_bak, directory);
+ slapi_task_log_notice(task,
+ SLAPI_COMPONENT_NAME_NSPR " error %d (%s)",
+ prerr, slapd_pr_strerror(prerr));
+ }
+ }
}
out:
/* close the database down again */
diff --git a/ldap/servers/slapd/back-ldbm/misc.c b/ldap/servers/slapd/back-ldbm/misc.c
index ad7128de..2bcdd9d9 100644
--- a/ldap/servers/slapd/back-ldbm/misc.c
+++ b/ldap/servers/slapd/back-ldbm/misc.c
@@ -245,7 +245,10 @@ allinstance_set_busy(struct ldbminfo *li)
for (inst_obj = objset_first_obj(li->li_instance_set); inst_obj;
inst_obj = objset_next_obj(li->li_instance_set, inst_obj)) {
inst = (ldbm_instance *)object_get_data(inst_obj);
- instance_set_busy(inst);
+ if (instance_set_busy(inst)) {
+ LDAPDebug1Arg(LDAP_DEBUG_TRACE, "could not set instance [%s] as busy, probably already busy\n",
+ inst->inst_name);
+ }
}
if (inst_obj)
object_release(inst_obj);
diff --git a/ldap/servers/slapd/eventq.c b/ldap/servers/slapd/eventq.c
index 6870ecc2..c5fa1200 100644
--- a/ldap/servers/slapd/eventq.c
+++ b/ldap/servers/slapd/eventq.c
@@ -435,7 +435,9 @@ void
eq_init()
{
if (!eq_initialized) {
- PR_CallOnce(&init_once, eq_create);
+ if (PR_SUCCESS != PR_CallOnce(&init_once, eq_create)) {
+ slapi_log_error(SLAPI_LOG_FATAL, NULL, "eq_init - eq_create failed\n");
+ }
}
}
diff --git a/ldap/servers/slapd/modify.c b/ldap/servers/slapd/modify.c
index 3f78b019..55308a30 100644
--- a/ldap/servers/slapd/modify.c
+++ b/ldap/servers/slapd/modify.c
@@ -573,7 +573,6 @@ static void op_shared_modify (Slapi_PBlock *pb, int pw_change, char *old_pw)
Slapi_Backend *be = NULL;
Slapi_Entry *pse;
Slapi_Entry *referral;
- Slapi_Entry *ecopy = NULL;
Slapi_Entry *e = NULL;
char ebuf[BUFSIZ];
char *dn;
diff --git a/ldap/servers/snmp/main.c b/ldap/servers/snmp/main.c
index 04c4ee3f..a216d34d 100644
--- a/ldap/servers/snmp/main.c
+++ b/ldap/servers/snmp/main.c
@@ -411,7 +411,10 @@ load_config(char *conf_path)
int vlen;
#endif
/* Check if this is the cn=config entry */
- ldif_parse_line(ldif_getline(&entryp), &attr, &val, &vlen);
+ if (ldif_parse_line(ldif_getline(&entryp), &attr, &val, &vlen)) {
+ printf("ldap-agent: error parsing ldif line from [%s]\n", serv_p->dse_ldif);
+ }
+
if ((strcmp(attr, "dn") == 0) &&
(strcmp(val, "cn=config") == 0)) {
char *dse_line = NULL;