From 97da9cb32b41d87d9dc5930a2ad931df559ae7f5 Mon Sep 17 00:00:00 2001
From: Noriko Hosoi <nhosoi@redhat.com>
Date: Tue, 23 Jun 2015 14:48:13 -0700
Subject: [PATCH 1/2] Ticket #48203 - Fix coverity issues - 06/22/2015
Description:
13294 Uninitialized scalar variable -- retrocl_init_trimming (introduced by #47669)
13293 Resource leak -- retrocl_init_trimming (introduced by #47669)
2. Defect type: CHECKED_RETURN
50. ldap/servers/slapd/tools/ldclt/ldapfct.c:1945:
9. ldap/servers/slapd/tools/ldclt/ldapfct.c:952:
check_return: Calling "addErrorStat" without checking return value
(as is done elsewhere 26 out of 28 times).
1. Defect type: COMPILER_WARNING
2. ldap/servers/slapd/daemon.c:1412:21:
warning: 'tp' may be used uninitialized in this function [-Wmaybe-uninitialized]
https://fedorahosted.org/389/ticket/48203
Reviewed by rmeggins@redhat.com (Thank you, Rich!!)
(cherry picked from commit 32d45c74231545ad91934147962bfb676dcdd391)
---
ldap/servers/plugins/retrocl/retrocl_trim.c | 3 ++-
ldap/servers/slapd/daemon.c | 2 +-
ldap/servers/slapd/tools/ldclt/ldapfct.c | 4 ++--
3 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/ldap/servers/plugins/retrocl/retrocl_trim.c b/ldap/servers/plugins/retrocl/retrocl_trim.c
index 65f3015..b09f669 100644
--- a/ldap/servers/plugins/retrocl/retrocl_trim.c
+++ b/ldap/servers/plugins/retrocl/retrocl_trim.c
@@ -412,7 +412,7 @@ void retrocl_housekeeping ( time_t cur_time, void *noarg )
void retrocl_init_trimming (void)
{
const char *cl_maxage;
- time_t ageval;
+ time_t ageval = 0; /* Don't trim, by default */
const char *cl_trim_interval;
cl_maxage = retrocl_get_config_str(CONFIG_CHANGELOG_MAXAGE_ATTRIBUTE);
@@ -425,6 +425,7 @@ void retrocl_init_trimming (void)
"retrocl_init_trimming: ignoring invalid %s value %s; "
"not trimming retro changelog.\n",
CONFIG_CHANGELOG_MAXAGE_ATTRIBUTE, cl_maxage);
+ slapi_ch_free_string((char **)&cl_maxage);
return;
}
}
diff --git a/ldap/servers/slapd/daemon.c b/ldap/servers/slapd/daemon.c
index 436f3d5..ba73da3 100644
--- a/ldap/servers/slapd/daemon.c
+++ b/ldap/servers/slapd/daemon.c
@@ -1026,7 +1026,7 @@ void slapd_daemon( daemon_ports_t *ports )
int threads;
int in_referral_mode = config_check_referral_mode();
#ifdef ENABLE_NUNC_STANS
- ns_thrpool_t *tp;
+ ns_thrpool_t *tp = NULL;
struct ns_thrpool_config tp_config;
#endif
int connection_table_size = get_configured_connection_table_size();
diff --git a/ldap/servers/slapd/tools/ldclt/ldapfct.c b/ldap/servers/slapd/tools/ldclt/ldapfct.c
index bc8c89d..f906c5a 100644
--- a/ldap/servers/slapd/tools/ldclt/ldapfct.c
+++ b/ldap/servers/slapd/tools/ldclt/ldapfct.c
@@ -949,7 +949,7 @@ connectToServer (
fprintf (stderr, "ldclt[%d]: T%03d: cannot ldap_unbind(), error=%d (%s)\n",
mctx.pid, tttctx->thrdNum, ret,strerror (ret));
fflush (stderr);
- addErrorStat(ret);
+ (void)addErrorStat(ret);
return (-1);
}
tttctx->ldapCtx = NULL;
@@ -1942,7 +1942,7 @@ createMissingNodes (
printf ("ldclt[%d]: T%03d: Cannot add (%s), error=%d (%s)\n",
mctx.pid, tttctx->thrdNum, nodeDN, ret, my_ldap_err2string (ret));
fflush (stdout);
- addErrorStat(ret);
+ (void)addErrorStat(ret);
return (-1);
}
--
1.9.3