ldap/servers lib/libaccess
by Richard Allen Megginson
ldap/servers/plugins/acct_usability/acct_usability.c | 2 -
ldap/servers/plugins/acl/acl_ext.c | 2 -
ldap/servers/plugins/acl/aclutil.c | 3 +
ldap/servers/plugins/automember/automember.c | 3 +
ldap/servers/plugins/deref/deref.c | 2 -
ldap/servers/plugins/http/http_impl.c | 4 +-
ldap/servers/plugins/pam_passthru/pam_ptimpl.c | 2 -
ldap/servers/plugins/referint/referint.c | 2 -
ldap/servers/plugins/replication/cl5_api.c | 20 ++++++------
ldap/servers/plugins/replication/repl5_replica.c | 8 ++--
ldap/servers/plugins/replication/windows_inc_protocol.c | 2 -
ldap/servers/plugins/replication/windows_private.c | 9 ++++-
ldap/servers/plugins/usn/usn.c | 4 +-
ldap/servers/slapd/attrsyntax.c | 4 --
ldap/servers/slapd/back-ldbm/import-threads.c | 2 -
ldap/servers/slapd/back-ldbm/monitor.c | 18 +++++------
ldap/servers/slapd/log.c | 26 +++++++++-------
ldap/servers/slapd/mapping_tree.c | 6 +++
ldap/servers/slapd/regex.c | 10 ++++--
ldap/servers/slapd/slapi-plugin.h | 9 +++++
ldap/servers/slapd/tools/ldclt/ldapfct.c | 5 ---
ldap/servers/slapd/tools/rsearch/infadd.c | 7 +---
ldap/servers/snmp/main.c | 13 +++++++-
lib/libaccess/acltools.cpp | 2 -
lib/libaccess/lasdns.cpp | 1
lib/libaccess/register.cpp | 10 +++---
26 files changed, 104 insertions(+), 72 deletions(-)
New commits:
commit 97ce027162c2b07c9b40273e317a9a15fda7ba74
Author: Rich Megginson <rmeggins(a)redhat.com>
Date: Wed Jun 5 11:30:13 2013 -0600
Ticket #47378 - fix recent compiler warnings
https://fedorahosted.org/389/ticket/47378
Reviewed by: nhosoi (Thanks!)
Branch: master
Fix Description: Fix the various compiler warnings as reported by
http://jenkins.cloud.fedoraproject.org/job/389-ds-base/ws/build-warns.137...
In addition, fixed a bug in the slapi_re_subs_ext - if there was an
ampersand that did not need to be replaced, that is, if the ampersand
was part of an LDAP search filter, it was replaced with a '('. Also, an
ampersand preceeded by an open parenthesis and followed by a non-open
parenthesis is supposed to be replaced in the string, but this was not
working.
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: no
diff --git a/ldap/servers/plugins/acct_usability/acct_usability.c b/ldap/servers/plugins/acct_usability/acct_usability.c
index 19e55c3..f41f934 100644
--- a/ldap/servers/plugins/acct_usability/acct_usability.c
+++ b/ldap/servers/plugins/acct_usability/acct_usability.c
@@ -312,7 +312,7 @@ auc_pre_search(Slapi_PBlock *pb)
int ldapcode = LDAP_SUCCESS;
const LDAPControl **reqctrls = NULL;
const LDAPControl *aucctrl = NULL;
- const char *ldaperrtext;
+ const char *ldaperrtext = "Unknown error";
const char *incompatible = NULL;
int isroot = 0;
int ii;
diff --git a/ldap/servers/plugins/acl/acl_ext.c b/ldap/servers/plugins/acl/acl_ext.c
index b3f9072..c1b6b4a 100644
--- a/ldap/servers/plugins/acl/acl_ext.c
+++ b/ldap/servers/plugins/acl/acl_ext.c
@@ -128,7 +128,7 @@ acl_get_ext (ext_type type, void *object)
void
acl_set_ext (ext_type type, void *object, void *data)
{
- if ( type >= 0 && type < ACL_EXT_ALL )
+ if ( type < ACL_EXT_ALL )
{
struct acl_ext ext = acl_ext_list [type];
slapi_set_object_extension ( ext.object_type, object, ext.handle, data );
diff --git a/ldap/servers/plugins/acl/aclutil.c b/ldap/servers/plugins/acl/aclutil.c
index 7097540..5969b26 100644
--- a/ldap/servers/plugins/acl/aclutil.c
+++ b/ldap/servers/plugins/acl/aclutil.c
@@ -96,6 +96,7 @@ aclutil_str_append_ext(char **dest, size_t *dlen, const char *src, size_t slen)
char *ptr = NULL;
int rc = 0;
+ PR_ASSERT(NULL != dlen);
if ( dest == NULL || src == NULL ) {
return rc;
}
@@ -103,7 +104,7 @@ aclutil_str_append_ext(char **dest, size_t *dlen, const char *src, size_t slen)
if (0 == slen) {
slen = strlen(src);
}
- if (*dest && dlen > 0) {
+ if (*dest && *dlen > 0) {
size_t dest_strlen = strlen(*dest);
size_t new_len = dest_strlen + slen + 1;
if (new_len > *dlen) {
diff --git a/ldap/servers/plugins/automember/automember.c b/ldap/servers/plugins/automember/automember.c
index 424b507..49f47f7 100644
--- a/ldap/servers/plugins/automember/automember.c
+++ b/ldap/servers/plugins/automember/automember.c
@@ -2522,10 +2522,11 @@ void automember_map_task_thread(void *arg){
#if defined(USE_OPENLDAP)
int buflen = 0;
LDIFFP *ldif_fd_in = NULL;
+ ldif_record_lineno_t lineno = 0;
#else
PRFileDesc *ldif_fd_in = NULL;
-#endif
int lineno = 0;
+#endif
int rc = 0;
td = (task_data *)slapi_task_get_data(task);
diff --git a/ldap/servers/plugins/deref/deref.c b/ldap/servers/plugins/deref/deref.c
index 2601170..8414452 100644
--- a/ldap/servers/plugins/deref/deref.c
+++ b/ldap/servers/plugins/deref/deref.c
@@ -441,7 +441,7 @@ deref_pre_search(Slapi_PBlock *pb)
int ldapcode = LDAP_SUCCESS;
const LDAPControl **reqctrls = NULL;
const LDAPControl *derefctrl = NULL;
- const char *ldaperrtext;
+ const char *ldaperrtext = "Unknown error";
const char *incompatible = NULL;
DerefSpecList *speclist = NULL;
int ii;
diff --git a/ldap/servers/plugins/http/http_impl.c b/ldap/servers/plugins/http/http_impl.c
index f96d75a..db02b67 100644
--- a/ldap/servers/plugins/http/http_impl.c
+++ b/ldap/servers/plugins/http/http_impl.c
@@ -260,7 +260,7 @@ static int doRequest(const char *url, httpheader **httpheaderArray, char *body,
PRInt32 port;
PRInt32 errcode = 0;
PRInt32 http_connection_time_out = 0;
- PRInt32 sslOn;
+ PRInt32 sslOn = 0;
LDAPDebug( LDAP_DEBUG_PLUGIN, "--> doRequest -- BEGIN\n",0,0,0);
@@ -1178,7 +1178,7 @@ SECStatus
struct SECKEYPrivateKeyStr **pRetKey)
{
CERTCertificate * cert;
- SECKEYPrivateKey * privKey;
+ SECKEYPrivateKey * privKey = NULL;
char * chosenNickName = (char *)arg;
void * proto_win = NULL;
SECStatus secStatus = SECFailure;
diff --git a/ldap/servers/plugins/pam_passthru/pam_ptimpl.c b/ldap/servers/plugins/pam_passthru/pam_ptimpl.c
index 69c08e8..2558b9e 100644
--- a/ldap/servers/plugins/pam_passthru/pam_ptimpl.c
+++ b/ldap/servers/plugins/pam_passthru/pam_ptimpl.c
@@ -263,7 +263,7 @@ do_one_pam_auth(
MyStrBuf pam_id;
const char *binddn = NULL;
Slapi_DN *bindsdn = NULL;
- int rc;
+ int rc = PAM_SUCCESS;
int retcode = LDAP_SUCCESS;
pam_handle_t *pam_handle;
struct my_pam_conv_str my_data;
diff --git a/ldap/servers/plugins/referint/referint.c b/ldap/servers/plugins/referint/referint.c
index beb5f9f..234c322 100644
--- a/ldap/servers/plugins/referint/referint.c
+++ b/ldap/servers/plugins/referint/referint.c
@@ -921,7 +921,7 @@ int referint_postop_close( Slapi_PBlock *pb)
void
referint_thread_func(void *arg)
{
- PRFileDesc *prfd;
+ PRFileDesc *prfd = NULL;
char **plugin_argv = (char **)arg;
char *logfilename;
char thisline[MAX_LINE];
diff --git a/ldap/servers/plugins/replication/cl5_api.c b/ldap/servers/plugins/replication/cl5_api.c
index 63b2b99..b29fa2e 100644
--- a/ldap/servers/plugins/replication/cl5_api.c
+++ b/ldap/servers/plugins/replication/cl5_api.c
@@ -277,8 +277,8 @@ static CL5Desc s_cl5Desc;
/* changelog initialization and cleanup */
static int _cl5Open (const char *dir, const CL5DBConfig *config, CL5OpenMode openMode);
-static int _cl5AppInit (PRBool *didRecovery);
-static int _cl5DBOpen ();
+static int _cl5AppInit (void);
+static int _cl5DBOpen (void);
static void _cl5SetDefaultDBConfig ();
static void _cl5SetDBConfig (const CL5DBConfig *config);
static int _cl5CheckDBVersion ();
@@ -882,12 +882,13 @@ cl5ImportLDIF (const char *clDir, const char *ldifFile, Object **replicas)
#if defined(USE_OPENLDAP)
LDIFFP *file = NULL;
int buflen;
+ ldif_record_lineno_t lineno = 0;
#else
FILE *file = NULL;
+ int lineno = 0;
#endif
int rc;
char *buff = NULL;
- int lineno = 0;
slapi_operation_parameters op;
Object *prim_replica_obj = NULL;
Object *replica_obj = NULL;
@@ -1856,7 +1857,6 @@ int cl5GetOperationCount (Object *replica)
static int _cl5Open (const char *dir, const CL5DBConfig *config, CL5OpenMode openMode)
{
int rc;
- PRBool didRecovery;
PR_ASSERT (dir);
@@ -1904,7 +1904,7 @@ static int _cl5Open (const char *dir, const CL5DBConfig *config, CL5OpenMode ope
s_cl5Desc.dbOpenMode = openMode;
/* initialize db environment */
- rc = _cl5AppInit (&didRecovery);
+ rc = _cl5AppInit ();
if (rc != CL5_SUCCESS)
{
slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl,
@@ -1919,7 +1919,7 @@ static int _cl5Open (const char *dir, const CL5DBConfig *config, CL5OpenMode ope
}
/* open database files */
- rc = _cl5DBOpen (!didRecovery);
+ rc = _cl5DBOpen ();
if (rc != CL5_SUCCESS)
{
slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl,
@@ -1995,7 +1995,7 @@ int cl5CreateDirIfNeeded (const char *dirName)
return CL5_SUCCESS;
}
-static int _cl5AppInit (PRBool *didRecovery)
+static int _cl5AppInit (void)
{
int rc = -1; /* initialize to failure */
DB_ENV *dbEnv = NULL;
@@ -2889,7 +2889,7 @@ static int _cl5UpgradeMajor(char *fromVersion, char *toVersion)
backup = s_cl5Desc.dbOpenMode;
s_cl5Desc.dbOpenMode = CL5_OPEN_CLEAN_RECOVER;
/* CL5_OPEN_CLEAN_RECOVER does 1 and 2 */
- rc = _cl5AppInit (NULL);
+ rc = _cl5AppInit ();
if (rc != CL5_SUCCESS)
{
slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl,
@@ -2984,7 +2984,7 @@ static int _cl5UpgradeMinor(char *fromVersion, char *toVersion)
backup = s_cl5Desc.dbOpenMode;
s_cl5Desc.dbOpenMode = CL5_OPEN_CLEAN_RECOVER;
/* CL5_OPEN_CLEAN_RECOVER does 1 and 2 */
- rc = _cl5AppInit (NULL);
+ rc = _cl5AppInit ();
if (rc != CL5_SUCCESS)
{
slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl,
@@ -4264,7 +4264,7 @@ static int _cl5Operation2LDIF (const slapi_operation_parameters *op, const char
int len = 2;
lenstr *l = NULL;
const char *strType;
- char *strDeleteOldRDN;
+ const char *strDeleteOldRDN = "false";
char *buff, *start;
LDAPMod **add_mods;
char *rawDN = NULL;
diff --git a/ldap/servers/plugins/replication/repl5_replica.c b/ldap/servers/plugins/replication/repl5_replica.c
index 6c73d05..f9914e4 100644
--- a/ldap/servers/plugins/replication/repl5_replica.c
+++ b/ldap/servers/plugins/replication/repl5_replica.c
@@ -104,7 +104,7 @@ typedef struct reap_callback_data
/* Forward declarations of helper functions*/
-static Slapi_Entry* _replica_get_config_entry (const Slapi_DN *root, char **attrs);
+static Slapi_Entry* _replica_get_config_entry (const Slapi_DN *root, const char **attrs);
static int _replica_check_validity (const Replica *r);
static int _replica_init_from_config (Replica *r, Slapi_Entry *e, char *errortext);
static int _replica_update_entry (Replica *r, Slapi_Entry *e, char *errortext);
@@ -1556,7 +1556,7 @@ int replica_check_for_data_reload (Replica *r, void *arg)
mapping tree node for the replica's backend */
static Slapi_Entry*
-_replica_get_config_entry (const Slapi_DN *root, char **attrs)
+_replica_get_config_entry (const Slapi_DN *root, const char **attrs)
{
int rc = 0;
char *dn = NULL;
@@ -1573,7 +1573,7 @@ _replica_get_config_entry (const Slapi_DN *root, char **attrs)
}
pb = slapi_pblock_new ();
- slapi_search_internal_set_pb (pb, dn, LDAP_SCOPE_BASE, "objectclass=*", attrs, 0, NULL,
+ slapi_search_internal_set_pb (pb, dn, LDAP_SCOPE_BASE, "objectclass=*", (char **)attrs, 0, NULL,
NULL, repl_get_plugin_identity (PLUGIN_MULTIMASTER_REPLICATION), 0);
slapi_search_internal_pb (pb);
slapi_pblock_get(pb, SLAPI_PLUGIN_INTOP_RESULT, &rc);
@@ -1596,7 +1596,7 @@ _replica_get_config_entry (const Slapi_DN *root, char **attrs)
Slapi_Entry *
get_in_memory_ruv(Slapi_DN *suffix_sdn)
{
- char *attrs[3];
+ const char *attrs[3];
/* these two attributes needs to be asked when reading the RUV */
attrs[0] = type_ruvElement;
diff --git a/ldap/servers/plugins/replication/windows_inc_protocol.c b/ldap/servers/plugins/replication/windows_inc_protocol.c
index e503f30..58f48f2 100644
--- a/ldap/servers/plugins/replication/windows_inc_protocol.c
+++ b/ldap/servers/plugins/replication/windows_inc_protocol.c
@@ -1174,7 +1174,7 @@ send_updates(Private_Repl_Protocol *prp, RUV *remote_update_vector, PRUint32 *nu
{
CL5Entry entry;
slapi_operation_parameters op;
- int return_value;
+ int return_value = UPDATE_NO_MORE_UPDATES;
int rc;
int set_mincsn = 0;
CL5ReplayIterator *changelog_iterator = NULL;
diff --git a/ldap/servers/plugins/replication/windows_private.c b/ldap/servers/plugins/replication/windows_private.c
index 3bdd0c1..e0dc8ca 100644
--- a/ldap/servers/plugins/replication/windows_private.c
+++ b/ldap/servers/plugins/replication/windows_private.c
@@ -1355,11 +1355,16 @@ windows_plugin_init(Repl_Agmt *ra)
{
struct winsync_plugin_cookie *list = NULL;
void *cookie = NULL;
- PRStatus rv;
LDAPDebug0Args( LDAP_DEBUG_PLUGIN, "--> windows_plugin_init_start -- begin\n");
- rv = PR_CallOnce(&winsync_callOnce, windows_plugin_callonce);
+ if (PR_CallOnce(&winsync_callOnce, windows_plugin_callonce)) {
+ PRErrorCode prerr = PR_GetError();
+ slapi_log_error(SLAPI_LOG_FATAL, "windows_plugin_init",
+ "cannot initialize plugin: %d:%s\n", prerr,
+ slapi_pr_strerror(prerr));
+ return;
+ }
/* call each plugin init function in turn - store the returned cookie
indexed by the api */
diff --git a/ldap/servers/plugins/usn/usn.c b/ldap/servers/plugins/usn/usn.c
index 0273fd1..4473618 100644
--- a/ldap/servers/plugins/usn/usn.c
+++ b/ldap/servers/plugins/usn/usn.c
@@ -673,7 +673,7 @@ usn_rootdse_search(Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry* entryAfter,
if (be && be->be_usn_counter) {
/* get a next USN counter from be_usn_counter;
* then minus 1 from it */
- PR_snprintf(usn_berval.bv_val, USN_COUNTER_BUF_LEN, "%" NSPRI64 "d",
+ PR_snprintf(usn_berval.bv_val, USN_COUNTER_BUF_LEN, "%" NSPRIu64,
slapi_counter_get_value(be->be_usn_counter)-1);
usn_berval.bv_len = strlen(usn_berval.bv_val);
slapi_entry_attr_replace(e, attr, vals);
@@ -692,7 +692,7 @@ usn_rootdse_search(Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry* entryAfter,
}
/* get a next USN counter from be_usn_counter;
* then minus 1 from it */
- PR_snprintf(usn_berval.bv_val, USN_COUNTER_BUF_LEN, "%" NSPRI64 "d",
+ PR_snprintf(usn_berval.bv_val, USN_COUNTER_BUF_LEN, "%" NSPRIu64,
slapi_counter_get_value(be->be_usn_counter)-1);
usn_berval.bv_len = strlen(usn_berval.bv_val);
diff --git a/ldap/servers/slapd/attrsyntax.c b/ldap/servers/slapd/attrsyntax.c
index 05aca7d..82adad4 100644
--- a/ldap/servers/slapd/attrsyntax.c
+++ b/ldap/servers/slapd/attrsyntax.c
@@ -1229,15 +1229,11 @@ slapi_add_internal_attr_syntax( const char *name, const char *oid,
int rc = LDAP_SUCCESS;
struct asyntaxinfo *asip;
char *names[2];
- char *origins[2];
unsigned long std_flags = SLAPI_ATTR_FLAG_STD_ATTR | SLAPI_ATTR_FLAG_OPATTR;
names[0] = (char *)name;
names[1] = NULL;
- origins[0] = SLAPD_VERSION_STR;
- origins[1] = NULL;
-
rc = attr_syntax_create( oid, names,
"internal server defined attribute type",
NULL, /* superior */
diff --git a/ldap/servers/slapd/back-ldbm/import-threads.c b/ldap/servers/slapd/back-ldbm/import-threads.c
index 3828080..d9ab51f 100644
--- a/ldap/servers/slapd/back-ldbm/import-threads.c
+++ b/ldap/servers/slapd/back-ldbm/import-threads.c
@@ -3985,7 +3985,7 @@ _get_import_entryusn(ImportJob *job, Slapi_Value **usn_value)
* Use the counter which stores the old DB's
* next entryusn. */
PR_snprintf(counter_buf, USN_COUNTER_BUF_LEN,
- "%" NSPRI64 "d",
+ "%" NSPRIu64,
slapi_counter_get_value(be->be_usn_counter));
} else {
/* import_init value is digit.
diff --git a/ldap/servers/slapd/back-ldbm/monitor.c b/ldap/servers/slapd/back-ldbm/monitor.c
index 1a06a25..49edb68 100644
--- a/ldap/servers/slapd/back-ldbm/monitor.c
+++ b/ldap/servers/slapd/back-ldbm/monitor.c
@@ -238,13 +238,13 @@ int ldbm_back_monitor_instance_search(Slapi_PBlock *pb, Slapi_Entry *e,
#endif
MSETF("dbFilename-%d", i);
- sprintf(buf, "%u", mpfstat[i]->st_cache_hit);
+ sprintf(buf, "%lu", (unsigned long)mpfstat[i]->st_cache_hit);
MSETF("dbFileCacheHit-%d", i);
- sprintf(buf, "%u", mpfstat[i]->st_cache_miss);
+ sprintf(buf, "%lu", (unsigned long)mpfstat[i]->st_cache_miss);
MSETF("dbFileCacheMiss-%d", i);
- sprintf(buf, "%u", mpfstat[i]->st_page_in);
+ sprintf(buf, "%lu", (unsigned long)mpfstat[i]->st_page_in);
MSETF("dbFilePageIn-%d", i);
- sprintf(buf, "%u", mpfstat[i]->st_page_out);
+ sprintf(buf, "%lu", (unsigned long)mpfstat[i]->st_page_out);
MSETF("dbFilePageOut-%d", i);
slapi_ch_free_string(&absolute_pathname);
@@ -291,7 +291,7 @@ int ldbm_back_monitor_search(Slapi_PBlock *pb, Slapi_Entry *e,
}
/* cache hits*/
- sprintf(buf, "%u", mpstat->st_cache_hit);
+ sprintf(buf, "%lu", (unsigned long)mpstat->st_cache_hit);
MSET("dbCacheHits");
/* cache tries*/
@@ -303,13 +303,13 @@ int ldbm_back_monitor_search(Slapi_PBlock *pb, Slapi_Entry *e,
sprintf(buf, "%lu", (unsigned long)(100.0 * (double)mpstat->st_cache_hit / (double)(cache_tries > 0 ? cache_tries : 1) ));
MSET("dbCacheHitRatio");
- sprintf(buf, "%u", mpstat->st_page_in);
+ sprintf(buf, "%lu", (unsigned long)mpstat->st_page_in);
MSET("dbCachePageIn");
- sprintf(buf, "%u", mpstat->st_page_out);
+ sprintf(buf, "%lu", (unsigned long)mpstat->st_page_out);
MSET("dbCachePageOut");
- sprintf(buf, "%u", mpstat->st_ro_evict);
+ sprintf(buf, "%lu", (unsigned long)mpstat->st_ro_evict);
MSET("dbCacheROEvict");
- sprintf(buf, "%u", mpstat->st_rw_evict);
+ sprintf(buf, "%lu", (unsigned long)mpstat->st_rw_evict);
MSET("dbCacheRWEvict");
slapi_ch_free((void **)&mpstat);
diff --git a/ldap/servers/slapd/log.c b/ldap/servers/slapd/log.c
index cab82d5..5873c11 100644
--- a/ldap/servers/slapd/log.c
+++ b/ldap/servers/slapd/log.c
@@ -207,6 +207,15 @@ slapd_log_error_proc_internal(
/* Should be a flush in here ?? Yes because PR_SYNC doesn't work ! */ \
PR_Sync(fd); \
} while (0)
+#define LOG_WRITE_NOW_NO_ERR(fd, buffer, size, headersize) do {\
+ if ( slapi_write_buffer((fd), (buffer), (size)) != (size) ) \
+ { \
+ PRErrorCode prerr = PR_GetError(); \
+ syslog(LOG_ERR, "Failed to write log, " SLAPI_COMPONENT_NAME_NSPR " error %d (%s): %s\n", prerr, slapd_pr_strerror(prerr), (buffer)+(headersize) ); \
+ } \
+ /* Should be a flush in here ?? Yes because PR_SYNC doesn't work ! */ \
+ PR_Sync(fd); \
+ } while (0)
#define LOG_CLOSE(fd) \
PR_Close((fd))
#endif
@@ -1267,7 +1276,7 @@ int
log_set_maxdiskspace(const char *attrname, char *maxdiskspace_str, int logtype, char *errorbuf, int apply)
{
int rv = 0;
- PRInt64 mlogsize; /* in bytes */
+ PRInt64 mlogsize = 0; /* in bytes */
PRInt64 maxdiskspace; /* in bytes */
int s_maxdiskspace; /* in megabytes */
@@ -1500,7 +1509,7 @@ log_set_expirationtimeunit(const char *attrname, char *expunit, int logtype, cha
{
int value = 0;
int rv = 0;
- int exptime, rsecs;
+ int exptime = 0, rsecs = 0;
int *exptimeunitp = NULL;
slapdFrontendConfig_t *fe_cfg = getFrontendConfig();
@@ -1616,12 +1625,11 @@ log_write_title (LOGFD fp)
char *buildnum = config_get_buildnum();
char buff[512];
int bufflen = sizeof(buff);
- int err = 0;
PR_snprintf(buff, bufflen, "\t%s B%s\n",
fe_cfg->versionstring ? fe_cfg->versionstring : CAPBRAND "-Directory/" DS_PACKAGE_VERSION,
buildnum ? buildnum : "");
- LOG_WRITE_NOW(fp, buff, strlen(buff), 0, err);
+ LOG_WRITE_NOW_NO_ERR(fp, buff, strlen(buff), 0);
if (fe_cfg->localhost) {
PR_snprintf(buff, bufflen, "\t%s:%d (%s)\n\n",
@@ -1636,7 +1644,7 @@ log_write_title (LOGFD fp)
PR_snprintf(buff, bufflen, "\t<host>:<port> (%s)\n\n",
fe_cfg->configdir ? fe_cfg->configdir : "");
}
- LOG_WRITE_NOW(fp, buff, strlen(buff), 0, err);
+ LOG_WRITE_NOW_NO_ERR(fp, buff, strlen(buff), 0);
slapi_ch_free((void **)&buildnum);
}
@@ -1723,7 +1731,6 @@ slapd_log_audit_proc (
int buf_len)
{
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) {
@@ -1742,7 +1749,7 @@ slapd_log_audit_proc (
log_write_title( loginfo.log_audit_fdes);
loginfo.log_audit_state &= ~LOGGING_NEED_TITLE;
}
- LOG_WRITE_NOW(loginfo.log_audit_fdes, buffer, buf_len, 0, err);
+ LOG_WRITE_NOW_NO_ERR(loginfo.log_audit_fdes, buffer, buf_len, 0);
LOG_AUDIT_UNLOCK_WRITE();
return 0;
}
@@ -4144,7 +4151,6 @@ static void log_flush_buffer(LogBufferInfo *lbi, int type, int sync_now)
slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
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) {
@@ -4175,8 +4181,8 @@ static void log_flush_buffer(LogBufferInfo *lbi, int type, int sync_now)
if (!sync_now && slapdFrontendConfig->accesslogbuffering) {
LOG_WRITE(loginfo.log_access_fdes, lbi->top, lbi->current - lbi->top, 0);
} else {
- LOG_WRITE_NOW(loginfo.log_access_fdes, lbi->top,
- lbi->current - lbi->top, 0, err);
+ LOG_WRITE_NOW_NO_ERR(loginfo.log_access_fdes, lbi->top,
+ lbi->current - lbi->top, 0);
}
lbi->current = lbi->top;
diff --git a/ldap/servers/slapd/mapping_tree.c b/ldap/servers/slapd/mapping_tree.c
index 5de0e46..9336d7c 100644
--- a/ldap/servers/slapd/mapping_tree.c
+++ b/ldap/servers/slapd/mapping_tree.c
@@ -158,8 +158,10 @@ static mapping_tree_node *
static int _mtn_update_config_param(int op, char *type, char *strvalue);
#ifdef DEBUG
+#ifdef USE_DUMP_MAPPING_TREE
static void dump_mapping_tree(mapping_tree_node *parent, int depth);
#endif
+#endif
/* structure and static local variable used to store the
* list of plugins that have registered to a callback when backend state
@@ -3721,6 +3723,7 @@ void test_register()
#endif
#ifdef DEBUG
+#ifdef USE_DUMP_MAPPING_TREE
static void dump_mapping_tree(mapping_tree_node *parent, int depth)
{
mapping_tree_node *current = NULL;
@@ -3751,7 +3754,8 @@ static void dump_mapping_tree(mapping_tree_node *parent, int depth)
}
return;
}
-#endif
+#endif /* USE_DUMP_MAPPING_TREE */
+#endif /* DEBUG */
/* helper function to set/remove the config param in cn=config */
static int
diff --git a/ldap/servers/slapd/regex.c b/ldap/servers/slapd/regex.c
index 3697fde..29edffe 100644
--- a/ldap/servers/slapd/regex.c
+++ b/ldap/servers/slapd/regex.c
@@ -161,7 +161,7 @@ slapi_re_subs_ext( Slapi_Regex *re_handle, const char *subject,
int pin;
int *ovector;
char *mydst;
- const char *prev, *next;
+ const char *prev;
const char *substring_start;
const char *p;
@@ -179,8 +179,7 @@ slapi_re_subs_ext( Slapi_Regex *re_handle, const char *subject,
for (p = src; *p != '\0'; p++) {
if ('&' == *p) {
/* Don't replace '&' if it's a filter AND: "(&(cn=a)(sn=b))" */
- next = p;
- if(!filter || (*prev != '(' && *next++ != '(')){
+ if(!filter || !(*prev == '(' && *(p+1) == '(')){
if (re_handle->re_oveccount <= 1) {
memset(*dst, '\0', dstlen);
return -1;
@@ -188,6 +187,11 @@ slapi_re_subs_ext( Slapi_Regex *re_handle, const char *subject,
substring_start = subject + ovector[0];
thislen = ovector[1] - ovector[0];
len += thislen;
+ } else { /* is a filter AND clause */
+ /* just copy it into the filter */
+ substring_start = p;
+ thislen = 1;
+ len++;
}
} else if (('\\' == *p) && ('0' <= *(p+1) && *(p+1) <= '9')) {
pin = *(++p) - '0';
diff --git a/ldap/servers/slapd/slapi-plugin.h b/ldap/servers/slapd/slapi-plugin.h
index ee209d2..ba8b6e6 100644
--- a/ldap/servers/slapd/slapi-plugin.h
+++ b/ldap/servers/slapd/slapi-plugin.h
@@ -7033,6 +7033,15 @@ int slapi_ldap_get_lderrno(LDAP *ld, char **m, char **s);
#endif
void slapi_ldif_put_type_and_value_with_options( char **out, const char *t, const char *val, int vlen, unsigned long options );
+/* ldif_read_record lineno argument type depends on openldap version */
+#if defined(USE_OPENLDAP)
+#if LDAP_VENDOR_VERSION >= 20434 /* changed in 2.4.34 */
+typedef unsigned long int ldif_record_lineno_t;
+#else
+typedef int ldif_record_lineno_t;
+#endif
+#endif
+
#if defined(USE_OPENLDAP)
/*
* UTF-8 routines (should these move into libnls?)
diff --git a/ldap/servers/slapd/tools/ldclt/ldapfct.c b/ldap/servers/slapd/tools/ldclt/ldapfct.c
index 1d0a0d4..c57f240 100644
--- a/ldap/servers/slapd/tools/ldclt/ldapfct.c
+++ b/ldap/servers/slapd/tools/ldclt/ldapfct.c
@@ -732,10 +732,8 @@ LDAP *
connectToLDAP(thread_context *tttctx, const char *bufBindDN, const char *bufPasswd, unsigned int mode, unsigned int mod2)
{
LDAP *ld = NULL;
- const char *mech = LDAP_SASL_SIMPLE;
struct berval cred = {0, NULL};
int v2v3 = LDAP_VERSION3;
- const char *binddn = NULL;
const char *passwd = NULL;
#if defined(USE_OPENLDAP)
char *ldapurl = NULL;
@@ -863,11 +861,8 @@ connectToLDAP(thread_context *tttctx, const char *bufBindDN, const char *bufPass
#endif /* !USE_OPENLDAP */
if (mode & CLTAUTH) {
- mech = "EXTERNAL";
- binddn = "";
passwd = NULL;
} else {
- binddn = bufBindDN?bufBindDN:mctx.bindDN;
passwd = bufPasswd?bufPasswd:mctx.passwd;
if (passwd) {
cred.bv_val = (char *)passwd;
diff --git a/ldap/servers/slapd/tools/rsearch/infadd.c b/ldap/servers/slapd/tools/rsearch/infadd.c
index 607381a..4a9f2e9 100644
--- a/ldap/servers/slapd/tools/rsearch/infadd.c
+++ b/ldap/servers/slapd/tools/rsearch/infadd.c
@@ -127,11 +127,10 @@ char *randName(void)
return x;
}
-int fill_table(NameTable *nt, PRUint32 size)
+void fill_table(NameTable *nt, PRUint32 size)
{
PRUint32 i;
char *x;
- int ret;
fprintf(stdout, "Generating random names: 0 ");
for (i = 0; i < size; i++) {
@@ -141,13 +140,13 @@ int fill_table(NameTable *nt, PRUint32 size)
free(x);
x = randName();
}
- ret = nt_push(nt, x);
+ (void)nt_push(nt, x);
if ((i % 100) == 0) {
fprintf(stdout, "\b\b\b\b\b\b\b%-7d", i);
}
}
fprintf(stdout, "\b\b\b\b\b\b\b%d. Done.\n", size);
- return ret;
+ return;
}
int main(int argc, char **argv)
diff --git a/ldap/servers/snmp/main.c b/ldap/servers/snmp/main.c
index 9a60f70..badaacc 100644
--- a/ldap/servers/snmp/main.c
+++ b/ldap/servers/snmp/main.c
@@ -236,6 +236,15 @@ main (int argc, char *argv[]) {
return 0;
}
+/* ldif_read_record lineno argument type depends on openldap version */
+#if defined(USE_OPENLDAP)
+#if LDAP_VENDOR_VERSION >= 20434 /* changed in 2.4.34 */
+typedef unsigned long int ldif_record_lineno_t;
+#else
+typedef int ldif_record_lineno_t;
+#endif
+#endif
+
/************************************************************************
* load_config
*
@@ -249,8 +258,10 @@ load_config(char *conf_path)
#if defined(USE_OPENLDAP)
LDIFFP *dse_fp = NULL;
int buflen = 0;
+ ldif_record_lineno_t lineno = 0;
#else
FILE *dse_fp = NULL;
+ int lineno = 0;
#endif
char line[MAXLINE];
char *p = NULL;
@@ -334,10 +345,10 @@ load_config(char *conf_path)
int got_rundir = 0;
int got_snmp_index = 0;
long snmp_index = 0;
- int lineno = 0;
char *entry = NULL;
char *instancename = NULL;
+ lineno = 0;
/* Allocate a server_instance */
if ((serv_p = malloc(sizeof(server_instance))) == NULL) {
printf("ldap-agent: malloc error processing config file\n");
diff --git a/lib/libaccess/acltools.cpp b/lib/libaccess/acltools.cpp
index 69d0c2e..3ef2beb 100644
--- a/lib/libaccess/acltools.cpp
+++ b/lib/libaccess/acltools.cpp
@@ -1740,7 +1740,7 @@ static PList_t ACLAttr2IndexPList = NULL;
int
ACL_InitAttr2Index(void)
{
- int i;
+ intptr_t i;
if (ACLAttr2IndexPList) return 0;
diff --git a/lib/libaccess/lasdns.cpp b/lib/libaccess/lasdns.cpp
index de8e624..93730c7 100644
--- a/lib/libaccess/lasdns.cpp
+++ b/lib/libaccess/lasdns.cpp
@@ -140,7 +140,6 @@ LASDnsBuild(NSErr_t *errp, char *attr_pattern, LASDnsContext_t *context, int ali
size_t delimiter; /* length of valid tokeni */
char token[256]; /* max length dns name */
int i;
- int ipcnt = 0;
char **p;
pool_handle_t *pool;
PRStatus error=PR_SUCCESS;
diff --git a/lib/libaccess/register.cpp b/lib/libaccess/register.cpp
index 766436e..798a926 100644
--- a/lib/libaccess/register.cpp
+++ b/lib/libaccess/register.cpp
@@ -77,6 +77,8 @@ ACL_LasHashInit()
{
int i;
+ (void)(link_ACLGlobal); /* get rid of defined but not used compiler warning */
+ (void)(link_nsacl_table); /* get rid of defined but not used compiler warning */
ACLLasEvalHash = PR_NewHashTable(0,
PR_HashString,
PR_CompareStrings,
@@ -268,11 +270,11 @@ ACL_MethodRegister(NSErr_t *errp, const char *name, ACLMethod_t *t)
}
/* Put it in the hash table */
- if (NULL == PR_HashTableAdd(ACLMethodHash, name, (void *)++cur_method)) {
+ if (NULL == PR_HashTableAdd(ACLMethodHash, name, (void *)(intptr_t)++cur_method)) {
ACL_CritExit();
return -1;
}
- *t = (ACLMethod_t) cur_method;
+ *t = (ACLMethod_t) (intptr_t)cur_method;
ACL_CritExit();
return 0;
@@ -412,11 +414,11 @@ ACL_DbTypeRegister(NSErr_t *errp, const char *name, DbParseFn_t func, ACLDbType_
}
/* Put it in the hash table */
- if (NULL == PR_HashTableAdd(ACLDbTypeHash, name, (void *)++cur_dbtype)) {
+ if (NULL == PR_HashTableAdd(ACLDbTypeHash, name, (void *)(intptr_t)++cur_dbtype)) {
ACL_CritExit();
return -1;
}
- *t = (ACLDbType_t) cur_dbtype;
+ *t = (ACLDbType_t) (intptr_t)cur_dbtype;
ACLDbParseFnTable[cur_dbtype] = func;
ACL_CritExit();
10 years, 11 months
Branch '389-ds-base-1.3.0' - ldap/servers lib/libaccess
by Richard Allen Megginson
ldap/servers/plugins/acct_usability/acct_usability.c | 2 -
ldap/servers/plugins/acl/acl_ext.c | 2 -
ldap/servers/plugins/acl/aclutil.c | 3 +
ldap/servers/plugins/automember/automember.c | 3 +
ldap/servers/plugins/deref/deref.c | 2 -
ldap/servers/plugins/http/http_impl.c | 4 +-
ldap/servers/plugins/pam_passthru/pam_ptimpl.c | 2 -
ldap/servers/plugins/referint/referint.c | 2 -
ldap/servers/plugins/replication/cl5_api.c | 20 ++++++------
ldap/servers/plugins/replication/windows_inc_protocol.c | 2 -
ldap/servers/plugins/replication/windows_private.c | 9 ++++-
ldap/servers/plugins/usn/usn.c | 4 +-
ldap/servers/slapd/back-ldbm/import-threads.c | 2 -
ldap/servers/slapd/back-ldbm/monitor.c | 18 +++++------
ldap/servers/slapd/log.c | 26 +++++++++-------
ldap/servers/slapd/mapping_tree.c | 6 +++
ldap/servers/slapd/regex.c | 10 ++++--
ldap/servers/slapd/slapi-plugin.h | 9 +++++
ldap/servers/slapd/tools/ldclt/ldapfct.c | 5 ---
ldap/servers/slapd/tools/rsearch/infadd.c | 7 +---
ldap/servers/snmp/main.c | 13 +++++++-
lib/libaccess/acltools.cpp | 2 -
lib/libaccess/lasdns.cpp | 1
lib/libaccess/register.cpp | 10 +++---
24 files changed, 100 insertions(+), 64 deletions(-)
New commits:
commit 6f8cdf7c0d25df2637a1f18ce970174392095bf4
Author: Rich Megginson <rmeggins(a)redhat.com>
Date: Wed Jun 5 11:30:13 2013 -0600
Ticket #47378 - fix recent compiler warnings
https://fedorahosted.org/389/ticket/47378
Reviewed by: nhosoi (Thanks!)
Branch: master
Fix Description: Fix the various compiler warnings as reported by
http://jenkins.cloud.fedoraproject.org/job/389-ds-base/ws/build-warns.137...
In addition, fixed a bug in the slapi_re_subs_ext - if there was an
ampersand that did not need to be replaced, that is, if the ampersand
was part of an LDAP search filter, it was replaced with a '('. Also, an
ampersand preceeded by an open parenthesis and followed by a non-open
parenthesis is supposed to be replaced in the string, but this was not
working.
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: no
(cherry picked from commit 0dc230b007dc3ad292961f378421b03736b68f9e)
diff --git a/ldap/servers/plugins/acct_usability/acct_usability.c b/ldap/servers/plugins/acct_usability/acct_usability.c
index 19e55c3..f41f934 100644
--- a/ldap/servers/plugins/acct_usability/acct_usability.c
+++ b/ldap/servers/plugins/acct_usability/acct_usability.c
@@ -312,7 +312,7 @@ auc_pre_search(Slapi_PBlock *pb)
int ldapcode = LDAP_SUCCESS;
const LDAPControl **reqctrls = NULL;
const LDAPControl *aucctrl = NULL;
- const char *ldaperrtext;
+ const char *ldaperrtext = "Unknown error";
const char *incompatible = NULL;
int isroot = 0;
int ii;
diff --git a/ldap/servers/plugins/acl/acl_ext.c b/ldap/servers/plugins/acl/acl_ext.c
index f8699b4..e42a7e2 100644
--- a/ldap/servers/plugins/acl/acl_ext.c
+++ b/ldap/servers/plugins/acl/acl_ext.c
@@ -128,7 +128,7 @@ acl_get_ext (ext_type type, void *object)
void
acl_set_ext (ext_type type, void *object, void *data)
{
- if ( type >= 0 && type < ACL_EXT_ALL )
+ if ( type < ACL_EXT_ALL )
{
struct acl_ext ext = acl_ext_list [type];
slapi_set_object_extension ( ext.object_type, object, ext.handle, data );
diff --git a/ldap/servers/plugins/acl/aclutil.c b/ldap/servers/plugins/acl/aclutil.c
index 7097540..5969b26 100644
--- a/ldap/servers/plugins/acl/aclutil.c
+++ b/ldap/servers/plugins/acl/aclutil.c
@@ -96,6 +96,7 @@ aclutil_str_append_ext(char **dest, size_t *dlen, const char *src, size_t slen)
char *ptr = NULL;
int rc = 0;
+ PR_ASSERT(NULL != dlen);
if ( dest == NULL || src == NULL ) {
return rc;
}
@@ -103,7 +104,7 @@ aclutil_str_append_ext(char **dest, size_t *dlen, const char *src, size_t slen)
if (0 == slen) {
slen = strlen(src);
}
- if (*dest && dlen > 0) {
+ if (*dest && *dlen > 0) {
size_t dest_strlen = strlen(*dest);
size_t new_len = dest_strlen + slen + 1;
if (new_len > *dlen) {
diff --git a/ldap/servers/plugins/automember/automember.c b/ldap/servers/plugins/automember/automember.c
index 424b507..49f47f7 100644
--- a/ldap/servers/plugins/automember/automember.c
+++ b/ldap/servers/plugins/automember/automember.c
@@ -2522,10 +2522,11 @@ void automember_map_task_thread(void *arg){
#if defined(USE_OPENLDAP)
int buflen = 0;
LDIFFP *ldif_fd_in = NULL;
+ ldif_record_lineno_t lineno = 0;
#else
PRFileDesc *ldif_fd_in = NULL;
-#endif
int lineno = 0;
+#endif
int rc = 0;
td = (task_data *)slapi_task_get_data(task);
diff --git a/ldap/servers/plugins/deref/deref.c b/ldap/servers/plugins/deref/deref.c
index aec48ed..5c98535 100644
--- a/ldap/servers/plugins/deref/deref.c
+++ b/ldap/servers/plugins/deref/deref.c
@@ -438,7 +438,7 @@ deref_pre_search(Slapi_PBlock *pb)
int ldapcode = LDAP_SUCCESS;
const LDAPControl **reqctrls = NULL;
const LDAPControl *derefctrl = NULL;
- const char *ldaperrtext;
+ const char *ldaperrtext = "Unknown error";
const char *incompatible = NULL;
DerefSpecList *speclist = NULL;
int ii;
diff --git a/ldap/servers/plugins/http/http_impl.c b/ldap/servers/plugins/http/http_impl.c
index f96d75a..db02b67 100644
--- a/ldap/servers/plugins/http/http_impl.c
+++ b/ldap/servers/plugins/http/http_impl.c
@@ -260,7 +260,7 @@ static int doRequest(const char *url, httpheader **httpheaderArray, char *body,
PRInt32 port;
PRInt32 errcode = 0;
PRInt32 http_connection_time_out = 0;
- PRInt32 sslOn;
+ PRInt32 sslOn = 0;
LDAPDebug( LDAP_DEBUG_PLUGIN, "--> doRequest -- BEGIN\n",0,0,0);
@@ -1178,7 +1178,7 @@ SECStatus
struct SECKEYPrivateKeyStr **pRetKey)
{
CERTCertificate * cert;
- SECKEYPrivateKey * privKey;
+ SECKEYPrivateKey * privKey = NULL;
char * chosenNickName = (char *)arg;
void * proto_win = NULL;
SECStatus secStatus = SECFailure;
diff --git a/ldap/servers/plugins/pam_passthru/pam_ptimpl.c b/ldap/servers/plugins/pam_passthru/pam_ptimpl.c
index 69c08e8..2558b9e 100644
--- a/ldap/servers/plugins/pam_passthru/pam_ptimpl.c
+++ b/ldap/servers/plugins/pam_passthru/pam_ptimpl.c
@@ -263,7 +263,7 @@ do_one_pam_auth(
MyStrBuf pam_id;
const char *binddn = NULL;
Slapi_DN *bindsdn = NULL;
- int rc;
+ int rc = PAM_SUCCESS;
int retcode = LDAP_SUCCESS;
pam_handle_t *pam_handle;
struct my_pam_conv_str my_data;
diff --git a/ldap/servers/plugins/referint/referint.c b/ldap/servers/plugins/referint/referint.c
index beb5f9f..234c322 100644
--- a/ldap/servers/plugins/referint/referint.c
+++ b/ldap/servers/plugins/referint/referint.c
@@ -921,7 +921,7 @@ int referint_postop_close( Slapi_PBlock *pb)
void
referint_thread_func(void *arg)
{
- PRFileDesc *prfd;
+ PRFileDesc *prfd = NULL;
char **plugin_argv = (char **)arg;
char *logfilename;
char thisline[MAX_LINE];
diff --git a/ldap/servers/plugins/replication/cl5_api.c b/ldap/servers/plugins/replication/cl5_api.c
index f9934f3..da25ab0 100644
--- a/ldap/servers/plugins/replication/cl5_api.c
+++ b/ldap/servers/plugins/replication/cl5_api.c
@@ -272,8 +272,8 @@ static CL5Desc s_cl5Desc;
/* changelog initialization and cleanup */
static int _cl5Open (const char *dir, const CL5DBConfig *config, CL5OpenMode openMode);
-static int _cl5AppInit (PRBool *didRecovery);
-static int _cl5DBOpen ();
+static int _cl5AppInit (void);
+static int _cl5DBOpen (void);
static void _cl5SetDefaultDBConfig ();
static void _cl5SetDBConfig (const CL5DBConfig *config);
static int _cl5CheckDBVersion ();
@@ -877,12 +877,13 @@ cl5ImportLDIF (const char *clDir, const char *ldifFile, Object **replicas)
#if defined(USE_OPENLDAP)
LDIFFP *file = NULL;
int buflen;
+ ldif_record_lineno_t lineno = 0;
#else
FILE *file = NULL;
+ int lineno = 0;
#endif
int rc;
char *buff = NULL;
- int lineno = 0;
slapi_operation_parameters op;
Object *prim_replica_obj = NULL;
Object *replica_obj = NULL;
@@ -1851,7 +1852,6 @@ int cl5GetOperationCount (Object *replica)
static int _cl5Open (const char *dir, const CL5DBConfig *config, CL5OpenMode openMode)
{
int rc;
- PRBool didRecovery;
PR_ASSERT (dir);
@@ -1899,7 +1899,7 @@ static int _cl5Open (const char *dir, const CL5DBConfig *config, CL5OpenMode ope
s_cl5Desc.dbOpenMode = openMode;
/* initialize db environment */
- rc = _cl5AppInit (&didRecovery);
+ rc = _cl5AppInit ();
if (rc != CL5_SUCCESS)
{
slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl,
@@ -1914,7 +1914,7 @@ static int _cl5Open (const char *dir, const CL5DBConfig *config, CL5OpenMode ope
}
/* open database files */
- rc = _cl5DBOpen (!didRecovery);
+ rc = _cl5DBOpen ();
if (rc != CL5_SUCCESS)
{
slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl,
@@ -1990,7 +1990,7 @@ int cl5CreateDirIfNeeded (const char *dirName)
return CL5_SUCCESS;
}
-static int _cl5AppInit (PRBool *didRecovery)
+static int _cl5AppInit (void)
{
int rc = -1; /* initialize to failure */
DB_ENV *dbEnv = NULL;
@@ -2854,7 +2854,7 @@ static int _cl5Upgrade3_4(char *fromVersion, char *toVersion)
backup = s_cl5Desc.dbOpenMode;
s_cl5Desc.dbOpenMode = CL5_OPEN_CLEAN_RECOVER;
/* CL5_OPEN_CLEAN_RECOVER does 1 and 2 */
- rc = _cl5AppInit (NULL);
+ rc = _cl5AppInit ();
if (rc != CL5_SUCCESS)
{
slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl,
@@ -2944,7 +2944,7 @@ static int _cl5Upgrade4_4(char *fromVersion, char *toVersion)
backup = s_cl5Desc.dbOpenMode;
s_cl5Desc.dbOpenMode = CL5_OPEN_CLEAN_RECOVER;
/* CL5_OPEN_CLEAN_RECOVER does 1 and 2 */
- rc = _cl5AppInit (NULL);
+ rc = _cl5AppInit ();
if (rc != CL5_SUCCESS)
{
slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl,
@@ -4224,7 +4224,7 @@ static int _cl5Operation2LDIF (const slapi_operation_parameters *op, const char
int len = 2;
lenstr *l = NULL;
const char *strType;
- char *strDeleteOldRDN;
+ const char *strDeleteOldRDN = "false";
char *buff, *start;
LDAPMod **add_mods;
char *rawDN = NULL;
diff --git a/ldap/servers/plugins/replication/windows_inc_protocol.c b/ldap/servers/plugins/replication/windows_inc_protocol.c
index 4540fe1..17c8df5 100644
--- a/ldap/servers/plugins/replication/windows_inc_protocol.c
+++ b/ldap/servers/plugins/replication/windows_inc_protocol.c
@@ -1175,7 +1175,7 @@ send_updates(Private_Repl_Protocol *prp, RUV *remote_update_vector, PRUint32 *nu
{
CL5Entry entry;
slapi_operation_parameters op;
- int return_value;
+ int return_value = UPDATE_NO_MORE_UPDATES;
int rc;
int set_mincsn = 0;
CL5ReplayIterator *changelog_iterator = NULL;
diff --git a/ldap/servers/plugins/replication/windows_private.c b/ldap/servers/plugins/replication/windows_private.c
index 3bdd0c1..e0dc8ca 100644
--- a/ldap/servers/plugins/replication/windows_private.c
+++ b/ldap/servers/plugins/replication/windows_private.c
@@ -1355,11 +1355,16 @@ windows_plugin_init(Repl_Agmt *ra)
{
struct winsync_plugin_cookie *list = NULL;
void *cookie = NULL;
- PRStatus rv;
LDAPDebug0Args( LDAP_DEBUG_PLUGIN, "--> windows_plugin_init_start -- begin\n");
- rv = PR_CallOnce(&winsync_callOnce, windows_plugin_callonce);
+ if (PR_CallOnce(&winsync_callOnce, windows_plugin_callonce)) {
+ PRErrorCode prerr = PR_GetError();
+ slapi_log_error(SLAPI_LOG_FATAL, "windows_plugin_init",
+ "cannot initialize plugin: %d:%s\n", prerr,
+ slapi_pr_strerror(prerr));
+ return;
+ }
/* call each plugin init function in turn - store the returned cookie
indexed by the api */
diff --git a/ldap/servers/plugins/usn/usn.c b/ldap/servers/plugins/usn/usn.c
index 0273fd1..4473618 100644
--- a/ldap/servers/plugins/usn/usn.c
+++ b/ldap/servers/plugins/usn/usn.c
@@ -673,7 +673,7 @@ usn_rootdse_search(Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry* entryAfter,
if (be && be->be_usn_counter) {
/* get a next USN counter from be_usn_counter;
* then minus 1 from it */
- PR_snprintf(usn_berval.bv_val, USN_COUNTER_BUF_LEN, "%" NSPRI64 "d",
+ PR_snprintf(usn_berval.bv_val, USN_COUNTER_BUF_LEN, "%" NSPRIu64,
slapi_counter_get_value(be->be_usn_counter)-1);
usn_berval.bv_len = strlen(usn_berval.bv_val);
slapi_entry_attr_replace(e, attr, vals);
@@ -692,7 +692,7 @@ usn_rootdse_search(Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry* entryAfter,
}
/* get a next USN counter from be_usn_counter;
* then minus 1 from it */
- PR_snprintf(usn_berval.bv_val, USN_COUNTER_BUF_LEN, "%" NSPRI64 "d",
+ PR_snprintf(usn_berval.bv_val, USN_COUNTER_BUF_LEN, "%" NSPRIu64,
slapi_counter_get_value(be->be_usn_counter)-1);
usn_berval.bv_len = strlen(usn_berval.bv_val);
diff --git a/ldap/servers/slapd/back-ldbm/import-threads.c b/ldap/servers/slapd/back-ldbm/import-threads.c
index 60dbb5f..78db060 100644
--- a/ldap/servers/slapd/back-ldbm/import-threads.c
+++ b/ldap/servers/slapd/back-ldbm/import-threads.c
@@ -3620,7 +3620,7 @@ _get_import_entryusn(ImportJob *job, Slapi_Value **usn_value)
* Use the counter which stores the old DB's
* next entryusn. */
PR_snprintf(counter_buf, USN_COUNTER_BUF_LEN,
- "%" NSPRI64 "d",
+ "%" NSPRIu64,
slapi_counter_get_value(be->be_usn_counter));
} else {
/* import_init value is digit.
diff --git a/ldap/servers/slapd/back-ldbm/monitor.c b/ldap/servers/slapd/back-ldbm/monitor.c
index 1a06a25..49edb68 100644
--- a/ldap/servers/slapd/back-ldbm/monitor.c
+++ b/ldap/servers/slapd/back-ldbm/monitor.c
@@ -238,13 +238,13 @@ int ldbm_back_monitor_instance_search(Slapi_PBlock *pb, Slapi_Entry *e,
#endif
MSETF("dbFilename-%d", i);
- sprintf(buf, "%u", mpfstat[i]->st_cache_hit);
+ sprintf(buf, "%lu", (unsigned long)mpfstat[i]->st_cache_hit);
MSETF("dbFileCacheHit-%d", i);
- sprintf(buf, "%u", mpfstat[i]->st_cache_miss);
+ sprintf(buf, "%lu", (unsigned long)mpfstat[i]->st_cache_miss);
MSETF("dbFileCacheMiss-%d", i);
- sprintf(buf, "%u", mpfstat[i]->st_page_in);
+ sprintf(buf, "%lu", (unsigned long)mpfstat[i]->st_page_in);
MSETF("dbFilePageIn-%d", i);
- sprintf(buf, "%u", mpfstat[i]->st_page_out);
+ sprintf(buf, "%lu", (unsigned long)mpfstat[i]->st_page_out);
MSETF("dbFilePageOut-%d", i);
slapi_ch_free_string(&absolute_pathname);
@@ -291,7 +291,7 @@ int ldbm_back_monitor_search(Slapi_PBlock *pb, Slapi_Entry *e,
}
/* cache hits*/
- sprintf(buf, "%u", mpstat->st_cache_hit);
+ sprintf(buf, "%lu", (unsigned long)mpstat->st_cache_hit);
MSET("dbCacheHits");
/* cache tries*/
@@ -303,13 +303,13 @@ int ldbm_back_monitor_search(Slapi_PBlock *pb, Slapi_Entry *e,
sprintf(buf, "%lu", (unsigned long)(100.0 * (double)mpstat->st_cache_hit / (double)(cache_tries > 0 ? cache_tries : 1) ));
MSET("dbCacheHitRatio");
- sprintf(buf, "%u", mpstat->st_page_in);
+ sprintf(buf, "%lu", (unsigned long)mpstat->st_page_in);
MSET("dbCachePageIn");
- sprintf(buf, "%u", mpstat->st_page_out);
+ sprintf(buf, "%lu", (unsigned long)mpstat->st_page_out);
MSET("dbCachePageOut");
- sprintf(buf, "%u", mpstat->st_ro_evict);
+ sprintf(buf, "%lu", (unsigned long)mpstat->st_ro_evict);
MSET("dbCacheROEvict");
- sprintf(buf, "%u", mpstat->st_rw_evict);
+ sprintf(buf, "%lu", (unsigned long)mpstat->st_rw_evict);
MSET("dbCacheRWEvict");
slapi_ch_free((void **)&mpstat);
diff --git a/ldap/servers/slapd/log.c b/ldap/servers/slapd/log.c
index cab82d5..5873c11 100644
--- a/ldap/servers/slapd/log.c
+++ b/ldap/servers/slapd/log.c
@@ -207,6 +207,15 @@ slapd_log_error_proc_internal(
/* Should be a flush in here ?? Yes because PR_SYNC doesn't work ! */ \
PR_Sync(fd); \
} while (0)
+#define LOG_WRITE_NOW_NO_ERR(fd, buffer, size, headersize) do {\
+ if ( slapi_write_buffer((fd), (buffer), (size)) != (size) ) \
+ { \
+ PRErrorCode prerr = PR_GetError(); \
+ syslog(LOG_ERR, "Failed to write log, " SLAPI_COMPONENT_NAME_NSPR " error %d (%s): %s\n", prerr, slapd_pr_strerror(prerr), (buffer)+(headersize) ); \
+ } \
+ /* Should be a flush in here ?? Yes because PR_SYNC doesn't work ! */ \
+ PR_Sync(fd); \
+ } while (0)
#define LOG_CLOSE(fd) \
PR_Close((fd))
#endif
@@ -1267,7 +1276,7 @@ int
log_set_maxdiskspace(const char *attrname, char *maxdiskspace_str, int logtype, char *errorbuf, int apply)
{
int rv = 0;
- PRInt64 mlogsize; /* in bytes */
+ PRInt64 mlogsize = 0; /* in bytes */
PRInt64 maxdiskspace; /* in bytes */
int s_maxdiskspace; /* in megabytes */
@@ -1500,7 +1509,7 @@ log_set_expirationtimeunit(const char *attrname, char *expunit, int logtype, cha
{
int value = 0;
int rv = 0;
- int exptime, rsecs;
+ int exptime = 0, rsecs = 0;
int *exptimeunitp = NULL;
slapdFrontendConfig_t *fe_cfg = getFrontendConfig();
@@ -1616,12 +1625,11 @@ log_write_title (LOGFD fp)
char *buildnum = config_get_buildnum();
char buff[512];
int bufflen = sizeof(buff);
- int err = 0;
PR_snprintf(buff, bufflen, "\t%s B%s\n",
fe_cfg->versionstring ? fe_cfg->versionstring : CAPBRAND "-Directory/" DS_PACKAGE_VERSION,
buildnum ? buildnum : "");
- LOG_WRITE_NOW(fp, buff, strlen(buff), 0, err);
+ LOG_WRITE_NOW_NO_ERR(fp, buff, strlen(buff), 0);
if (fe_cfg->localhost) {
PR_snprintf(buff, bufflen, "\t%s:%d (%s)\n\n",
@@ -1636,7 +1644,7 @@ log_write_title (LOGFD fp)
PR_snprintf(buff, bufflen, "\t<host>:<port> (%s)\n\n",
fe_cfg->configdir ? fe_cfg->configdir : "");
}
- LOG_WRITE_NOW(fp, buff, strlen(buff), 0, err);
+ LOG_WRITE_NOW_NO_ERR(fp, buff, strlen(buff), 0);
slapi_ch_free((void **)&buildnum);
}
@@ -1723,7 +1731,6 @@ slapd_log_audit_proc (
int buf_len)
{
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) {
@@ -1742,7 +1749,7 @@ slapd_log_audit_proc (
log_write_title( loginfo.log_audit_fdes);
loginfo.log_audit_state &= ~LOGGING_NEED_TITLE;
}
- LOG_WRITE_NOW(loginfo.log_audit_fdes, buffer, buf_len, 0, err);
+ LOG_WRITE_NOW_NO_ERR(loginfo.log_audit_fdes, buffer, buf_len, 0);
LOG_AUDIT_UNLOCK_WRITE();
return 0;
}
@@ -4144,7 +4151,6 @@ static void log_flush_buffer(LogBufferInfo *lbi, int type, int sync_now)
slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
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) {
@@ -4175,8 +4181,8 @@ static void log_flush_buffer(LogBufferInfo *lbi, int type, int sync_now)
if (!sync_now && slapdFrontendConfig->accesslogbuffering) {
LOG_WRITE(loginfo.log_access_fdes, lbi->top, lbi->current - lbi->top, 0);
} else {
- LOG_WRITE_NOW(loginfo.log_access_fdes, lbi->top,
- lbi->current - lbi->top, 0, err);
+ LOG_WRITE_NOW_NO_ERR(loginfo.log_access_fdes, lbi->top,
+ lbi->current - lbi->top, 0);
}
lbi->current = lbi->top;
diff --git a/ldap/servers/slapd/mapping_tree.c b/ldap/servers/slapd/mapping_tree.c
index 5de0e46..9336d7c 100644
--- a/ldap/servers/slapd/mapping_tree.c
+++ b/ldap/servers/slapd/mapping_tree.c
@@ -158,8 +158,10 @@ static mapping_tree_node *
static int _mtn_update_config_param(int op, char *type, char *strvalue);
#ifdef DEBUG
+#ifdef USE_DUMP_MAPPING_TREE
static void dump_mapping_tree(mapping_tree_node *parent, int depth);
#endif
+#endif
/* structure and static local variable used to store the
* list of plugins that have registered to a callback when backend state
@@ -3721,6 +3723,7 @@ void test_register()
#endif
#ifdef DEBUG
+#ifdef USE_DUMP_MAPPING_TREE
static void dump_mapping_tree(mapping_tree_node *parent, int depth)
{
mapping_tree_node *current = NULL;
@@ -3751,7 +3754,8 @@ static void dump_mapping_tree(mapping_tree_node *parent, int depth)
}
return;
}
-#endif
+#endif /* USE_DUMP_MAPPING_TREE */
+#endif /* DEBUG */
/* helper function to set/remove the config param in cn=config */
static int
diff --git a/ldap/servers/slapd/regex.c b/ldap/servers/slapd/regex.c
index 3697fde..29edffe 100644
--- a/ldap/servers/slapd/regex.c
+++ b/ldap/servers/slapd/regex.c
@@ -161,7 +161,7 @@ slapi_re_subs_ext( Slapi_Regex *re_handle, const char *subject,
int pin;
int *ovector;
char *mydst;
- const char *prev, *next;
+ const char *prev;
const char *substring_start;
const char *p;
@@ -179,8 +179,7 @@ slapi_re_subs_ext( Slapi_Regex *re_handle, const char *subject,
for (p = src; *p != '\0'; p++) {
if ('&' == *p) {
/* Don't replace '&' if it's a filter AND: "(&(cn=a)(sn=b))" */
- next = p;
- if(!filter || (*prev != '(' && *next++ != '(')){
+ if(!filter || !(*prev == '(' && *(p+1) == '(')){
if (re_handle->re_oveccount <= 1) {
memset(*dst, '\0', dstlen);
return -1;
@@ -188,6 +187,11 @@ slapi_re_subs_ext( Slapi_Regex *re_handle, const char *subject,
substring_start = subject + ovector[0];
thislen = ovector[1] - ovector[0];
len += thislen;
+ } else { /* is a filter AND clause */
+ /* just copy it into the filter */
+ substring_start = p;
+ thislen = 1;
+ len++;
}
} else if (('\\' == *p) && ('0' <= *(p+1) && *(p+1) <= '9')) {
pin = *(++p) - '0';
diff --git a/ldap/servers/slapd/slapi-plugin.h b/ldap/servers/slapd/slapi-plugin.h
index 8d14dd6..b1a4fe7 100644
--- a/ldap/servers/slapd/slapi-plugin.h
+++ b/ldap/servers/slapd/slapi-plugin.h
@@ -6950,6 +6950,15 @@ int slapi_ldap_get_lderrno(LDAP *ld, char **m, char **s);
#endif
void slapi_ldif_put_type_and_value_with_options( char **out, const char *t, const char *val, int vlen, unsigned long options );
+/* ldif_read_record lineno argument type depends on openldap version */
+#if defined(USE_OPENLDAP)
+#if LDAP_VENDOR_VERSION >= 20434 /* changed in 2.4.34 */
+typedef unsigned long int ldif_record_lineno_t;
+#else
+typedef int ldif_record_lineno_t;
+#endif
+#endif
+
#if defined(USE_OPENLDAP)
/*
* UTF-8 routines (should these move into libnls?)
diff --git a/ldap/servers/slapd/tools/ldclt/ldapfct.c b/ldap/servers/slapd/tools/ldclt/ldapfct.c
index 3f74fd0..b177d7c 100644
--- a/ldap/servers/slapd/tools/ldclt/ldapfct.c
+++ b/ldap/servers/slapd/tools/ldclt/ldapfct.c
@@ -732,10 +732,8 @@ LDAP *
connectToLDAP(thread_context *tttctx, const char *bufBindDN, const char *bufPasswd, unsigned int mode, unsigned int mod2)
{
LDAP *ld = NULL;
- const char *mech = LDAP_SASL_SIMPLE;
struct berval cred = {0, NULL};
int v2v3 = LDAP_VERSION3;
- const char *binddn = NULL;
const char *passwd = NULL;
#if defined(USE_OPENLDAP)
char *ldapurl = NULL;
@@ -863,11 +861,8 @@ connectToLDAP(thread_context *tttctx, const char *bufBindDN, const char *bufPass
#endif /* !USE_OPENLDAP */
if (mode & CLTAUTH) {
- mech = "EXTERNAL";
- binddn = "";
passwd = NULL;
} else {
- binddn = bufBindDN?bufBindDN:mctx.bindDN;
passwd = bufPasswd?bufPasswd:mctx.passwd;
if (passwd) {
cred.bv_val = (char *)passwd;
diff --git a/ldap/servers/slapd/tools/rsearch/infadd.c b/ldap/servers/slapd/tools/rsearch/infadd.c
index 607381a..4a9f2e9 100644
--- a/ldap/servers/slapd/tools/rsearch/infadd.c
+++ b/ldap/servers/slapd/tools/rsearch/infadd.c
@@ -127,11 +127,10 @@ char *randName(void)
return x;
}
-int fill_table(NameTable *nt, PRUint32 size)
+void fill_table(NameTable *nt, PRUint32 size)
{
PRUint32 i;
char *x;
- int ret;
fprintf(stdout, "Generating random names: 0 ");
for (i = 0; i < size; i++) {
@@ -141,13 +140,13 @@ int fill_table(NameTable *nt, PRUint32 size)
free(x);
x = randName();
}
- ret = nt_push(nt, x);
+ (void)nt_push(nt, x);
if ((i % 100) == 0) {
fprintf(stdout, "\b\b\b\b\b\b\b%-7d", i);
}
}
fprintf(stdout, "\b\b\b\b\b\b\b%d. Done.\n", size);
- return ret;
+ return;
}
int main(int argc, char **argv)
diff --git a/ldap/servers/snmp/main.c b/ldap/servers/snmp/main.c
index ca3fc1c..78d4814 100644
--- a/ldap/servers/snmp/main.c
+++ b/ldap/servers/snmp/main.c
@@ -236,6 +236,15 @@ main (int argc, char *argv[]) {
return 0;
}
+/* ldif_read_record lineno argument type depends on openldap version */
+#if defined(USE_OPENLDAP)
+#if LDAP_VENDOR_VERSION >= 20434 /* changed in 2.4.34 */
+typedef unsigned long int ldif_record_lineno_t;
+#else
+typedef int ldif_record_lineno_t;
+#endif
+#endif
+
/************************************************************************
* load_config
*
@@ -249,8 +258,10 @@ load_config(char *conf_path)
#if defined(USE_OPENLDAP)
LDIFFP *dse_fp = NULL;
int buflen = 0;
+ ldif_record_lineno_t lineno = 0;
#else
FILE *dse_fp = NULL;
+ int lineno = 0;
#endif
char line[MAXLINE];
char *p = NULL;
@@ -332,10 +343,10 @@ load_config(char *conf_path)
} else if ((p = strstr(line, "server")) != NULL) {
int got_port = 0;
int got_rundir = 0;
- int lineno = 0;
char *entry = NULL;
char *instancename = NULL;
+ lineno = 0;
/* Allocate a server_instance */
if ((serv_p = malloc(sizeof(server_instance))) == NULL) {
printf("ldap-agent: malloc error processing config file\n");
diff --git a/lib/libaccess/acltools.cpp b/lib/libaccess/acltools.cpp
index 69d0c2e..3ef2beb 100644
--- a/lib/libaccess/acltools.cpp
+++ b/lib/libaccess/acltools.cpp
@@ -1740,7 +1740,7 @@ static PList_t ACLAttr2IndexPList = NULL;
int
ACL_InitAttr2Index(void)
{
- int i;
+ intptr_t i;
if (ACLAttr2IndexPList) return 0;
diff --git a/lib/libaccess/lasdns.cpp b/lib/libaccess/lasdns.cpp
index de8e624..93730c7 100644
--- a/lib/libaccess/lasdns.cpp
+++ b/lib/libaccess/lasdns.cpp
@@ -140,7 +140,6 @@ LASDnsBuild(NSErr_t *errp, char *attr_pattern, LASDnsContext_t *context, int ali
size_t delimiter; /* length of valid tokeni */
char token[256]; /* max length dns name */
int i;
- int ipcnt = 0;
char **p;
pool_handle_t *pool;
PRStatus error=PR_SUCCESS;
diff --git a/lib/libaccess/register.cpp b/lib/libaccess/register.cpp
index 766436e..798a926 100644
--- a/lib/libaccess/register.cpp
+++ b/lib/libaccess/register.cpp
@@ -77,6 +77,8 @@ ACL_LasHashInit()
{
int i;
+ (void)(link_ACLGlobal); /* get rid of defined but not used compiler warning */
+ (void)(link_nsacl_table); /* get rid of defined but not used compiler warning */
ACLLasEvalHash = PR_NewHashTable(0,
PR_HashString,
PR_CompareStrings,
@@ -268,11 +270,11 @@ ACL_MethodRegister(NSErr_t *errp, const char *name, ACLMethod_t *t)
}
/* Put it in the hash table */
- if (NULL == PR_HashTableAdd(ACLMethodHash, name, (void *)++cur_method)) {
+ if (NULL == PR_HashTableAdd(ACLMethodHash, name, (void *)(intptr_t)++cur_method)) {
ACL_CritExit();
return -1;
}
- *t = (ACLMethod_t) cur_method;
+ *t = (ACLMethod_t) (intptr_t)cur_method;
ACL_CritExit();
return 0;
@@ -412,11 +414,11 @@ ACL_DbTypeRegister(NSErr_t *errp, const char *name, DbParseFn_t func, ACLDbType_
}
/* Put it in the hash table */
- if (NULL == PR_HashTableAdd(ACLDbTypeHash, name, (void *)++cur_dbtype)) {
+ if (NULL == PR_HashTableAdd(ACLDbTypeHash, name, (void *)(intptr_t)++cur_dbtype)) {
ACL_CritExit();
return -1;
}
- *t = (ACLDbType_t) cur_dbtype;
+ *t = (ACLDbType_t) (intptr_t)cur_dbtype;
ACLDbParseFnTable[cur_dbtype] = func;
ACL_CritExit();
10 years, 11 months
Branch '389-ds-base-1.2.11' - ldap/servers lib/libaccess
by Richard Allen Megginson
ldap/servers/plugins/acct_usability/acct_usability.c | 2 -
ldap/servers/plugins/acl/acl_ext.c | 2 -
ldap/servers/plugins/acl/aclutil.c | 3 +
ldap/servers/plugins/automember/automember.c | 3 +
ldap/servers/plugins/deref/deref.c | 2 -
ldap/servers/plugins/http/http_impl.c | 4 +-
ldap/servers/plugins/pam_passthru/pam_ptimpl.c | 2 -
ldap/servers/plugins/referint/referint.c | 2 -
ldap/servers/plugins/replication/cl5_api.c | 20 ++++++------
ldap/servers/plugins/replication/windows_inc_protocol.c | 2 -
ldap/servers/plugins/replication/windows_private.c | 9 ++++-
ldap/servers/plugins/usn/usn.c | 4 +-
ldap/servers/slapd/back-ldbm/import-threads.c | 2 -
ldap/servers/slapd/back-ldbm/monitor.c | 18 +++++------
ldap/servers/slapd/log.c | 26 +++++++++-------
ldap/servers/slapd/mapping_tree.c | 6 +++
ldap/servers/slapd/regex.c | 10 ++++--
ldap/servers/slapd/slapi-plugin.h | 9 +++++
ldap/servers/slapd/tools/ldclt/ldapfct.c | 5 ---
ldap/servers/slapd/tools/rsearch/infadd.c | 7 +---
ldap/servers/snmp/main.c | 13 +++++++-
lib/libaccess/acltools.cpp | 2 -
lib/libaccess/register.cpp | 10 +++---
23 files changed, 100 insertions(+), 63 deletions(-)
New commits:
commit 79739bdfba251ed6445ae4a16e90a471ca3f7b94
Author: Rich Megginson <rmeggins(a)redhat.com>
Date: Wed Jun 5 11:30:13 2013 -0600
Ticket #47378 - fix recent compiler warnings
https://fedorahosted.org/389/ticket/47378
Reviewed by: nhosoi (Thanks!)
Branch: master
Fix Description: Fix the various compiler warnings as reported by
http://jenkins.cloud.fedoraproject.org/job/389-ds-base/ws/build-warns.137...
In addition, fixed a bug in the slapi_re_subs_ext - if there was an
ampersand that did not need to be replaced, that is, if the ampersand
was part of an LDAP search filter, it was replaced with a '('. Also, an
ampersand preceeded by an open parenthesis and followed by a non-open
parenthesis is supposed to be replaced in the string, but this was not
working.
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: no
(cherry picked from commit 0dc230b007dc3ad292961f378421b03736b68f9e)
diff --git a/ldap/servers/plugins/acct_usability/acct_usability.c b/ldap/servers/plugins/acct_usability/acct_usability.c
index 19e55c3..f41f934 100644
--- a/ldap/servers/plugins/acct_usability/acct_usability.c
+++ b/ldap/servers/plugins/acct_usability/acct_usability.c
@@ -312,7 +312,7 @@ auc_pre_search(Slapi_PBlock *pb)
int ldapcode = LDAP_SUCCESS;
const LDAPControl **reqctrls = NULL;
const LDAPControl *aucctrl = NULL;
- const char *ldaperrtext;
+ const char *ldaperrtext = "Unknown error";
const char *incompatible = NULL;
int isroot = 0;
int ii;
diff --git a/ldap/servers/plugins/acl/acl_ext.c b/ldap/servers/plugins/acl/acl_ext.c
index f8699b4..e42a7e2 100644
--- a/ldap/servers/plugins/acl/acl_ext.c
+++ b/ldap/servers/plugins/acl/acl_ext.c
@@ -128,7 +128,7 @@ acl_get_ext (ext_type type, void *object)
void
acl_set_ext (ext_type type, void *object, void *data)
{
- if ( type >= 0 && type < ACL_EXT_ALL )
+ if ( type < ACL_EXT_ALL )
{
struct acl_ext ext = acl_ext_list [type];
slapi_set_object_extension ( ext.object_type, object, ext.handle, data );
diff --git a/ldap/servers/plugins/acl/aclutil.c b/ldap/servers/plugins/acl/aclutil.c
index 7097540..5969b26 100644
--- a/ldap/servers/plugins/acl/aclutil.c
+++ b/ldap/servers/plugins/acl/aclutil.c
@@ -96,6 +96,7 @@ aclutil_str_append_ext(char **dest, size_t *dlen, const char *src, size_t slen)
char *ptr = NULL;
int rc = 0;
+ PR_ASSERT(NULL != dlen);
if ( dest == NULL || src == NULL ) {
return rc;
}
@@ -103,7 +104,7 @@ aclutil_str_append_ext(char **dest, size_t *dlen, const char *src, size_t slen)
if (0 == slen) {
slen = strlen(src);
}
- if (*dest && dlen > 0) {
+ if (*dest && *dlen > 0) {
size_t dest_strlen = strlen(*dest);
size_t new_len = dest_strlen + slen + 1;
if (new_len > *dlen) {
diff --git a/ldap/servers/plugins/automember/automember.c b/ldap/servers/plugins/automember/automember.c
index 424b507..49f47f7 100644
--- a/ldap/servers/plugins/automember/automember.c
+++ b/ldap/servers/plugins/automember/automember.c
@@ -2522,10 +2522,11 @@ void automember_map_task_thread(void *arg){
#if defined(USE_OPENLDAP)
int buflen = 0;
LDIFFP *ldif_fd_in = NULL;
+ ldif_record_lineno_t lineno = 0;
#else
PRFileDesc *ldif_fd_in = NULL;
-#endif
int lineno = 0;
+#endif
int rc = 0;
td = (task_data *)slapi_task_get_data(task);
diff --git a/ldap/servers/plugins/deref/deref.c b/ldap/servers/plugins/deref/deref.c
index 51394c8..6e4d4ec 100644
--- a/ldap/servers/plugins/deref/deref.c
+++ b/ldap/servers/plugins/deref/deref.c
@@ -440,7 +440,7 @@ deref_pre_search(Slapi_PBlock *pb)
int ldapcode = LDAP_SUCCESS;
const LDAPControl **reqctrls = NULL;
const LDAPControl *derefctrl = NULL;
- const char *ldaperrtext;
+ const char *ldaperrtext = "Unknown error";
const char *incompatible = NULL;
DerefSpecList *speclist = NULL;
int ii;
diff --git a/ldap/servers/plugins/http/http_impl.c b/ldap/servers/plugins/http/http_impl.c
index f96d75a..db02b67 100644
--- a/ldap/servers/plugins/http/http_impl.c
+++ b/ldap/servers/plugins/http/http_impl.c
@@ -260,7 +260,7 @@ static int doRequest(const char *url, httpheader **httpheaderArray, char *body,
PRInt32 port;
PRInt32 errcode = 0;
PRInt32 http_connection_time_out = 0;
- PRInt32 sslOn;
+ PRInt32 sslOn = 0;
LDAPDebug( LDAP_DEBUG_PLUGIN, "--> doRequest -- BEGIN\n",0,0,0);
@@ -1178,7 +1178,7 @@ SECStatus
struct SECKEYPrivateKeyStr **pRetKey)
{
CERTCertificate * cert;
- SECKEYPrivateKey * privKey;
+ SECKEYPrivateKey * privKey = NULL;
char * chosenNickName = (char *)arg;
void * proto_win = NULL;
SECStatus secStatus = SECFailure;
diff --git a/ldap/servers/plugins/pam_passthru/pam_ptimpl.c b/ldap/servers/plugins/pam_passthru/pam_ptimpl.c
index 69c08e8..2558b9e 100644
--- a/ldap/servers/plugins/pam_passthru/pam_ptimpl.c
+++ b/ldap/servers/plugins/pam_passthru/pam_ptimpl.c
@@ -263,7 +263,7 @@ do_one_pam_auth(
MyStrBuf pam_id;
const char *binddn = NULL;
Slapi_DN *bindsdn = NULL;
- int rc;
+ int rc = PAM_SUCCESS;
int retcode = LDAP_SUCCESS;
pam_handle_t *pam_handle;
struct my_pam_conv_str my_data;
diff --git a/ldap/servers/plugins/referint/referint.c b/ldap/servers/plugins/referint/referint.c
index 8f751da..4a722c1 100644
--- a/ldap/servers/plugins/referint/referint.c
+++ b/ldap/servers/plugins/referint/referint.c
@@ -896,7 +896,7 @@ void
referint_thread_func(void *arg)
{
char **plugin_argv = (char **)arg;
- PRFileDesc *prfd;
+ PRFileDesc *prfd = NULL;
char *logfilename;
char thisline[MAX_LINE];
int delay;
diff --git a/ldap/servers/plugins/replication/cl5_api.c b/ldap/servers/plugins/replication/cl5_api.c
index f9934f3..da25ab0 100644
--- a/ldap/servers/plugins/replication/cl5_api.c
+++ b/ldap/servers/plugins/replication/cl5_api.c
@@ -272,8 +272,8 @@ static CL5Desc s_cl5Desc;
/* changelog initialization and cleanup */
static int _cl5Open (const char *dir, const CL5DBConfig *config, CL5OpenMode openMode);
-static int _cl5AppInit (PRBool *didRecovery);
-static int _cl5DBOpen ();
+static int _cl5AppInit (void);
+static int _cl5DBOpen (void);
static void _cl5SetDefaultDBConfig ();
static void _cl5SetDBConfig (const CL5DBConfig *config);
static int _cl5CheckDBVersion ();
@@ -877,12 +877,13 @@ cl5ImportLDIF (const char *clDir, const char *ldifFile, Object **replicas)
#if defined(USE_OPENLDAP)
LDIFFP *file = NULL;
int buflen;
+ ldif_record_lineno_t lineno = 0;
#else
FILE *file = NULL;
+ int lineno = 0;
#endif
int rc;
char *buff = NULL;
- int lineno = 0;
slapi_operation_parameters op;
Object *prim_replica_obj = NULL;
Object *replica_obj = NULL;
@@ -1851,7 +1852,6 @@ int cl5GetOperationCount (Object *replica)
static int _cl5Open (const char *dir, const CL5DBConfig *config, CL5OpenMode openMode)
{
int rc;
- PRBool didRecovery;
PR_ASSERT (dir);
@@ -1899,7 +1899,7 @@ static int _cl5Open (const char *dir, const CL5DBConfig *config, CL5OpenMode ope
s_cl5Desc.dbOpenMode = openMode;
/* initialize db environment */
- rc = _cl5AppInit (&didRecovery);
+ rc = _cl5AppInit ();
if (rc != CL5_SUCCESS)
{
slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl,
@@ -1914,7 +1914,7 @@ static int _cl5Open (const char *dir, const CL5DBConfig *config, CL5OpenMode ope
}
/* open database files */
- rc = _cl5DBOpen (!didRecovery);
+ rc = _cl5DBOpen ();
if (rc != CL5_SUCCESS)
{
slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl,
@@ -1990,7 +1990,7 @@ int cl5CreateDirIfNeeded (const char *dirName)
return CL5_SUCCESS;
}
-static int _cl5AppInit (PRBool *didRecovery)
+static int _cl5AppInit (void)
{
int rc = -1; /* initialize to failure */
DB_ENV *dbEnv = NULL;
@@ -2854,7 +2854,7 @@ static int _cl5Upgrade3_4(char *fromVersion, char *toVersion)
backup = s_cl5Desc.dbOpenMode;
s_cl5Desc.dbOpenMode = CL5_OPEN_CLEAN_RECOVER;
/* CL5_OPEN_CLEAN_RECOVER does 1 and 2 */
- rc = _cl5AppInit (NULL);
+ rc = _cl5AppInit ();
if (rc != CL5_SUCCESS)
{
slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl,
@@ -2944,7 +2944,7 @@ static int _cl5Upgrade4_4(char *fromVersion, char *toVersion)
backup = s_cl5Desc.dbOpenMode;
s_cl5Desc.dbOpenMode = CL5_OPEN_CLEAN_RECOVER;
/* CL5_OPEN_CLEAN_RECOVER does 1 and 2 */
- rc = _cl5AppInit (NULL);
+ rc = _cl5AppInit ();
if (rc != CL5_SUCCESS)
{
slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl,
@@ -4224,7 +4224,7 @@ static int _cl5Operation2LDIF (const slapi_operation_parameters *op, const char
int len = 2;
lenstr *l = NULL;
const char *strType;
- char *strDeleteOldRDN;
+ const char *strDeleteOldRDN = "false";
char *buff, *start;
LDAPMod **add_mods;
char *rawDN = NULL;
diff --git a/ldap/servers/plugins/replication/windows_inc_protocol.c b/ldap/servers/plugins/replication/windows_inc_protocol.c
index af5d964..15d69a3 100644
--- a/ldap/servers/plugins/replication/windows_inc_protocol.c
+++ b/ldap/servers/plugins/replication/windows_inc_protocol.c
@@ -1176,7 +1176,7 @@ send_updates(Private_Repl_Protocol *prp, RUV *remote_update_vector, PRUint32 *nu
{
CL5Entry entry;
slapi_operation_parameters op;
- int return_value;
+ int return_value = UPDATE_NO_MORE_UPDATES;
int rc;
int set_mincsn = 0;
CL5ReplayIterator *changelog_iterator = NULL;
diff --git a/ldap/servers/plugins/replication/windows_private.c b/ldap/servers/plugins/replication/windows_private.c
index 20360a3..a103cad 100644
--- a/ldap/servers/plugins/replication/windows_private.c
+++ b/ldap/servers/plugins/replication/windows_private.c
@@ -1344,11 +1344,16 @@ windows_plugin_init(Repl_Agmt *ra)
{
struct winsync_plugin_cookie *list = NULL;
void *cookie = NULL;
- PRStatus rv;
LDAPDebug0Args( LDAP_DEBUG_PLUGIN, "--> windows_plugin_init_start -- begin\n");
- rv = PR_CallOnce(&winsync_callOnce, windows_plugin_callonce);
+ if (PR_CallOnce(&winsync_callOnce, windows_plugin_callonce)) {
+ PRErrorCode prerr = PR_GetError();
+ slapi_log_error(SLAPI_LOG_FATAL, "windows_plugin_init",
+ "cannot initialize plugin: %d:%s\n", prerr,
+ slapi_pr_strerror(prerr));
+ return;
+ }
/* call each plugin init function in turn - store the returned cookie
indexed by the api */
diff --git a/ldap/servers/plugins/usn/usn.c b/ldap/servers/plugins/usn/usn.c
index 0273fd1..4473618 100644
--- a/ldap/servers/plugins/usn/usn.c
+++ b/ldap/servers/plugins/usn/usn.c
@@ -673,7 +673,7 @@ usn_rootdse_search(Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry* entryAfter,
if (be && be->be_usn_counter) {
/* get a next USN counter from be_usn_counter;
* then minus 1 from it */
- PR_snprintf(usn_berval.bv_val, USN_COUNTER_BUF_LEN, "%" NSPRI64 "d",
+ PR_snprintf(usn_berval.bv_val, USN_COUNTER_BUF_LEN, "%" NSPRIu64,
slapi_counter_get_value(be->be_usn_counter)-1);
usn_berval.bv_len = strlen(usn_berval.bv_val);
slapi_entry_attr_replace(e, attr, vals);
@@ -692,7 +692,7 @@ usn_rootdse_search(Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry* entryAfter,
}
/* get a next USN counter from be_usn_counter;
* then minus 1 from it */
- PR_snprintf(usn_berval.bv_val, USN_COUNTER_BUF_LEN, "%" NSPRI64 "d",
+ PR_snprintf(usn_berval.bv_val, USN_COUNTER_BUF_LEN, "%" NSPRIu64,
slapi_counter_get_value(be->be_usn_counter)-1);
usn_berval.bv_len = strlen(usn_berval.bv_val);
diff --git a/ldap/servers/slapd/back-ldbm/import-threads.c b/ldap/servers/slapd/back-ldbm/import-threads.c
index 60dbb5f..78db060 100644
--- a/ldap/servers/slapd/back-ldbm/import-threads.c
+++ b/ldap/servers/slapd/back-ldbm/import-threads.c
@@ -3620,7 +3620,7 @@ _get_import_entryusn(ImportJob *job, Slapi_Value **usn_value)
* Use the counter which stores the old DB's
* next entryusn. */
PR_snprintf(counter_buf, USN_COUNTER_BUF_LEN,
- "%" NSPRI64 "d",
+ "%" NSPRIu64,
slapi_counter_get_value(be->be_usn_counter));
} else {
/* import_init value is digit.
diff --git a/ldap/servers/slapd/back-ldbm/monitor.c b/ldap/servers/slapd/back-ldbm/monitor.c
index 075a48f..e3e1fb5 100644
--- a/ldap/servers/slapd/back-ldbm/monitor.c
+++ b/ldap/servers/slapd/back-ldbm/monitor.c
@@ -214,13 +214,13 @@ int ldbm_back_monitor_instance_search(Slapi_PBlock *pb, Slapi_Entry *e,
#endif
MSETF("dbFilename-%d", i);
- sprintf(buf, "%u", mpfstat[i]->st_cache_hit);
+ sprintf(buf, "%lu", (unsigned long)mpfstat[i]->st_cache_hit);
MSETF("dbFileCacheHit-%d", i);
- sprintf(buf, "%u", mpfstat[i]->st_cache_miss);
+ sprintf(buf, "%lu", (unsigned long)mpfstat[i]->st_cache_miss);
MSETF("dbFileCacheMiss-%d", i);
- sprintf(buf, "%u", mpfstat[i]->st_page_in);
+ sprintf(buf, "%lu", (unsigned long)mpfstat[i]->st_page_in);
MSETF("dbFilePageIn-%d", i);
- sprintf(buf, "%u", mpfstat[i]->st_page_out);
+ sprintf(buf, "%lu", (unsigned long)mpfstat[i]->st_page_out);
MSETF("dbFilePageOut-%d", i);
slapi_ch_free_string(&absolute_pathname);
@@ -267,7 +267,7 @@ int ldbm_back_monitor_search(Slapi_PBlock *pb, Slapi_Entry *e,
}
/* cache hits*/
- sprintf(buf, "%u", mpstat->st_cache_hit);
+ sprintf(buf, "%lu", (unsigned long)mpstat->st_cache_hit);
MSET("dbCacheHits");
/* cache tries*/
@@ -279,13 +279,13 @@ int ldbm_back_monitor_search(Slapi_PBlock *pb, Slapi_Entry *e,
sprintf(buf, "%lu", (unsigned long)(100.0 * (double)mpstat->st_cache_hit / (double)(cache_tries > 0 ? cache_tries : 1) ));
MSET("dbCacheHitRatio");
- sprintf(buf, "%u", mpstat->st_page_in);
+ sprintf(buf, "%lu", (unsigned long)mpstat->st_page_in);
MSET("dbCachePageIn");
- sprintf(buf, "%u", mpstat->st_page_out);
+ sprintf(buf, "%lu", (unsigned long)mpstat->st_page_out);
MSET("dbCachePageOut");
- sprintf(buf, "%u", mpstat->st_ro_evict);
+ sprintf(buf, "%lu", (unsigned long)mpstat->st_ro_evict);
MSET("dbCacheROEvict");
- sprintf(buf, "%u", mpstat->st_rw_evict);
+ sprintf(buf, "%lu", (unsigned long)mpstat->st_rw_evict);
MSET("dbCacheRWEvict");
slapi_ch_free((void **)&mpstat);
diff --git a/ldap/servers/slapd/log.c b/ldap/servers/slapd/log.c
index a508908..3a31260 100644
--- a/ldap/servers/slapd/log.c
+++ b/ldap/servers/slapd/log.c
@@ -207,6 +207,15 @@ slapd_log_error_proc_internal(
/* Should be a flush in here ?? Yes because PR_SYNC doesn't work ! */ \
PR_Sync(fd); \
} while (0)
+#define LOG_WRITE_NOW_NO_ERR(fd, buffer, size, headersize) do {\
+ if ( slapi_write_buffer((fd), (buffer), (size)) != (size) ) \
+ { \
+ PRErrorCode prerr = PR_GetError(); \
+ syslog(LOG_ERR, "Failed to write log, " SLAPI_COMPONENT_NAME_NSPR " error %d (%s): %s\n", prerr, slapd_pr_strerror(prerr), (buffer)+(headersize) ); \
+ } \
+ /* Should be a flush in here ?? Yes because PR_SYNC doesn't work ! */ \
+ PR_Sync(fd); \
+ } while (0)
#define LOG_CLOSE(fd) \
PR_Close((fd))
#endif
@@ -1267,7 +1276,7 @@ int
log_set_maxdiskspace(const char *attrname, char *maxdiskspace_str, int logtype, char *errorbuf, int apply)
{
int rv = 0;
- PRInt64 mlogsize; /* in bytes */
+ PRInt64 mlogsize = 0; /* in bytes */
PRInt64 maxdiskspace; /* in bytes */
int s_maxdiskspace; /* in megabytes */
@@ -1500,7 +1509,7 @@ log_set_expirationtimeunit(const char *attrname, char *expunit, int logtype, cha
{
int value = 0;
int rv = 0;
- int exptime, rsecs;
+ int exptime = 0, rsecs = 0;
int *exptimeunitp = NULL;
slapdFrontendConfig_t *fe_cfg = getFrontendConfig();
@@ -1616,12 +1625,11 @@ log_write_title (LOGFD fp)
char *buildnum = config_get_buildnum();
char buff[512];
int bufflen = sizeof(buff);
- int err = 0;
PR_snprintf(buff, bufflen, "\t%s B%s\n",
fe_cfg->versionstring ? fe_cfg->versionstring : CAPBRAND "-Directory/" DS_PACKAGE_VERSION,
buildnum ? buildnum : "");
- LOG_WRITE_NOW(fp, buff, strlen(buff), 0, err);
+ LOG_WRITE_NOW_NO_ERR(fp, buff, strlen(buff), 0);
if (fe_cfg->localhost) {
PR_snprintf(buff, bufflen, "\t%s:%d (%s)\n\n",
@@ -1636,7 +1644,7 @@ log_write_title (LOGFD fp)
PR_snprintf(buff, bufflen, "\t<host>:<port> (%s)\n\n",
fe_cfg->configdir ? fe_cfg->configdir : "");
}
- LOG_WRITE_NOW(fp, buff, strlen(buff), 0, err);
+ LOG_WRITE_NOW_NO_ERR(fp, buff, strlen(buff), 0);
slapi_ch_free((void **)&buildnum);
}
@@ -1723,7 +1731,6 @@ slapd_log_audit_proc (
int buf_len)
{
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) {
@@ -1742,7 +1749,7 @@ slapd_log_audit_proc (
log_write_title( loginfo.log_audit_fdes);
loginfo.log_audit_state &= ~LOGGING_NEED_TITLE;
}
- LOG_WRITE_NOW(loginfo.log_audit_fdes, buffer, buf_len, 0, err);
+ LOG_WRITE_NOW_NO_ERR(loginfo.log_audit_fdes, buffer, buf_len, 0);
LOG_AUDIT_UNLOCK_WRITE();
return 0;
}
@@ -4144,7 +4151,6 @@ static void log_flush_buffer(LogBufferInfo *lbi, int type, int sync_now)
slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
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) {
@@ -4175,8 +4181,8 @@ static void log_flush_buffer(LogBufferInfo *lbi, int type, int sync_now)
if (!sync_now && slapdFrontendConfig->accesslogbuffering) {
LOG_WRITE(loginfo.log_access_fdes, lbi->top, lbi->current - lbi->top, 0);
} else {
- LOG_WRITE_NOW(loginfo.log_access_fdes, lbi->top,
- lbi->current - lbi->top, 0, err);
+ LOG_WRITE_NOW_NO_ERR(loginfo.log_access_fdes, lbi->top,
+ lbi->current - lbi->top, 0);
}
lbi->current = lbi->top;
diff --git a/ldap/servers/slapd/mapping_tree.c b/ldap/servers/slapd/mapping_tree.c
index da8e4f3..19c5708 100644
--- a/ldap/servers/slapd/mapping_tree.c
+++ b/ldap/servers/slapd/mapping_tree.c
@@ -158,8 +158,10 @@ static mapping_tree_node *
static int _mtn_update_config_param(int op, char *type, char *strvalue);
#ifdef DEBUG
+#ifdef USE_DUMP_MAPPING_TREE
static void dump_mapping_tree(mapping_tree_node *parent, int depth);
#endif
+#endif
/* structure and static local variable used to store the
* list of plugins that have registered to a callback when backend state
@@ -3721,6 +3723,7 @@ void test_register()
#endif
#ifdef DEBUG
+#ifdef USE_DUMP_MAPPING_TREE
static void dump_mapping_tree(mapping_tree_node *parent, int depth)
{
mapping_tree_node *current = NULL;
@@ -3751,7 +3754,8 @@ static void dump_mapping_tree(mapping_tree_node *parent, int depth)
}
return;
}
-#endif
+#endif /* USE_DUMP_MAPPING_TREE */
+#endif /* DEBUG */
/* helper function to set/remove the config param in cn=config */
static int
diff --git a/ldap/servers/slapd/regex.c b/ldap/servers/slapd/regex.c
index 3697fde..29edffe 100644
--- a/ldap/servers/slapd/regex.c
+++ b/ldap/servers/slapd/regex.c
@@ -161,7 +161,7 @@ slapi_re_subs_ext( Slapi_Regex *re_handle, const char *subject,
int pin;
int *ovector;
char *mydst;
- const char *prev, *next;
+ const char *prev;
const char *substring_start;
const char *p;
@@ -179,8 +179,7 @@ slapi_re_subs_ext( Slapi_Regex *re_handle, const char *subject,
for (p = src; *p != '\0'; p++) {
if ('&' == *p) {
/* Don't replace '&' if it's a filter AND: "(&(cn=a)(sn=b))" */
- next = p;
- if(!filter || (*prev != '(' && *next++ != '(')){
+ if(!filter || !(*prev == '(' && *(p+1) == '(')){
if (re_handle->re_oveccount <= 1) {
memset(*dst, '\0', dstlen);
return -1;
@@ -188,6 +187,11 @@ slapi_re_subs_ext( Slapi_Regex *re_handle, const char *subject,
substring_start = subject + ovector[0];
thislen = ovector[1] - ovector[0];
len += thislen;
+ } else { /* is a filter AND clause */
+ /* just copy it into the filter */
+ substring_start = p;
+ thislen = 1;
+ len++;
}
} else if (('\\' == *p) && ('0' <= *(p+1) && *(p+1) <= '9')) {
pin = *(++p) - '0';
diff --git a/ldap/servers/slapd/slapi-plugin.h b/ldap/servers/slapd/slapi-plugin.h
index f78787e..4e7aae5 100644
--- a/ldap/servers/slapd/slapi-plugin.h
+++ b/ldap/servers/slapd/slapi-plugin.h
@@ -6849,6 +6849,15 @@ int slapi_ldap_get_lderrno(LDAP *ld, char **m, char **s);
#endif
void slapi_ldif_put_type_and_value_with_options( char **out, const char *t, const char *val, int vlen, unsigned long options );
+/* ldif_read_record lineno argument type depends on openldap version */
+#if defined(USE_OPENLDAP)
+#if LDAP_VENDOR_VERSION >= 20434 /* changed in 2.4.34 */
+typedef unsigned long int ldif_record_lineno_t;
+#else
+typedef int ldif_record_lineno_t;
+#endif
+#endif
+
#if defined(USE_OPENLDAP)
/*
* UTF-8 routines (should these move into libnls?)
diff --git a/ldap/servers/slapd/tools/ldclt/ldapfct.c b/ldap/servers/slapd/tools/ldclt/ldapfct.c
index 3f74fd0..b177d7c 100644
--- a/ldap/servers/slapd/tools/ldclt/ldapfct.c
+++ b/ldap/servers/slapd/tools/ldclt/ldapfct.c
@@ -732,10 +732,8 @@ LDAP *
connectToLDAP(thread_context *tttctx, const char *bufBindDN, const char *bufPasswd, unsigned int mode, unsigned int mod2)
{
LDAP *ld = NULL;
- const char *mech = LDAP_SASL_SIMPLE;
struct berval cred = {0, NULL};
int v2v3 = LDAP_VERSION3;
- const char *binddn = NULL;
const char *passwd = NULL;
#if defined(USE_OPENLDAP)
char *ldapurl = NULL;
@@ -863,11 +861,8 @@ connectToLDAP(thread_context *tttctx, const char *bufBindDN, const char *bufPass
#endif /* !USE_OPENLDAP */
if (mode & CLTAUTH) {
- mech = "EXTERNAL";
- binddn = "";
passwd = NULL;
} else {
- binddn = bufBindDN?bufBindDN:mctx.bindDN;
passwd = bufPasswd?bufPasswd:mctx.passwd;
if (passwd) {
cred.bv_val = (char *)passwd;
diff --git a/ldap/servers/slapd/tools/rsearch/infadd.c b/ldap/servers/slapd/tools/rsearch/infadd.c
index 607381a..4a9f2e9 100644
--- a/ldap/servers/slapd/tools/rsearch/infadd.c
+++ b/ldap/servers/slapd/tools/rsearch/infadd.c
@@ -127,11 +127,10 @@ char *randName(void)
return x;
}
-int fill_table(NameTable *nt, PRUint32 size)
+void fill_table(NameTable *nt, PRUint32 size)
{
PRUint32 i;
char *x;
- int ret;
fprintf(stdout, "Generating random names: 0 ");
for (i = 0; i < size; i++) {
@@ -141,13 +140,13 @@ int fill_table(NameTable *nt, PRUint32 size)
free(x);
x = randName();
}
- ret = nt_push(nt, x);
+ (void)nt_push(nt, x);
if ((i % 100) == 0) {
fprintf(stdout, "\b\b\b\b\b\b\b%-7d", i);
}
}
fprintf(stdout, "\b\b\b\b\b\b\b%d. Done.\n", size);
- return ret;
+ return;
}
int main(int argc, char **argv)
diff --git a/ldap/servers/snmp/main.c b/ldap/servers/snmp/main.c
index ca3fc1c..78d4814 100644
--- a/ldap/servers/snmp/main.c
+++ b/ldap/servers/snmp/main.c
@@ -236,6 +236,15 @@ main (int argc, char *argv[]) {
return 0;
}
+/* ldif_read_record lineno argument type depends on openldap version */
+#if defined(USE_OPENLDAP)
+#if LDAP_VENDOR_VERSION >= 20434 /* changed in 2.4.34 */
+typedef unsigned long int ldif_record_lineno_t;
+#else
+typedef int ldif_record_lineno_t;
+#endif
+#endif
+
/************************************************************************
* load_config
*
@@ -249,8 +258,10 @@ load_config(char *conf_path)
#if defined(USE_OPENLDAP)
LDIFFP *dse_fp = NULL;
int buflen = 0;
+ ldif_record_lineno_t lineno = 0;
#else
FILE *dse_fp = NULL;
+ int lineno = 0;
#endif
char line[MAXLINE];
char *p = NULL;
@@ -332,10 +343,10 @@ load_config(char *conf_path)
} else if ((p = strstr(line, "server")) != NULL) {
int got_port = 0;
int got_rundir = 0;
- int lineno = 0;
char *entry = NULL;
char *instancename = NULL;
+ lineno = 0;
/* Allocate a server_instance */
if ((serv_p = malloc(sizeof(server_instance))) == NULL) {
printf("ldap-agent: malloc error processing config file\n");
diff --git a/lib/libaccess/acltools.cpp b/lib/libaccess/acltools.cpp
index df08658..4c1d28c 100644
--- a/lib/libaccess/acltools.cpp
+++ b/lib/libaccess/acltools.cpp
@@ -1741,7 +1741,7 @@ static PList_t ACLAttr2IndexPList = NULL;
int
ACL_InitAttr2Index(void)
{
- int i;
+ intptr_t i;
if (ACLAttr2IndexPList) return 0;
diff --git a/lib/libaccess/register.cpp b/lib/libaccess/register.cpp
index 766436e..798a926 100644
--- a/lib/libaccess/register.cpp
+++ b/lib/libaccess/register.cpp
@@ -77,6 +77,8 @@ ACL_LasHashInit()
{
int i;
+ (void)(link_ACLGlobal); /* get rid of defined but not used compiler warning */
+ (void)(link_nsacl_table); /* get rid of defined but not used compiler warning */
ACLLasEvalHash = PR_NewHashTable(0,
PR_HashString,
PR_CompareStrings,
@@ -268,11 +270,11 @@ ACL_MethodRegister(NSErr_t *errp, const char *name, ACLMethod_t *t)
}
/* Put it in the hash table */
- if (NULL == PR_HashTableAdd(ACLMethodHash, name, (void *)++cur_method)) {
+ if (NULL == PR_HashTableAdd(ACLMethodHash, name, (void *)(intptr_t)++cur_method)) {
ACL_CritExit();
return -1;
}
- *t = (ACLMethod_t) cur_method;
+ *t = (ACLMethod_t) (intptr_t)cur_method;
ACL_CritExit();
return 0;
@@ -412,11 +414,11 @@ ACL_DbTypeRegister(NSErr_t *errp, const char *name, DbParseFn_t func, ACLDbType_
}
/* Put it in the hash table */
- if (NULL == PR_HashTableAdd(ACLDbTypeHash, name, (void *)++cur_dbtype)) {
+ if (NULL == PR_HashTableAdd(ACLDbTypeHash, name, (void *)(intptr_t)++cur_dbtype)) {
ACL_CritExit();
return -1;
}
- *t = (ACLDbType_t) cur_dbtype;
+ *t = (ACLDbType_t) (intptr_t)cur_dbtype;
ACLDbParseFnTable[cur_dbtype] = func;
ACL_CritExit();
10 years, 11 months
Branch '389-ds-base-1.3.1' - ldap/servers lib/libaccess
by Richard Allen Megginson
ldap/servers/plugins/acct_usability/acct_usability.c | 2 -
ldap/servers/plugins/acl/acl_ext.c | 2 -
ldap/servers/plugins/acl/aclutil.c | 3 +
ldap/servers/plugins/automember/automember.c | 3 +
ldap/servers/plugins/deref/deref.c | 2 -
ldap/servers/plugins/http/http_impl.c | 4 +-
ldap/servers/plugins/pam_passthru/pam_ptimpl.c | 2 -
ldap/servers/plugins/referint/referint.c | 2 -
ldap/servers/plugins/replication/cl5_api.c | 20 ++++++------
ldap/servers/plugins/replication/windows_inc_protocol.c | 2 -
ldap/servers/plugins/replication/windows_private.c | 9 ++++-
ldap/servers/plugins/usn/usn.c | 4 +-
ldap/servers/slapd/back-ldbm/import-threads.c | 2 -
ldap/servers/slapd/back-ldbm/monitor.c | 18 +++++------
ldap/servers/slapd/log.c | 26 +++++++++-------
ldap/servers/slapd/mapping_tree.c | 6 +++
ldap/servers/slapd/regex.c | 10 ++++--
ldap/servers/slapd/slapi-plugin.h | 9 +++++
ldap/servers/slapd/tools/ldclt/ldapfct.c | 5 ---
ldap/servers/slapd/tools/rsearch/infadd.c | 7 +---
ldap/servers/snmp/main.c | 13 +++++++-
lib/libaccess/acltools.cpp | 2 -
lib/libaccess/lasdns.cpp | 1
lib/libaccess/register.cpp | 10 +++---
24 files changed, 100 insertions(+), 64 deletions(-)
New commits:
commit f77de00bb756cfbc275f8ce4ce1a6b8ecb16cbbb
Author: Rich Megginson <rmeggins(a)redhat.com>
Date: Wed Jun 5 11:30:13 2013 -0600
Ticket #47378 - fix recent compiler warnings
https://fedorahosted.org/389/ticket/47378
Reviewed by: nhosoi (Thanks!)
Branch: master
Fix Description: Fix the various compiler warnings as reported by
http://jenkins.cloud.fedoraproject.org/job/389-ds-base/ws/build-warns.137...
In addition, fixed a bug in the slapi_re_subs_ext - if there was an
ampersand that did not need to be replaced, that is, if the ampersand
was part of an LDAP search filter, it was replaced with a '('. Also, an
ampersand preceeded by an open parenthesis and followed by a non-open
parenthesis is supposed to be replaced in the string, but this was not
working.
Platforms tested: RHEL6 x86_64
Flag Day: no
Doc impact: no
diff --git a/ldap/servers/plugins/acct_usability/acct_usability.c b/ldap/servers/plugins/acct_usability/acct_usability.c
index 19e55c3..f41f934 100644
--- a/ldap/servers/plugins/acct_usability/acct_usability.c
+++ b/ldap/servers/plugins/acct_usability/acct_usability.c
@@ -312,7 +312,7 @@ auc_pre_search(Slapi_PBlock *pb)
int ldapcode = LDAP_SUCCESS;
const LDAPControl **reqctrls = NULL;
const LDAPControl *aucctrl = NULL;
- const char *ldaperrtext;
+ const char *ldaperrtext = "Unknown error";
const char *incompatible = NULL;
int isroot = 0;
int ii;
diff --git a/ldap/servers/plugins/acl/acl_ext.c b/ldap/servers/plugins/acl/acl_ext.c
index f8699b4..e42a7e2 100644
--- a/ldap/servers/plugins/acl/acl_ext.c
+++ b/ldap/servers/plugins/acl/acl_ext.c
@@ -128,7 +128,7 @@ acl_get_ext (ext_type type, void *object)
void
acl_set_ext (ext_type type, void *object, void *data)
{
- if ( type >= 0 && type < ACL_EXT_ALL )
+ if ( type < ACL_EXT_ALL )
{
struct acl_ext ext = acl_ext_list [type];
slapi_set_object_extension ( ext.object_type, object, ext.handle, data );
diff --git a/ldap/servers/plugins/acl/aclutil.c b/ldap/servers/plugins/acl/aclutil.c
index 7097540..5969b26 100644
--- a/ldap/servers/plugins/acl/aclutil.c
+++ b/ldap/servers/plugins/acl/aclutil.c
@@ -96,6 +96,7 @@ aclutil_str_append_ext(char **dest, size_t *dlen, const char *src, size_t slen)
char *ptr = NULL;
int rc = 0;
+ PR_ASSERT(NULL != dlen);
if ( dest == NULL || src == NULL ) {
return rc;
}
@@ -103,7 +104,7 @@ aclutil_str_append_ext(char **dest, size_t *dlen, const char *src, size_t slen)
if (0 == slen) {
slen = strlen(src);
}
- if (*dest && dlen > 0) {
+ if (*dest && *dlen > 0) {
size_t dest_strlen = strlen(*dest);
size_t new_len = dest_strlen + slen + 1;
if (new_len > *dlen) {
diff --git a/ldap/servers/plugins/automember/automember.c b/ldap/servers/plugins/automember/automember.c
index 424b507..49f47f7 100644
--- a/ldap/servers/plugins/automember/automember.c
+++ b/ldap/servers/plugins/automember/automember.c
@@ -2522,10 +2522,11 @@ void automember_map_task_thread(void *arg){
#if defined(USE_OPENLDAP)
int buflen = 0;
LDIFFP *ldif_fd_in = NULL;
+ ldif_record_lineno_t lineno = 0;
#else
PRFileDesc *ldif_fd_in = NULL;
-#endif
int lineno = 0;
+#endif
int rc = 0;
td = (task_data *)slapi_task_get_data(task);
diff --git a/ldap/servers/plugins/deref/deref.c b/ldap/servers/plugins/deref/deref.c
index 2601170..8414452 100644
--- a/ldap/servers/plugins/deref/deref.c
+++ b/ldap/servers/plugins/deref/deref.c
@@ -441,7 +441,7 @@ deref_pre_search(Slapi_PBlock *pb)
int ldapcode = LDAP_SUCCESS;
const LDAPControl **reqctrls = NULL;
const LDAPControl *derefctrl = NULL;
- const char *ldaperrtext;
+ const char *ldaperrtext = "Unknown error";
const char *incompatible = NULL;
DerefSpecList *speclist = NULL;
int ii;
diff --git a/ldap/servers/plugins/http/http_impl.c b/ldap/servers/plugins/http/http_impl.c
index f96d75a..db02b67 100644
--- a/ldap/servers/plugins/http/http_impl.c
+++ b/ldap/servers/plugins/http/http_impl.c
@@ -260,7 +260,7 @@ static int doRequest(const char *url, httpheader **httpheaderArray, char *body,
PRInt32 port;
PRInt32 errcode = 0;
PRInt32 http_connection_time_out = 0;
- PRInt32 sslOn;
+ PRInt32 sslOn = 0;
LDAPDebug( LDAP_DEBUG_PLUGIN, "--> doRequest -- BEGIN\n",0,0,0);
@@ -1178,7 +1178,7 @@ SECStatus
struct SECKEYPrivateKeyStr **pRetKey)
{
CERTCertificate * cert;
- SECKEYPrivateKey * privKey;
+ SECKEYPrivateKey * privKey = NULL;
char * chosenNickName = (char *)arg;
void * proto_win = NULL;
SECStatus secStatus = SECFailure;
diff --git a/ldap/servers/plugins/pam_passthru/pam_ptimpl.c b/ldap/servers/plugins/pam_passthru/pam_ptimpl.c
index 69c08e8..2558b9e 100644
--- a/ldap/servers/plugins/pam_passthru/pam_ptimpl.c
+++ b/ldap/servers/plugins/pam_passthru/pam_ptimpl.c
@@ -263,7 +263,7 @@ do_one_pam_auth(
MyStrBuf pam_id;
const char *binddn = NULL;
Slapi_DN *bindsdn = NULL;
- int rc;
+ int rc = PAM_SUCCESS;
int retcode = LDAP_SUCCESS;
pam_handle_t *pam_handle;
struct my_pam_conv_str my_data;
diff --git a/ldap/servers/plugins/referint/referint.c b/ldap/servers/plugins/referint/referint.c
index beb5f9f..234c322 100644
--- a/ldap/servers/plugins/referint/referint.c
+++ b/ldap/servers/plugins/referint/referint.c
@@ -921,7 +921,7 @@ int referint_postop_close( Slapi_PBlock *pb)
void
referint_thread_func(void *arg)
{
- PRFileDesc *prfd;
+ PRFileDesc *prfd = NULL;
char **plugin_argv = (char **)arg;
char *logfilename;
char thisline[MAX_LINE];
diff --git a/ldap/servers/plugins/replication/cl5_api.c b/ldap/servers/plugins/replication/cl5_api.c
index 63b2b99..b29fa2e 100644
--- a/ldap/servers/plugins/replication/cl5_api.c
+++ b/ldap/servers/plugins/replication/cl5_api.c
@@ -277,8 +277,8 @@ static CL5Desc s_cl5Desc;
/* changelog initialization and cleanup */
static int _cl5Open (const char *dir, const CL5DBConfig *config, CL5OpenMode openMode);
-static int _cl5AppInit (PRBool *didRecovery);
-static int _cl5DBOpen ();
+static int _cl5AppInit (void);
+static int _cl5DBOpen (void);
static void _cl5SetDefaultDBConfig ();
static void _cl5SetDBConfig (const CL5DBConfig *config);
static int _cl5CheckDBVersion ();
@@ -882,12 +882,13 @@ cl5ImportLDIF (const char *clDir, const char *ldifFile, Object **replicas)
#if defined(USE_OPENLDAP)
LDIFFP *file = NULL;
int buflen;
+ ldif_record_lineno_t lineno = 0;
#else
FILE *file = NULL;
+ int lineno = 0;
#endif
int rc;
char *buff = NULL;
- int lineno = 0;
slapi_operation_parameters op;
Object *prim_replica_obj = NULL;
Object *replica_obj = NULL;
@@ -1856,7 +1857,6 @@ int cl5GetOperationCount (Object *replica)
static int _cl5Open (const char *dir, const CL5DBConfig *config, CL5OpenMode openMode)
{
int rc;
- PRBool didRecovery;
PR_ASSERT (dir);
@@ -1904,7 +1904,7 @@ static int _cl5Open (const char *dir, const CL5DBConfig *config, CL5OpenMode ope
s_cl5Desc.dbOpenMode = openMode;
/* initialize db environment */
- rc = _cl5AppInit (&didRecovery);
+ rc = _cl5AppInit ();
if (rc != CL5_SUCCESS)
{
slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl,
@@ -1919,7 +1919,7 @@ static int _cl5Open (const char *dir, const CL5DBConfig *config, CL5OpenMode ope
}
/* open database files */
- rc = _cl5DBOpen (!didRecovery);
+ rc = _cl5DBOpen ();
if (rc != CL5_SUCCESS)
{
slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name_cl,
@@ -1995,7 +1995,7 @@ int cl5CreateDirIfNeeded (const char *dirName)
return CL5_SUCCESS;
}
-static int _cl5AppInit (PRBool *didRecovery)
+static int _cl5AppInit (void)
{
int rc = -1; /* initialize to failure */
DB_ENV *dbEnv = NULL;
@@ -2889,7 +2889,7 @@ static int _cl5UpgradeMajor(char *fromVersion, char *toVersion)
backup = s_cl5Desc.dbOpenMode;
s_cl5Desc.dbOpenMode = CL5_OPEN_CLEAN_RECOVER;
/* CL5_OPEN_CLEAN_RECOVER does 1 and 2 */
- rc = _cl5AppInit (NULL);
+ rc = _cl5AppInit ();
if (rc != CL5_SUCCESS)
{
slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl,
@@ -2984,7 +2984,7 @@ static int _cl5UpgradeMinor(char *fromVersion, char *toVersion)
backup = s_cl5Desc.dbOpenMode;
s_cl5Desc.dbOpenMode = CL5_OPEN_CLEAN_RECOVER;
/* CL5_OPEN_CLEAN_RECOVER does 1 and 2 */
- rc = _cl5AppInit (NULL);
+ rc = _cl5AppInit ();
if (rc != CL5_SUCCESS)
{
slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name_cl,
@@ -4264,7 +4264,7 @@ static int _cl5Operation2LDIF (const slapi_operation_parameters *op, const char
int len = 2;
lenstr *l = NULL;
const char *strType;
- char *strDeleteOldRDN;
+ const char *strDeleteOldRDN = "false";
char *buff, *start;
LDAPMod **add_mods;
char *rawDN = NULL;
diff --git a/ldap/servers/plugins/replication/windows_inc_protocol.c b/ldap/servers/plugins/replication/windows_inc_protocol.c
index e503f30..58f48f2 100644
--- a/ldap/servers/plugins/replication/windows_inc_protocol.c
+++ b/ldap/servers/plugins/replication/windows_inc_protocol.c
@@ -1174,7 +1174,7 @@ send_updates(Private_Repl_Protocol *prp, RUV *remote_update_vector, PRUint32 *nu
{
CL5Entry entry;
slapi_operation_parameters op;
- int return_value;
+ int return_value = UPDATE_NO_MORE_UPDATES;
int rc;
int set_mincsn = 0;
CL5ReplayIterator *changelog_iterator = NULL;
diff --git a/ldap/servers/plugins/replication/windows_private.c b/ldap/servers/plugins/replication/windows_private.c
index 3bdd0c1..e0dc8ca 100644
--- a/ldap/servers/plugins/replication/windows_private.c
+++ b/ldap/servers/plugins/replication/windows_private.c
@@ -1355,11 +1355,16 @@ windows_plugin_init(Repl_Agmt *ra)
{
struct winsync_plugin_cookie *list = NULL;
void *cookie = NULL;
- PRStatus rv;
LDAPDebug0Args( LDAP_DEBUG_PLUGIN, "--> windows_plugin_init_start -- begin\n");
- rv = PR_CallOnce(&winsync_callOnce, windows_plugin_callonce);
+ if (PR_CallOnce(&winsync_callOnce, windows_plugin_callonce)) {
+ PRErrorCode prerr = PR_GetError();
+ slapi_log_error(SLAPI_LOG_FATAL, "windows_plugin_init",
+ "cannot initialize plugin: %d:%s\n", prerr,
+ slapi_pr_strerror(prerr));
+ return;
+ }
/* call each plugin init function in turn - store the returned cookie
indexed by the api */
diff --git a/ldap/servers/plugins/usn/usn.c b/ldap/servers/plugins/usn/usn.c
index 0273fd1..4473618 100644
--- a/ldap/servers/plugins/usn/usn.c
+++ b/ldap/servers/plugins/usn/usn.c
@@ -673,7 +673,7 @@ usn_rootdse_search(Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry* entryAfter,
if (be && be->be_usn_counter) {
/* get a next USN counter from be_usn_counter;
* then minus 1 from it */
- PR_snprintf(usn_berval.bv_val, USN_COUNTER_BUF_LEN, "%" NSPRI64 "d",
+ PR_snprintf(usn_berval.bv_val, USN_COUNTER_BUF_LEN, "%" NSPRIu64,
slapi_counter_get_value(be->be_usn_counter)-1);
usn_berval.bv_len = strlen(usn_berval.bv_val);
slapi_entry_attr_replace(e, attr, vals);
@@ -692,7 +692,7 @@ usn_rootdse_search(Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry* entryAfter,
}
/* get a next USN counter from be_usn_counter;
* then minus 1 from it */
- PR_snprintf(usn_berval.bv_val, USN_COUNTER_BUF_LEN, "%" NSPRI64 "d",
+ PR_snprintf(usn_berval.bv_val, USN_COUNTER_BUF_LEN, "%" NSPRIu64,
slapi_counter_get_value(be->be_usn_counter)-1);
usn_berval.bv_len = strlen(usn_berval.bv_val);
diff --git a/ldap/servers/slapd/back-ldbm/import-threads.c b/ldap/servers/slapd/back-ldbm/import-threads.c
index 3828080..d9ab51f 100644
--- a/ldap/servers/slapd/back-ldbm/import-threads.c
+++ b/ldap/servers/slapd/back-ldbm/import-threads.c
@@ -3985,7 +3985,7 @@ _get_import_entryusn(ImportJob *job, Slapi_Value **usn_value)
* Use the counter which stores the old DB's
* next entryusn. */
PR_snprintf(counter_buf, USN_COUNTER_BUF_LEN,
- "%" NSPRI64 "d",
+ "%" NSPRIu64,
slapi_counter_get_value(be->be_usn_counter));
} else {
/* import_init value is digit.
diff --git a/ldap/servers/slapd/back-ldbm/monitor.c b/ldap/servers/slapd/back-ldbm/monitor.c
index 1a06a25..49edb68 100644
--- a/ldap/servers/slapd/back-ldbm/monitor.c
+++ b/ldap/servers/slapd/back-ldbm/monitor.c
@@ -238,13 +238,13 @@ int ldbm_back_monitor_instance_search(Slapi_PBlock *pb, Slapi_Entry *e,
#endif
MSETF("dbFilename-%d", i);
- sprintf(buf, "%u", mpfstat[i]->st_cache_hit);
+ sprintf(buf, "%lu", (unsigned long)mpfstat[i]->st_cache_hit);
MSETF("dbFileCacheHit-%d", i);
- sprintf(buf, "%u", mpfstat[i]->st_cache_miss);
+ sprintf(buf, "%lu", (unsigned long)mpfstat[i]->st_cache_miss);
MSETF("dbFileCacheMiss-%d", i);
- sprintf(buf, "%u", mpfstat[i]->st_page_in);
+ sprintf(buf, "%lu", (unsigned long)mpfstat[i]->st_page_in);
MSETF("dbFilePageIn-%d", i);
- sprintf(buf, "%u", mpfstat[i]->st_page_out);
+ sprintf(buf, "%lu", (unsigned long)mpfstat[i]->st_page_out);
MSETF("dbFilePageOut-%d", i);
slapi_ch_free_string(&absolute_pathname);
@@ -291,7 +291,7 @@ int ldbm_back_monitor_search(Slapi_PBlock *pb, Slapi_Entry *e,
}
/* cache hits*/
- sprintf(buf, "%u", mpstat->st_cache_hit);
+ sprintf(buf, "%lu", (unsigned long)mpstat->st_cache_hit);
MSET("dbCacheHits");
/* cache tries*/
@@ -303,13 +303,13 @@ int ldbm_back_monitor_search(Slapi_PBlock *pb, Slapi_Entry *e,
sprintf(buf, "%lu", (unsigned long)(100.0 * (double)mpstat->st_cache_hit / (double)(cache_tries > 0 ? cache_tries : 1) ));
MSET("dbCacheHitRatio");
- sprintf(buf, "%u", mpstat->st_page_in);
+ sprintf(buf, "%lu", (unsigned long)mpstat->st_page_in);
MSET("dbCachePageIn");
- sprintf(buf, "%u", mpstat->st_page_out);
+ sprintf(buf, "%lu", (unsigned long)mpstat->st_page_out);
MSET("dbCachePageOut");
- sprintf(buf, "%u", mpstat->st_ro_evict);
+ sprintf(buf, "%lu", (unsigned long)mpstat->st_ro_evict);
MSET("dbCacheROEvict");
- sprintf(buf, "%u", mpstat->st_rw_evict);
+ sprintf(buf, "%lu", (unsigned long)mpstat->st_rw_evict);
MSET("dbCacheRWEvict");
slapi_ch_free((void **)&mpstat);
diff --git a/ldap/servers/slapd/log.c b/ldap/servers/slapd/log.c
index cab82d5..5873c11 100644
--- a/ldap/servers/slapd/log.c
+++ b/ldap/servers/slapd/log.c
@@ -207,6 +207,15 @@ slapd_log_error_proc_internal(
/* Should be a flush in here ?? Yes because PR_SYNC doesn't work ! */ \
PR_Sync(fd); \
} while (0)
+#define LOG_WRITE_NOW_NO_ERR(fd, buffer, size, headersize) do {\
+ if ( slapi_write_buffer((fd), (buffer), (size)) != (size) ) \
+ { \
+ PRErrorCode prerr = PR_GetError(); \
+ syslog(LOG_ERR, "Failed to write log, " SLAPI_COMPONENT_NAME_NSPR " error %d (%s): %s\n", prerr, slapd_pr_strerror(prerr), (buffer)+(headersize) ); \
+ } \
+ /* Should be a flush in here ?? Yes because PR_SYNC doesn't work ! */ \
+ PR_Sync(fd); \
+ } while (0)
#define LOG_CLOSE(fd) \
PR_Close((fd))
#endif
@@ -1267,7 +1276,7 @@ int
log_set_maxdiskspace(const char *attrname, char *maxdiskspace_str, int logtype, char *errorbuf, int apply)
{
int rv = 0;
- PRInt64 mlogsize; /* in bytes */
+ PRInt64 mlogsize = 0; /* in bytes */
PRInt64 maxdiskspace; /* in bytes */
int s_maxdiskspace; /* in megabytes */
@@ -1500,7 +1509,7 @@ log_set_expirationtimeunit(const char *attrname, char *expunit, int logtype, cha
{
int value = 0;
int rv = 0;
- int exptime, rsecs;
+ int exptime = 0, rsecs = 0;
int *exptimeunitp = NULL;
slapdFrontendConfig_t *fe_cfg = getFrontendConfig();
@@ -1616,12 +1625,11 @@ log_write_title (LOGFD fp)
char *buildnum = config_get_buildnum();
char buff[512];
int bufflen = sizeof(buff);
- int err = 0;
PR_snprintf(buff, bufflen, "\t%s B%s\n",
fe_cfg->versionstring ? fe_cfg->versionstring : CAPBRAND "-Directory/" DS_PACKAGE_VERSION,
buildnum ? buildnum : "");
- LOG_WRITE_NOW(fp, buff, strlen(buff), 0, err);
+ LOG_WRITE_NOW_NO_ERR(fp, buff, strlen(buff), 0);
if (fe_cfg->localhost) {
PR_snprintf(buff, bufflen, "\t%s:%d (%s)\n\n",
@@ -1636,7 +1644,7 @@ log_write_title (LOGFD fp)
PR_snprintf(buff, bufflen, "\t<host>:<port> (%s)\n\n",
fe_cfg->configdir ? fe_cfg->configdir : "");
}
- LOG_WRITE_NOW(fp, buff, strlen(buff), 0, err);
+ LOG_WRITE_NOW_NO_ERR(fp, buff, strlen(buff), 0);
slapi_ch_free((void **)&buildnum);
}
@@ -1723,7 +1731,6 @@ slapd_log_audit_proc (
int buf_len)
{
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) {
@@ -1742,7 +1749,7 @@ slapd_log_audit_proc (
log_write_title( loginfo.log_audit_fdes);
loginfo.log_audit_state &= ~LOGGING_NEED_TITLE;
}
- LOG_WRITE_NOW(loginfo.log_audit_fdes, buffer, buf_len, 0, err);
+ LOG_WRITE_NOW_NO_ERR(loginfo.log_audit_fdes, buffer, buf_len, 0);
LOG_AUDIT_UNLOCK_WRITE();
return 0;
}
@@ -4144,7 +4151,6 @@ static void log_flush_buffer(LogBufferInfo *lbi, int type, int sync_now)
slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();
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) {
@@ -4175,8 +4181,8 @@ static void log_flush_buffer(LogBufferInfo *lbi, int type, int sync_now)
if (!sync_now && slapdFrontendConfig->accesslogbuffering) {
LOG_WRITE(loginfo.log_access_fdes, lbi->top, lbi->current - lbi->top, 0);
} else {
- LOG_WRITE_NOW(loginfo.log_access_fdes, lbi->top,
- lbi->current - lbi->top, 0, err);
+ LOG_WRITE_NOW_NO_ERR(loginfo.log_access_fdes, lbi->top,
+ lbi->current - lbi->top, 0);
}
lbi->current = lbi->top;
diff --git a/ldap/servers/slapd/mapping_tree.c b/ldap/servers/slapd/mapping_tree.c
index 5de0e46..9336d7c 100644
--- a/ldap/servers/slapd/mapping_tree.c
+++ b/ldap/servers/slapd/mapping_tree.c
@@ -158,8 +158,10 @@ static mapping_tree_node *
static int _mtn_update_config_param(int op, char *type, char *strvalue);
#ifdef DEBUG
+#ifdef USE_DUMP_MAPPING_TREE
static void dump_mapping_tree(mapping_tree_node *parent, int depth);
#endif
+#endif
/* structure and static local variable used to store the
* list of plugins that have registered to a callback when backend state
@@ -3721,6 +3723,7 @@ void test_register()
#endif
#ifdef DEBUG
+#ifdef USE_DUMP_MAPPING_TREE
static void dump_mapping_tree(mapping_tree_node *parent, int depth)
{
mapping_tree_node *current = NULL;
@@ -3751,7 +3754,8 @@ static void dump_mapping_tree(mapping_tree_node *parent, int depth)
}
return;
}
-#endif
+#endif /* USE_DUMP_MAPPING_TREE */
+#endif /* DEBUG */
/* helper function to set/remove the config param in cn=config */
static int
diff --git a/ldap/servers/slapd/regex.c b/ldap/servers/slapd/regex.c
index 3697fde..29edffe 100644
--- a/ldap/servers/slapd/regex.c
+++ b/ldap/servers/slapd/regex.c
@@ -161,7 +161,7 @@ slapi_re_subs_ext( Slapi_Regex *re_handle, const char *subject,
int pin;
int *ovector;
char *mydst;
- const char *prev, *next;
+ const char *prev;
const char *substring_start;
const char *p;
@@ -179,8 +179,7 @@ slapi_re_subs_ext( Slapi_Regex *re_handle, const char *subject,
for (p = src; *p != '\0'; p++) {
if ('&' == *p) {
/* Don't replace '&' if it's a filter AND: "(&(cn=a)(sn=b))" */
- next = p;
- if(!filter || (*prev != '(' && *next++ != '(')){
+ if(!filter || !(*prev == '(' && *(p+1) == '(')){
if (re_handle->re_oveccount <= 1) {
memset(*dst, '\0', dstlen);
return -1;
@@ -188,6 +187,11 @@ slapi_re_subs_ext( Slapi_Regex *re_handle, const char *subject,
substring_start = subject + ovector[0];
thislen = ovector[1] - ovector[0];
len += thislen;
+ } else { /* is a filter AND clause */
+ /* just copy it into the filter */
+ substring_start = p;
+ thislen = 1;
+ len++;
}
} else if (('\\' == *p) && ('0' <= *(p+1) && *(p+1) <= '9')) {
pin = *(++p) - '0';
diff --git a/ldap/servers/slapd/slapi-plugin.h b/ldap/servers/slapd/slapi-plugin.h
index f2dc6af..fd580ea 100644
--- a/ldap/servers/slapd/slapi-plugin.h
+++ b/ldap/servers/slapd/slapi-plugin.h
@@ -6999,6 +6999,15 @@ int slapi_ldap_get_lderrno(LDAP *ld, char **m, char **s);
#endif
void slapi_ldif_put_type_and_value_with_options( char **out, const char *t, const char *val, int vlen, unsigned long options );
+/* ldif_read_record lineno argument type depends on openldap version */
+#if defined(USE_OPENLDAP)
+#if LDAP_VENDOR_VERSION >= 20434 /* changed in 2.4.34 */
+typedef unsigned long int ldif_record_lineno_t;
+#else
+typedef int ldif_record_lineno_t;
+#endif
+#endif
+
#if defined(USE_OPENLDAP)
/*
* UTF-8 routines (should these move into libnls?)
diff --git a/ldap/servers/slapd/tools/ldclt/ldapfct.c b/ldap/servers/slapd/tools/ldclt/ldapfct.c
index 1d0a0d4..c57f240 100644
--- a/ldap/servers/slapd/tools/ldclt/ldapfct.c
+++ b/ldap/servers/slapd/tools/ldclt/ldapfct.c
@@ -732,10 +732,8 @@ LDAP *
connectToLDAP(thread_context *tttctx, const char *bufBindDN, const char *bufPasswd, unsigned int mode, unsigned int mod2)
{
LDAP *ld = NULL;
- const char *mech = LDAP_SASL_SIMPLE;
struct berval cred = {0, NULL};
int v2v3 = LDAP_VERSION3;
- const char *binddn = NULL;
const char *passwd = NULL;
#if defined(USE_OPENLDAP)
char *ldapurl = NULL;
@@ -863,11 +861,8 @@ connectToLDAP(thread_context *tttctx, const char *bufBindDN, const char *bufPass
#endif /* !USE_OPENLDAP */
if (mode & CLTAUTH) {
- mech = "EXTERNAL";
- binddn = "";
passwd = NULL;
} else {
- binddn = bufBindDN?bufBindDN:mctx.bindDN;
passwd = bufPasswd?bufPasswd:mctx.passwd;
if (passwd) {
cred.bv_val = (char *)passwd;
diff --git a/ldap/servers/slapd/tools/rsearch/infadd.c b/ldap/servers/slapd/tools/rsearch/infadd.c
index 607381a..4a9f2e9 100644
--- a/ldap/servers/slapd/tools/rsearch/infadd.c
+++ b/ldap/servers/slapd/tools/rsearch/infadd.c
@@ -127,11 +127,10 @@ char *randName(void)
return x;
}
-int fill_table(NameTable *nt, PRUint32 size)
+void fill_table(NameTable *nt, PRUint32 size)
{
PRUint32 i;
char *x;
- int ret;
fprintf(stdout, "Generating random names: 0 ");
for (i = 0; i < size; i++) {
@@ -141,13 +140,13 @@ int fill_table(NameTable *nt, PRUint32 size)
free(x);
x = randName();
}
- ret = nt_push(nt, x);
+ (void)nt_push(nt, x);
if ((i % 100) == 0) {
fprintf(stdout, "\b\b\b\b\b\b\b%-7d", i);
}
}
fprintf(stdout, "\b\b\b\b\b\b\b%d. Done.\n", size);
- return ret;
+ return;
}
int main(int argc, char **argv)
diff --git a/ldap/servers/snmp/main.c b/ldap/servers/snmp/main.c
index ca3fc1c..78d4814 100644
--- a/ldap/servers/snmp/main.c
+++ b/ldap/servers/snmp/main.c
@@ -236,6 +236,15 @@ main (int argc, char *argv[]) {
return 0;
}
+/* ldif_read_record lineno argument type depends on openldap version */
+#if defined(USE_OPENLDAP)
+#if LDAP_VENDOR_VERSION >= 20434 /* changed in 2.4.34 */
+typedef unsigned long int ldif_record_lineno_t;
+#else
+typedef int ldif_record_lineno_t;
+#endif
+#endif
+
/************************************************************************
* load_config
*
@@ -249,8 +258,10 @@ load_config(char *conf_path)
#if defined(USE_OPENLDAP)
LDIFFP *dse_fp = NULL;
int buflen = 0;
+ ldif_record_lineno_t lineno = 0;
#else
FILE *dse_fp = NULL;
+ int lineno = 0;
#endif
char line[MAXLINE];
char *p = NULL;
@@ -332,10 +343,10 @@ load_config(char *conf_path)
} else if ((p = strstr(line, "server")) != NULL) {
int got_port = 0;
int got_rundir = 0;
- int lineno = 0;
char *entry = NULL;
char *instancename = NULL;
+ lineno = 0;
/* Allocate a server_instance */
if ((serv_p = malloc(sizeof(server_instance))) == NULL) {
printf("ldap-agent: malloc error processing config file\n");
diff --git a/lib/libaccess/acltools.cpp b/lib/libaccess/acltools.cpp
index 69d0c2e..3ef2beb 100644
--- a/lib/libaccess/acltools.cpp
+++ b/lib/libaccess/acltools.cpp
@@ -1740,7 +1740,7 @@ static PList_t ACLAttr2IndexPList = NULL;
int
ACL_InitAttr2Index(void)
{
- int i;
+ intptr_t i;
if (ACLAttr2IndexPList) return 0;
diff --git a/lib/libaccess/lasdns.cpp b/lib/libaccess/lasdns.cpp
index de8e624..93730c7 100644
--- a/lib/libaccess/lasdns.cpp
+++ b/lib/libaccess/lasdns.cpp
@@ -140,7 +140,6 @@ LASDnsBuild(NSErr_t *errp, char *attr_pattern, LASDnsContext_t *context, int ali
size_t delimiter; /* length of valid tokeni */
char token[256]; /* max length dns name */
int i;
- int ipcnt = 0;
char **p;
pool_handle_t *pool;
PRStatus error=PR_SUCCESS;
diff --git a/lib/libaccess/register.cpp b/lib/libaccess/register.cpp
index 766436e..798a926 100644
--- a/lib/libaccess/register.cpp
+++ b/lib/libaccess/register.cpp
@@ -77,6 +77,8 @@ ACL_LasHashInit()
{
int i;
+ (void)(link_ACLGlobal); /* get rid of defined but not used compiler warning */
+ (void)(link_nsacl_table); /* get rid of defined but not used compiler warning */
ACLLasEvalHash = PR_NewHashTable(0,
PR_HashString,
PR_CompareStrings,
@@ -268,11 +270,11 @@ ACL_MethodRegister(NSErr_t *errp, const char *name, ACLMethod_t *t)
}
/* Put it in the hash table */
- if (NULL == PR_HashTableAdd(ACLMethodHash, name, (void *)++cur_method)) {
+ if (NULL == PR_HashTableAdd(ACLMethodHash, name, (void *)(intptr_t)++cur_method)) {
ACL_CritExit();
return -1;
}
- *t = (ACLMethod_t) cur_method;
+ *t = (ACLMethod_t) (intptr_t)cur_method;
ACL_CritExit();
return 0;
@@ -412,11 +414,11 @@ ACL_DbTypeRegister(NSErr_t *errp, const char *name, DbParseFn_t func, ACLDbType_
}
/* Put it in the hash table */
- if (NULL == PR_HashTableAdd(ACLDbTypeHash, name, (void *)++cur_dbtype)) {
+ if (NULL == PR_HashTableAdd(ACLDbTypeHash, name, (void *)(intptr_t)++cur_dbtype)) {
ACL_CritExit();
return -1;
}
- *t = (ACLDbType_t) cur_dbtype;
+ *t = (ACLDbType_t) (intptr_t)cur_dbtype;
ACLDbParseFnTable[cur_dbtype] = func;
ACL_CritExit();
10 years, 11 months
Branch '389-ds-base-1.2.11' - ldap/servers lib/base
by Mark Reynolds
ldap/servers/plugins/dna/dna.c | 2
ldap/servers/plugins/replication/repl5_mtnode_ext.c | 6 +-
ldap/servers/plugins/uiduniq/uid.c | 2
ldap/servers/slapd/back-ldbm/idl.c | 4 -
ldap/servers/slapd/conntable.c | 4 -
ldap/servers/slapd/log.c | 54 ++++++++++----------
ldap/servers/slapd/opshared.c | 4 -
ldap/servers/slapd/tools/dbscan.c | 15 ++---
lib/base/util.cpp | 2
9 files changed, 44 insertions(+), 49 deletions(-)
New commits:
commit 9ac276a838636326811284a28695c0fdea4a8d03
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Thu Jun 6 11:28:07 2013 -0400
Coverity Fixes (Part 5)
11784 - Deference before null check (uiduniq/uid.c)
11785 - Deference before null check (conntable.c)
11786 - Deference before null check (opshared.c)
11787 - Deference before null check (tools/dbscan.c)
11788 - Deference before null check (tools/dbscan.c)
11789 - Deference before null check (tools/dbscan.c)
11790 - Allocation size mismatch (idl.c)
11791 - Allocation size mismatch (idl.c)
11792 - Wrong sizeof argument (dna.c)
11793 - Stray semicolon (lib/base/util.c)
11794 - Stray semicolon (lib/base/util.c)
11795 - Destination buffer too small (log.c)
11809 - Use after free (repl5_mtnode_ext.c)
11849 - Unitialized sclara variable (dblayer.c)
https://bugzilla.redhat.com/show_bug.cgi?id=970221
Reviewed by: richm(Thanks!!)
(cherry picked from commit 6d23891a44fd41aa0580cdc223667f0ca2b9e1cc)
diff --git a/ldap/servers/plugins/dna/dna.c b/ldap/servers/plugins/dna/dna.c
index 958a4a7..f7e1004 100644
--- a/ldap/servers/plugins/dna/dna.c
+++ b/ldap/servers/plugins/dna/dna.c
@@ -1865,7 +1865,7 @@ dna_first_free_value(struct configEntry *config_entry,
} else {
/* This is a single-type range, so just use the first (only)
* type from the list. */
- ctrls = (LDAPControl **)slapi_ch_calloc(2, sizeof(LDAPControl));
+ ctrls = (LDAPControl **)slapi_ch_calloc(2, sizeof(LDAPControl *));
if (NULL == ctrls)
return LDAP_OPERATIONS_ERROR;
diff --git a/ldap/servers/plugins/replication/repl5_mtnode_ext.c b/ldap/servers/plugins/replication/repl5_mtnode_ext.c
index dd0d261..9b61920 100644
--- a/ldap/servers/plugins/replication/repl5_mtnode_ext.c
+++ b/ldap/servers/plugins/replication/repl5_mtnode_ext.c
@@ -110,8 +110,10 @@ multimaster_mtnode_construct_replicas ()
ext->replica = object_new(r, replica_destroy);
if (replica_add_by_name (replica_get_name (r), ext->replica) != 0)
{
- object_release (ext->replica);
- ext->replica = NULL;
+ if(ext->replica){
+ object_release (ext->replica);
+ ext->replica = NULL;
+ }
}
}
}
diff --git a/ldap/servers/plugins/uiduniq/uid.c b/ldap/servers/plugins/uiduniq/uid.c
index d9e6ba4..984b93e 100644
--- a/ldap/servers/plugins/uiduniq/uid.c
+++ b/ldap/servers/plugins/uiduniq/uid.c
@@ -509,7 +509,7 @@ findSubtreeAndSearch(Slapi_DN *parentDN, const char *attrName, Slapi_Attr *attr,
Slapi_DN *newpar = NULL;
slapi_sdn_get_parent(parentDN, curpar);
- while ((curpar != NULL) && (slapi_sdn_get_dn(curpar) != NULL))
+ while (slapi_sdn_get_dn(curpar) != NULL)
{
if ((spb = dnHasObjectClass(curpar, markerObjectClass)))
{
diff --git a/ldap/servers/slapd/back-ldbm/idl.c b/ldap/servers/slapd/back-ldbm/idl.c
index 58736f8..76ee252 100644
--- a/ldap/servers/slapd/back-ldbm/idl.c
+++ b/ldap/servers/slapd/back-ldbm/idl.c
@@ -1247,7 +1247,7 @@ void idl_insert(IDList **idl, ID id)
(*idl)->b_nmax *= 2;
(*idl) = (IDList *) slapi_ch_realloc( (char *) (*idl),
- ((*idl)->b_nmax + 2) * sizeof(ID) );
+ ((*idl)->b_nmax + 2) * sizeof(ID) + sizeof(IDList) );
}
/* make a slot for the new id */
@@ -1345,7 +1345,7 @@ idl_insert_maxids( IDList **idl, ID id, int maxids )
(*idl)->b_nmax = maxids;
}
*idl = (IDList *) slapi_ch_realloc( (char *) *idl,
- ((*idl)->b_nmax + 2) * sizeof(ID) );
+ ((*idl)->b_nmax + 2) * sizeof(ID) + sizeof(IDList));
}
/* make a slot for the new id */
diff --git a/ldap/servers/slapd/conntable.c b/ldap/servers/slapd/conntable.c
index df4f2f8..7cf9f31 100644
--- a/ldap/servers/slapd/conntable.c
+++ b/ldap/servers/slapd/conntable.c
@@ -444,9 +444,7 @@ connection_table_as_entry(Connection_Table *ct, Slapi_Entry *e)
val.bv_val = bufptr;
val.bv_len = strlen( bufptr );
attrlist_merge( &e->e_attrs, "connection", vals );
- if (newbuf) {
- slapi_ch_free_string(&newbuf);
- }
+ slapi_ch_free_string(&newbuf);
}
PR_Unlock( ct->c[i].c_mutex );
}
diff --git a/ldap/servers/slapd/log.c b/ldap/servers/slapd/log.c
index 6be5b1e..a508908 100644
--- a/ldap/servers/slapd/log.c
+++ b/ldap/servers/slapd/log.c
@@ -2050,7 +2050,7 @@ static int vslapd_log_access(char *fmt, va_list ap)
int blen, vlen;
/* info needed to keep us from calling localtime/strftime so often: */
static time_t old_time = 0;
- static char old_tbuf[TBUFSIZE];
+ static char old_tbuf[SLAPI_LOG_BUFSIZ];
static int old_blen = 0;
tnl = current_time();
@@ -2058,11 +2058,11 @@ static int vslapd_log_access(char *fmt, va_list ap)
/* check if we can use the old strftime buffer */
PR_Lock(ts_time_lock);
if (tnl == old_time) {
- strcpy(buffer, old_tbuf);
- blen = old_blen;
- PR_Unlock(ts_time_lock);
+ strcpy(buffer, old_tbuf);
+ blen = old_blen;
+ PR_Unlock(ts_time_lock);
} else {
- /* nope... painstakingly create the new strftime buffer */
+ /* nope... painstakingly create the new strftime buffer */
#ifdef _WIN32
{
struct tm *pt = localtime( &tnl );
@@ -2070,39 +2070,39 @@ static int vslapd_log_access(char *fmt, va_list ap)
memcpy(&tms, pt, sizeof(struct tm) );
}
#else
- (void)localtime_r( &tnl, &tms );
- tmsp = &tms;
+ (void)localtime_r( &tnl, &tms );
+ tmsp = &tms;
#endif
#ifdef BSD_TIME
- tz = tmsp->tm_gmtoff;
+ tz = tmsp->tm_gmtoff;
#else /* BSD_TIME */
- tz = - timezone;
- if ( tmsp->tm_isdst ) {
- tz += 3600;
- }
+ tz = - timezone;
+ if ( tmsp->tm_isdst ) {
+ tz += 3600;
+ }
#endif /* BSD_TIME */
- sign = ( tz >= 0 ? '+' : '-' );
- if ( tz < 0 ) {
- tz = -tz;
- }
- (void)strftime( tbuf, (size_t)TBUFSIZE, "%d/%b/%Y:%H:%M:%S", tmsp);
- sprintf( buffer, "[%s %c%02d%02d] ", tbuf, sign,
- (int)( tz / 3600 ), (int)( tz % 3600));
- old_time = tnl;
- strcpy(old_tbuf, buffer);
- blen = strlen(buffer);
- old_blen = blen;
- PR_Unlock(ts_time_lock);
+ sign = ( tz >= 0 ? '+' : '-' );
+ if ( tz < 0 ) {
+ tz = -tz;
+ }
+ (void)strftime( tbuf, (size_t)TBUFSIZE, "%d/%b/%Y:%H:%M:%S", tmsp);
+ sprintf( buffer, "[%s %c%02d%02d] ", tbuf, sign,
+ (int)( tz / 3600 ), (int)( tz % 3600));
+ old_time = tnl;
+ strcpy(old_tbuf, buffer);
+ blen = strlen(buffer);
+ old_blen = blen;
+ PR_Unlock(ts_time_lock);
}
- vlen = PR_vsnprintf(vbuf, SLAPI_LOG_BUFSIZ, fmt, ap);
+ vlen = PR_vsnprintf(vbuf, SLAPI_LOG_BUFSIZ, fmt, ap);
if (! vlen) {
- return -1;
+ return -1;
}
if (SLAPI_LOG_BUFSIZ - blen < vlen) {
- return -1;
+ return -1;
}
log_append_buffer2(tnl, loginfo.log_access_buffer, buffer, blen, vbuf, vlen);
diff --git a/ldap/servers/slapd/opshared.c b/ldap/servers/slapd/opshared.c
index a96b950..1689283 100644
--- a/ldap/servers/slapd/opshared.c
+++ b/ldap/servers/slapd/opshared.c
@@ -1090,9 +1090,7 @@ process_entry(Slapi_PBlock *pb, Slapi_Entry *e, int send_result)
ber_bvecfree(refscopy);
refscopy = NULL;
}
- if( NULL != tmpUrls) {
- slapi_ch_free( (void **)&tmpUrls );
- }
+ slapi_ch_free( (void **)&tmpUrls );
}
return 1; /* done with this entry */
diff --git a/ldap/servers/slapd/tools/dbscan.c b/ldap/servers/slapd/tools/dbscan.c
index 6b0f525..d84f138 100644
--- a/ldap/servers/slapd/tools/dbscan.c
+++ b/ldap/servers/slapd/tools/dbscan.c
@@ -825,10 +825,9 @@ display_entryrdn_self(DB *db, ID id, const char *nrdn, int indent)
display_entryrdn_children(db, id_stored_to_internal(elem->rdn_elem_id),
elem->rdn_elem_nrdn_rdn, indent);
bail:
- if (keybuf) {
- free(keybuf);
- }
+ free(keybuf);
cursor->c_close(cursor);
+
return;
}
@@ -866,10 +865,9 @@ display_entryrdn_parent(DB *db, ID id, const char *nrdn, int indent)
elem = (rdn_elem *)data.data;
_entryrdn_dump_rdn_elem(keybuf, elem, indent);
bail:
- if (keybuf) {
- free(keybuf);
- }
+ free(keybuf);
cursor->c_close(cursor);
+
return;
}
@@ -939,10 +937,9 @@ display_entryrdn_children(DB *db, ID id, const char *nrdn, int indent)
}
}
bail:
- if (keybuf) {
- free(keybuf);
- }
+ free(keybuf);
cursor->c_close(cursor);
+
return;
}
diff --git a/lib/base/util.cpp b/lib/base/util.cpp
index b198154..01f916d 100644
--- a/lib/base/util.cpp
+++ b/lib/base/util.cpp
@@ -253,7 +253,7 @@ static char *Bfmt[] = {
static void _util_strftime_conv(char *, int, int, char);
-#define _util_strftime_add(str) for (;(*pt = *str++); pt++);
+#define _util_strftime_add(str) for (;(*pt = *str++); pt++)
#define _util_strftime_copy(str, len) memcpy(pt, str, len); pt += len;
#define _util_strftime_fmt util_strftime
10 years, 11 months
Branch '389-ds-base-1.3.0' - ldap/servers lib/base
by Mark Reynolds
ldap/servers/plugins/dna/dna.c | 2
ldap/servers/plugins/replication/repl5_mtnode_ext.c | 6 +-
ldap/servers/plugins/uiduniq/uid.c | 2
ldap/servers/slapd/back-ldbm/idl.c | 4 -
ldap/servers/slapd/conntable.c | 4 -
ldap/servers/slapd/log.c | 54 ++++++++++----------
ldap/servers/slapd/opshared.c | 4 -
ldap/servers/slapd/tools/dbscan.c | 15 ++---
lib/base/util.cpp | 2
9 files changed, 44 insertions(+), 49 deletions(-)
New commits:
commit 19052a151c647a40945fa1b81ce4442931a78fc3
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Thu Jun 6 11:28:07 2013 -0400
Coverity Fixes (Part 5)
11784 - Deference before null check (uiduniq/uid.c)
11785 - Deference before null check (conntable.c)
11786 - Deference before null check (opshared.c)
11787 - Deference before null check (tools/dbscan.c)
11788 - Deference before null check (tools/dbscan.c)
11789 - Deference before null check (tools/dbscan.c)
11790 - Allocation size mismatch (idl.c)
11791 - Allocation size mismatch (idl.c)
11792 - Wrong sizeof argument (dna.c)
11793 - Stray semicolon (lib/base/util.c)
11794 - Stray semicolon (lib/base/util.c)
11795 - Destination buffer too small (log.c)
11809 - Use after free (repl5_mtnode_ext.c)
11849 - Unitialized sclara variable (dblayer.c)
https://bugzilla.redhat.com/show_bug.cgi?id=970221
Reviewed by: richm(Thanks!!)
(cherry picked from commit 6d23891a44fd41aa0580cdc223667f0ca2b9e1cc)
diff --git a/ldap/servers/plugins/dna/dna.c b/ldap/servers/plugins/dna/dna.c
index 32acf12..8e5bec8 100644
--- a/ldap/servers/plugins/dna/dna.c
+++ b/ldap/servers/plugins/dna/dna.c
@@ -1866,7 +1866,7 @@ dna_first_free_value(struct configEntry *config_entry,
} else {
/* This is a single-type range, so just use the first (only)
* type from the list. */
- ctrls = (LDAPControl **)slapi_ch_calloc(2, sizeof(LDAPControl));
+ ctrls = (LDAPControl **)slapi_ch_calloc(2, sizeof(LDAPControl *));
if (NULL == ctrls)
return LDAP_OPERATIONS_ERROR;
diff --git a/ldap/servers/plugins/replication/repl5_mtnode_ext.c b/ldap/servers/plugins/replication/repl5_mtnode_ext.c
index dd0d261..9b61920 100644
--- a/ldap/servers/plugins/replication/repl5_mtnode_ext.c
+++ b/ldap/servers/plugins/replication/repl5_mtnode_ext.c
@@ -110,8 +110,10 @@ multimaster_mtnode_construct_replicas ()
ext->replica = object_new(r, replica_destroy);
if (replica_add_by_name (replica_get_name (r), ext->replica) != 0)
{
- object_release (ext->replica);
- ext->replica = NULL;
+ if(ext->replica){
+ object_release (ext->replica);
+ ext->replica = NULL;
+ }
}
}
}
diff --git a/ldap/servers/plugins/uiduniq/uid.c b/ldap/servers/plugins/uiduniq/uid.c
index d9e6ba4..984b93e 100644
--- a/ldap/servers/plugins/uiduniq/uid.c
+++ b/ldap/servers/plugins/uiduniq/uid.c
@@ -509,7 +509,7 @@ findSubtreeAndSearch(Slapi_DN *parentDN, const char *attrName, Slapi_Attr *attr,
Slapi_DN *newpar = NULL;
slapi_sdn_get_parent(parentDN, curpar);
- while ((curpar != NULL) && (slapi_sdn_get_dn(curpar) != NULL))
+ while (slapi_sdn_get_dn(curpar) != NULL)
{
if ((spb = dnHasObjectClass(curpar, markerObjectClass)))
{
diff --git a/ldap/servers/slapd/back-ldbm/idl.c b/ldap/servers/slapd/back-ldbm/idl.c
index 65fca7c..4309708 100644
--- a/ldap/servers/slapd/back-ldbm/idl.c
+++ b/ldap/servers/slapd/back-ldbm/idl.c
@@ -1247,7 +1247,7 @@ void idl_insert(IDList **idl, ID id)
(*idl)->b_nmax *= 2;
(*idl) = (IDList *) slapi_ch_realloc( (char *) (*idl),
- ((*idl)->b_nmax + 2) * sizeof(ID) );
+ ((*idl)->b_nmax + 2) * sizeof(ID) + sizeof(IDList) );
}
/* make a slot for the new id */
@@ -1345,7 +1345,7 @@ idl_insert_maxids( IDList **idl, ID id, int maxids )
(*idl)->b_nmax = maxids;
}
*idl = (IDList *) slapi_ch_realloc( (char *) *idl,
- ((*idl)->b_nmax + 2) * sizeof(ID) );
+ ((*idl)->b_nmax + 2) * sizeof(ID) + sizeof(IDList));
}
/* make a slot for the new id */
diff --git a/ldap/servers/slapd/conntable.c b/ldap/servers/slapd/conntable.c
index b61e5d4..6b1a261 100644
--- a/ldap/servers/slapd/conntable.c
+++ b/ldap/servers/slapd/conntable.c
@@ -443,9 +443,7 @@ connection_table_as_entry(Connection_Table *ct, Slapi_Entry *e)
val.bv_val = bufptr;
val.bv_len = strlen( bufptr );
attrlist_merge( &e->e_attrs, "connection", vals );
- if (newbuf) {
- slapi_ch_free_string(&newbuf);
- }
+ slapi_ch_free_string(&newbuf);
}
PR_Unlock( ct->c[i].c_mutex );
}
diff --git a/ldap/servers/slapd/log.c b/ldap/servers/slapd/log.c
index 0cf08f0..cab82d5 100644
--- a/ldap/servers/slapd/log.c
+++ b/ldap/servers/slapd/log.c
@@ -2050,7 +2050,7 @@ static int vslapd_log_access(char *fmt, va_list ap)
int blen, vlen;
/* info needed to keep us from calling localtime/strftime so often: */
static time_t old_time = 0;
- static char old_tbuf[TBUFSIZE];
+ static char old_tbuf[SLAPI_LOG_BUFSIZ];
static int old_blen = 0;
tnl = current_time();
@@ -2058,11 +2058,11 @@ static int vslapd_log_access(char *fmt, va_list ap)
/* check if we can use the old strftime buffer */
PR_Lock(ts_time_lock);
if (tnl == old_time) {
- strcpy(buffer, old_tbuf);
- blen = old_blen;
- PR_Unlock(ts_time_lock);
+ strcpy(buffer, old_tbuf);
+ blen = old_blen;
+ PR_Unlock(ts_time_lock);
} else {
- /* nope... painstakingly create the new strftime buffer */
+ /* nope... painstakingly create the new strftime buffer */
#ifdef _WIN32
{
struct tm *pt = localtime( &tnl );
@@ -2070,39 +2070,39 @@ static int vslapd_log_access(char *fmt, va_list ap)
memcpy(&tms, pt, sizeof(struct tm) );
}
#else
- (void)localtime_r( &tnl, &tms );
- tmsp = &tms;
+ (void)localtime_r( &tnl, &tms );
+ tmsp = &tms;
#endif
#ifdef BSD_TIME
- tz = tmsp->tm_gmtoff;
+ tz = tmsp->tm_gmtoff;
#else /* BSD_TIME */
- tz = - timezone;
- if ( tmsp->tm_isdst ) {
- tz += 3600;
- }
+ tz = - timezone;
+ if ( tmsp->tm_isdst ) {
+ tz += 3600;
+ }
#endif /* BSD_TIME */
- sign = ( tz >= 0 ? '+' : '-' );
- if ( tz < 0 ) {
- tz = -tz;
- }
- (void)strftime( tbuf, (size_t)TBUFSIZE, "%d/%b/%Y:%H:%M:%S", tmsp);
- sprintf( buffer, "[%s %c%02d%02d] ", tbuf, sign,
- (int)( tz / 3600 ), (int)( tz % 3600));
- old_time = tnl;
- strcpy(old_tbuf, buffer);
- blen = strlen(buffer);
- old_blen = blen;
- PR_Unlock(ts_time_lock);
+ sign = ( tz >= 0 ? '+' : '-' );
+ if ( tz < 0 ) {
+ tz = -tz;
+ }
+ (void)strftime( tbuf, (size_t)TBUFSIZE, "%d/%b/%Y:%H:%M:%S", tmsp);
+ sprintf( buffer, "[%s %c%02d%02d] ", tbuf, sign,
+ (int)( tz / 3600 ), (int)( tz % 3600));
+ old_time = tnl;
+ strcpy(old_tbuf, buffer);
+ blen = strlen(buffer);
+ old_blen = blen;
+ PR_Unlock(ts_time_lock);
}
- vlen = PR_vsnprintf(vbuf, SLAPI_LOG_BUFSIZ, fmt, ap);
+ vlen = PR_vsnprintf(vbuf, SLAPI_LOG_BUFSIZ, fmt, ap);
if (! vlen) {
- return -1;
+ return -1;
}
if (SLAPI_LOG_BUFSIZ - blen < vlen) {
- return -1;
+ return -1;
}
log_append_buffer2(tnl, loginfo.log_access_buffer, buffer, blen, vbuf, vlen);
diff --git a/ldap/servers/slapd/opshared.c b/ldap/servers/slapd/opshared.c
index 0149973..d7959e1 100644
--- a/ldap/servers/slapd/opshared.c
+++ b/ldap/servers/slapd/opshared.c
@@ -1092,9 +1092,7 @@ process_entry(Slapi_PBlock *pb, Slapi_Entry *e, int send_result)
ber_bvecfree(refscopy);
refscopy = NULL;
}
- if( NULL != tmpUrls) {
- slapi_ch_free( (void **)&tmpUrls );
- }
+ slapi_ch_free( (void **)&tmpUrls );
}
return 1; /* done with this entry */
diff --git a/ldap/servers/slapd/tools/dbscan.c b/ldap/servers/slapd/tools/dbscan.c
index 6b0f525..d84f138 100644
--- a/ldap/servers/slapd/tools/dbscan.c
+++ b/ldap/servers/slapd/tools/dbscan.c
@@ -825,10 +825,9 @@ display_entryrdn_self(DB *db, ID id, const char *nrdn, int indent)
display_entryrdn_children(db, id_stored_to_internal(elem->rdn_elem_id),
elem->rdn_elem_nrdn_rdn, indent);
bail:
- if (keybuf) {
- free(keybuf);
- }
+ free(keybuf);
cursor->c_close(cursor);
+
return;
}
@@ -866,10 +865,9 @@ display_entryrdn_parent(DB *db, ID id, const char *nrdn, int indent)
elem = (rdn_elem *)data.data;
_entryrdn_dump_rdn_elem(keybuf, elem, indent);
bail:
- if (keybuf) {
- free(keybuf);
- }
+ free(keybuf);
cursor->c_close(cursor);
+
return;
}
@@ -939,10 +937,9 @@ display_entryrdn_children(DB *db, ID id, const char *nrdn, int indent)
}
}
bail:
- if (keybuf) {
- free(keybuf);
- }
+ free(keybuf);
cursor->c_close(cursor);
+
return;
}
diff --git a/lib/base/util.cpp b/lib/base/util.cpp
index b198154..01f916d 100644
--- a/lib/base/util.cpp
+++ b/lib/base/util.cpp
@@ -253,7 +253,7 @@ static char *Bfmt[] = {
static void _util_strftime_conv(char *, int, int, char);
-#define _util_strftime_add(str) for (;(*pt = *str++); pt++);
+#define _util_strftime_add(str) for (;(*pt = *str++); pt++)
#define _util_strftime_copy(str, len) memcpy(pt, str, len); pt += len;
#define _util_strftime_fmt util_strftime
10 years, 11 months
Branch '389-ds-base-1.3.1' - ldap/servers lib/base
by Mark Reynolds
ldap/servers/plugins/dna/dna.c | 2
ldap/servers/plugins/replication/repl5_mtnode_ext.c | 6 +-
ldap/servers/plugins/uiduniq/uid.c | 2
ldap/servers/slapd/back-ldbm/idl.c | 4 -
ldap/servers/slapd/conntable.c | 4 -
ldap/servers/slapd/log.c | 54 ++++++++++----------
ldap/servers/slapd/opshared.c | 4 -
ldap/servers/slapd/tools/dbscan.c | 15 ++---
lib/base/util.cpp | 2
9 files changed, 44 insertions(+), 49 deletions(-)
New commits:
commit 6d23891a44fd41aa0580cdc223667f0ca2b9e1cc
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Thu Jun 6 11:28:07 2013 -0400
Coverity Fixes (Part 5)
11784 - Deference before null check (uiduniq/uid.c)
11785 - Deference before null check (conntable.c)
11786 - Deference before null check (opshared.c)
11787 - Deference before null check (tools/dbscan.c)
11788 - Deference before null check (tools/dbscan.c)
11789 - Deference before null check (tools/dbscan.c)
11790 - Allocation size mismatch (idl.c)
11791 - Allocation size mismatch (idl.c)
11792 - Wrong sizeof argument (dna.c)
11793 - Stray semicolon (lib/base/util.c)
11794 - Stray semicolon (lib/base/util.c)
11795 - Destination buffer too small (log.c)
11809 - Use after free (repl5_mtnode_ext.c)
11849 - Unitialized sclara variable (dblayer.c)
https://bugzilla.redhat.com/show_bug.cgi?id=970221
Reviewed by: richm(Thanks!!)
diff --git a/ldap/servers/plugins/dna/dna.c b/ldap/servers/plugins/dna/dna.c
index 48d539f..ff49f32 100644
--- a/ldap/servers/plugins/dna/dna.c
+++ b/ldap/servers/plugins/dna/dna.c
@@ -1865,7 +1865,7 @@ dna_first_free_value(struct configEntry *config_entry,
} else {
/* This is a single-type range, so just use the first (only)
* type from the list. */
- ctrls = (LDAPControl **)slapi_ch_calloc(2, sizeof(LDAPControl));
+ ctrls = (LDAPControl **)slapi_ch_calloc(2, sizeof(LDAPControl *));
if (NULL == ctrls)
return LDAP_OPERATIONS_ERROR;
diff --git a/ldap/servers/plugins/replication/repl5_mtnode_ext.c b/ldap/servers/plugins/replication/repl5_mtnode_ext.c
index dd0d261..9b61920 100644
--- a/ldap/servers/plugins/replication/repl5_mtnode_ext.c
+++ b/ldap/servers/plugins/replication/repl5_mtnode_ext.c
@@ -110,8 +110,10 @@ multimaster_mtnode_construct_replicas ()
ext->replica = object_new(r, replica_destroy);
if (replica_add_by_name (replica_get_name (r), ext->replica) != 0)
{
- object_release (ext->replica);
- ext->replica = NULL;
+ if(ext->replica){
+ object_release (ext->replica);
+ ext->replica = NULL;
+ }
}
}
}
diff --git a/ldap/servers/plugins/uiduniq/uid.c b/ldap/servers/plugins/uiduniq/uid.c
index d9e6ba4..984b93e 100644
--- a/ldap/servers/plugins/uiduniq/uid.c
+++ b/ldap/servers/plugins/uiduniq/uid.c
@@ -509,7 +509,7 @@ findSubtreeAndSearch(Slapi_DN *parentDN, const char *attrName, Slapi_Attr *attr,
Slapi_DN *newpar = NULL;
slapi_sdn_get_parent(parentDN, curpar);
- while ((curpar != NULL) && (slapi_sdn_get_dn(curpar) != NULL))
+ while (slapi_sdn_get_dn(curpar) != NULL)
{
if ((spb = dnHasObjectClass(curpar, markerObjectClass)))
{
diff --git a/ldap/servers/slapd/back-ldbm/idl.c b/ldap/servers/slapd/back-ldbm/idl.c
index 65fca7c..4309708 100644
--- a/ldap/servers/slapd/back-ldbm/idl.c
+++ b/ldap/servers/slapd/back-ldbm/idl.c
@@ -1247,7 +1247,7 @@ void idl_insert(IDList **idl, ID id)
(*idl)->b_nmax *= 2;
(*idl) = (IDList *) slapi_ch_realloc( (char *) (*idl),
- ((*idl)->b_nmax + 2) * sizeof(ID) );
+ ((*idl)->b_nmax + 2) * sizeof(ID) + sizeof(IDList) );
}
/* make a slot for the new id */
@@ -1345,7 +1345,7 @@ idl_insert_maxids( IDList **idl, ID id, int maxids )
(*idl)->b_nmax = maxids;
}
*idl = (IDList *) slapi_ch_realloc( (char *) *idl,
- ((*idl)->b_nmax + 2) * sizeof(ID) );
+ ((*idl)->b_nmax + 2) * sizeof(ID) + sizeof(IDList));
}
/* make a slot for the new id */
diff --git a/ldap/servers/slapd/conntable.c b/ldap/servers/slapd/conntable.c
index b61e5d4..6b1a261 100644
--- a/ldap/servers/slapd/conntable.c
+++ b/ldap/servers/slapd/conntable.c
@@ -443,9 +443,7 @@ connection_table_as_entry(Connection_Table *ct, Slapi_Entry *e)
val.bv_val = bufptr;
val.bv_len = strlen( bufptr );
attrlist_merge( &e->e_attrs, "connection", vals );
- if (newbuf) {
- slapi_ch_free_string(&newbuf);
- }
+ slapi_ch_free_string(&newbuf);
}
PR_Unlock( ct->c[i].c_mutex );
}
diff --git a/ldap/servers/slapd/log.c b/ldap/servers/slapd/log.c
index 0cf08f0..cab82d5 100644
--- a/ldap/servers/slapd/log.c
+++ b/ldap/servers/slapd/log.c
@@ -2050,7 +2050,7 @@ static int vslapd_log_access(char *fmt, va_list ap)
int blen, vlen;
/* info needed to keep us from calling localtime/strftime so often: */
static time_t old_time = 0;
- static char old_tbuf[TBUFSIZE];
+ static char old_tbuf[SLAPI_LOG_BUFSIZ];
static int old_blen = 0;
tnl = current_time();
@@ -2058,11 +2058,11 @@ static int vslapd_log_access(char *fmt, va_list ap)
/* check if we can use the old strftime buffer */
PR_Lock(ts_time_lock);
if (tnl == old_time) {
- strcpy(buffer, old_tbuf);
- blen = old_blen;
- PR_Unlock(ts_time_lock);
+ strcpy(buffer, old_tbuf);
+ blen = old_blen;
+ PR_Unlock(ts_time_lock);
} else {
- /* nope... painstakingly create the new strftime buffer */
+ /* nope... painstakingly create the new strftime buffer */
#ifdef _WIN32
{
struct tm *pt = localtime( &tnl );
@@ -2070,39 +2070,39 @@ static int vslapd_log_access(char *fmt, va_list ap)
memcpy(&tms, pt, sizeof(struct tm) );
}
#else
- (void)localtime_r( &tnl, &tms );
- tmsp = &tms;
+ (void)localtime_r( &tnl, &tms );
+ tmsp = &tms;
#endif
#ifdef BSD_TIME
- tz = tmsp->tm_gmtoff;
+ tz = tmsp->tm_gmtoff;
#else /* BSD_TIME */
- tz = - timezone;
- if ( tmsp->tm_isdst ) {
- tz += 3600;
- }
+ tz = - timezone;
+ if ( tmsp->tm_isdst ) {
+ tz += 3600;
+ }
#endif /* BSD_TIME */
- sign = ( tz >= 0 ? '+' : '-' );
- if ( tz < 0 ) {
- tz = -tz;
- }
- (void)strftime( tbuf, (size_t)TBUFSIZE, "%d/%b/%Y:%H:%M:%S", tmsp);
- sprintf( buffer, "[%s %c%02d%02d] ", tbuf, sign,
- (int)( tz / 3600 ), (int)( tz % 3600));
- old_time = tnl;
- strcpy(old_tbuf, buffer);
- blen = strlen(buffer);
- old_blen = blen;
- PR_Unlock(ts_time_lock);
+ sign = ( tz >= 0 ? '+' : '-' );
+ if ( tz < 0 ) {
+ tz = -tz;
+ }
+ (void)strftime( tbuf, (size_t)TBUFSIZE, "%d/%b/%Y:%H:%M:%S", tmsp);
+ sprintf( buffer, "[%s %c%02d%02d] ", tbuf, sign,
+ (int)( tz / 3600 ), (int)( tz % 3600));
+ old_time = tnl;
+ strcpy(old_tbuf, buffer);
+ blen = strlen(buffer);
+ old_blen = blen;
+ PR_Unlock(ts_time_lock);
}
- vlen = PR_vsnprintf(vbuf, SLAPI_LOG_BUFSIZ, fmt, ap);
+ vlen = PR_vsnprintf(vbuf, SLAPI_LOG_BUFSIZ, fmt, ap);
if (! vlen) {
- return -1;
+ return -1;
}
if (SLAPI_LOG_BUFSIZ - blen < vlen) {
- return -1;
+ return -1;
}
log_append_buffer2(tnl, loginfo.log_access_buffer, buffer, blen, vbuf, vlen);
diff --git a/ldap/servers/slapd/opshared.c b/ldap/servers/slapd/opshared.c
index e7f6135..a03a0a1 100644
--- a/ldap/servers/slapd/opshared.c
+++ b/ldap/servers/slapd/opshared.c
@@ -1090,9 +1090,7 @@ process_entry(Slapi_PBlock *pb, Slapi_Entry *e, int send_result)
ber_bvecfree(refscopy);
refscopy = NULL;
}
- if( NULL != tmpUrls) {
- slapi_ch_free( (void **)&tmpUrls );
- }
+ slapi_ch_free( (void **)&tmpUrls );
}
return 1; /* done with this entry */
diff --git a/ldap/servers/slapd/tools/dbscan.c b/ldap/servers/slapd/tools/dbscan.c
index 6b0f525..d84f138 100644
--- a/ldap/servers/slapd/tools/dbscan.c
+++ b/ldap/servers/slapd/tools/dbscan.c
@@ -825,10 +825,9 @@ display_entryrdn_self(DB *db, ID id, const char *nrdn, int indent)
display_entryrdn_children(db, id_stored_to_internal(elem->rdn_elem_id),
elem->rdn_elem_nrdn_rdn, indent);
bail:
- if (keybuf) {
- free(keybuf);
- }
+ free(keybuf);
cursor->c_close(cursor);
+
return;
}
@@ -866,10 +865,9 @@ display_entryrdn_parent(DB *db, ID id, const char *nrdn, int indent)
elem = (rdn_elem *)data.data;
_entryrdn_dump_rdn_elem(keybuf, elem, indent);
bail:
- if (keybuf) {
- free(keybuf);
- }
+ free(keybuf);
cursor->c_close(cursor);
+
return;
}
@@ -939,10 +937,9 @@ display_entryrdn_children(DB *db, ID id, const char *nrdn, int indent)
}
}
bail:
- if (keybuf) {
- free(keybuf);
- }
+ free(keybuf);
cursor->c_close(cursor);
+
return;
}
diff --git a/lib/base/util.cpp b/lib/base/util.cpp
index b198154..01f916d 100644
--- a/lib/base/util.cpp
+++ b/lib/base/util.cpp
@@ -253,7 +253,7 @@ static char *Bfmt[] = {
static void _util_strftime_conv(char *, int, int, char);
-#define _util_strftime_add(str) for (;(*pt = *str++); pt++);
+#define _util_strftime_add(str) for (;(*pt = *str++); pt++)
#define _util_strftime_copy(str, len) memcpy(pt, str, len); pt += len;
#define _util_strftime_fmt util_strftime
10 years, 11 months
ldap/servers lib/base
by Mark Reynolds
ldap/servers/plugins/dna/dna.c | 2
ldap/servers/plugins/replication/repl5_mtnode_ext.c | 6 +-
ldap/servers/plugins/uiduniq/uid.c | 2
ldap/servers/slapd/back-ldbm/dblayer.c | 2
ldap/servers/slapd/back-ldbm/idl.c | 4 -
ldap/servers/slapd/conntable.c | 4 -
ldap/servers/slapd/log.c | 54 ++++++++++----------
ldap/servers/slapd/opshared.c | 4 -
ldap/servers/slapd/tools/dbscan.c | 15 ++---
lib/base/util.cpp | 2
10 files changed, 45 insertions(+), 50 deletions(-)
New commits:
commit d8f50868d91e6dd892ab8d290cbee9267e8f2ce2
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Thu Jun 6 11:28:07 2013 -0400
Coverity Fixes (Part 5)
11784 - Deference before null check (uiduniq/uid.c)
11785 - Deference before null check (conntable.c)
11786 - Deference before null check (opshared.c)
11787 - Deference before null check (tools/dbscan.c)
11788 - Deference before null check (tools/dbscan.c)
11789 - Deference before null check (tools/dbscan.c)
11790 - Allocation size mismatch (idl.c)
11791 - Allocation size mismatch (idl.c)
11792 - Wrong sizeof argument (dna.c)
11793 - Stray semicolon (lib/base/util.c)
11794 - Stray semicolon (lib/base/util.c)
11795 - Destination buffer too small (log.c)
11809 - Use after free (repl5_mtnode_ext.c)
11849 - Unitialized sclara variable (dblayer.c)
https://bugzilla.redhat.com/show_bug.cgi?id=970221
Reviewed by: richm(Thanks!!)
diff --git a/ldap/servers/plugins/dna/dna.c b/ldap/servers/plugins/dna/dna.c
index 48d539f..ff49f32 100644
--- a/ldap/servers/plugins/dna/dna.c
+++ b/ldap/servers/plugins/dna/dna.c
@@ -1865,7 +1865,7 @@ dna_first_free_value(struct configEntry *config_entry,
} else {
/* This is a single-type range, so just use the first (only)
* type from the list. */
- ctrls = (LDAPControl **)slapi_ch_calloc(2, sizeof(LDAPControl));
+ ctrls = (LDAPControl **)slapi_ch_calloc(2, sizeof(LDAPControl *));
if (NULL == ctrls)
return LDAP_OPERATIONS_ERROR;
diff --git a/ldap/servers/plugins/replication/repl5_mtnode_ext.c b/ldap/servers/plugins/replication/repl5_mtnode_ext.c
index dd0d261..9b61920 100644
--- a/ldap/servers/plugins/replication/repl5_mtnode_ext.c
+++ b/ldap/servers/plugins/replication/repl5_mtnode_ext.c
@@ -110,8 +110,10 @@ multimaster_mtnode_construct_replicas ()
ext->replica = object_new(r, replica_destroy);
if (replica_add_by_name (replica_get_name (r), ext->replica) != 0)
{
- object_release (ext->replica);
- ext->replica = NULL;
+ if(ext->replica){
+ object_release (ext->replica);
+ ext->replica = NULL;
+ }
}
}
}
diff --git a/ldap/servers/plugins/uiduniq/uid.c b/ldap/servers/plugins/uiduniq/uid.c
index d9e6ba4..984b93e 100644
--- a/ldap/servers/plugins/uiduniq/uid.c
+++ b/ldap/servers/plugins/uiduniq/uid.c
@@ -509,7 +509,7 @@ findSubtreeAndSearch(Slapi_DN *parentDN, const char *attrName, Slapi_Attr *attr,
Slapi_DN *newpar = NULL;
slapi_sdn_get_parent(parentDN, curpar);
- while ((curpar != NULL) && (slapi_sdn_get_dn(curpar) != NULL))
+ while (slapi_sdn_get_dn(curpar) != NULL)
{
if ((spb = dnHasObjectClass(curpar, markerObjectClass)))
{
diff --git a/ldap/servers/slapd/back-ldbm/dblayer.c b/ldap/servers/slapd/back-ldbm/dblayer.c
index e93f79a..abb64e2 100644
--- a/ldap/servers/slapd/back-ldbm/dblayer.c
+++ b/ldap/servers/slapd/back-ldbm/dblayer.c
@@ -4499,7 +4499,7 @@ static int log_flush_threadmain(void *param)
{
dblayer_private *priv = NULL;
PRIntervalTime interval_wait, interval_flush, interval_def;
- PRIntervalTime last_flush;
+ PRIntervalTime last_flush = 0;
int i;
int do_flush = 0;
diff --git a/ldap/servers/slapd/back-ldbm/idl.c b/ldap/servers/slapd/back-ldbm/idl.c
index 0a11d88..a0bc139 100644
--- a/ldap/servers/slapd/back-ldbm/idl.c
+++ b/ldap/servers/slapd/back-ldbm/idl.c
@@ -1251,7 +1251,7 @@ void idl_insert(IDList **idl, ID id)
(*idl)->b_nmax *= 2;
(*idl) = (IDList *) slapi_ch_realloc( (char *) (*idl),
- ((*idl)->b_nmax + 2) * sizeof(ID) );
+ ((*idl)->b_nmax + 2) * sizeof(ID) + sizeof(IDList) );
}
/* make a slot for the new id */
@@ -1349,7 +1349,7 @@ idl_insert_maxids( IDList **idl, ID id, int maxids )
(*idl)->b_nmax = maxids;
}
*idl = (IDList *) slapi_ch_realloc( (char *) *idl,
- ((*idl)->b_nmax + 2) * sizeof(ID) );
+ ((*idl)->b_nmax + 2) * sizeof(ID) + sizeof(IDList));
}
/* make a slot for the new id */
diff --git a/ldap/servers/slapd/conntable.c b/ldap/servers/slapd/conntable.c
index b61e5d4..6b1a261 100644
--- a/ldap/servers/slapd/conntable.c
+++ b/ldap/servers/slapd/conntable.c
@@ -443,9 +443,7 @@ connection_table_as_entry(Connection_Table *ct, Slapi_Entry *e)
val.bv_val = bufptr;
val.bv_len = strlen( bufptr );
attrlist_merge( &e->e_attrs, "connection", vals );
- if (newbuf) {
- slapi_ch_free_string(&newbuf);
- }
+ slapi_ch_free_string(&newbuf);
}
PR_Unlock( ct->c[i].c_mutex );
}
diff --git a/ldap/servers/slapd/log.c b/ldap/servers/slapd/log.c
index 0cf08f0..cab82d5 100644
--- a/ldap/servers/slapd/log.c
+++ b/ldap/servers/slapd/log.c
@@ -2050,7 +2050,7 @@ static int vslapd_log_access(char *fmt, va_list ap)
int blen, vlen;
/* info needed to keep us from calling localtime/strftime so often: */
static time_t old_time = 0;
- static char old_tbuf[TBUFSIZE];
+ static char old_tbuf[SLAPI_LOG_BUFSIZ];
static int old_blen = 0;
tnl = current_time();
@@ -2058,11 +2058,11 @@ static int vslapd_log_access(char *fmt, va_list ap)
/* check if we can use the old strftime buffer */
PR_Lock(ts_time_lock);
if (tnl == old_time) {
- strcpy(buffer, old_tbuf);
- blen = old_blen;
- PR_Unlock(ts_time_lock);
+ strcpy(buffer, old_tbuf);
+ blen = old_blen;
+ PR_Unlock(ts_time_lock);
} else {
- /* nope... painstakingly create the new strftime buffer */
+ /* nope... painstakingly create the new strftime buffer */
#ifdef _WIN32
{
struct tm *pt = localtime( &tnl );
@@ -2070,39 +2070,39 @@ static int vslapd_log_access(char *fmt, va_list ap)
memcpy(&tms, pt, sizeof(struct tm) );
}
#else
- (void)localtime_r( &tnl, &tms );
- tmsp = &tms;
+ (void)localtime_r( &tnl, &tms );
+ tmsp = &tms;
#endif
#ifdef BSD_TIME
- tz = tmsp->tm_gmtoff;
+ tz = tmsp->tm_gmtoff;
#else /* BSD_TIME */
- tz = - timezone;
- if ( tmsp->tm_isdst ) {
- tz += 3600;
- }
+ tz = - timezone;
+ if ( tmsp->tm_isdst ) {
+ tz += 3600;
+ }
#endif /* BSD_TIME */
- sign = ( tz >= 0 ? '+' : '-' );
- if ( tz < 0 ) {
- tz = -tz;
- }
- (void)strftime( tbuf, (size_t)TBUFSIZE, "%d/%b/%Y:%H:%M:%S", tmsp);
- sprintf( buffer, "[%s %c%02d%02d] ", tbuf, sign,
- (int)( tz / 3600 ), (int)( tz % 3600));
- old_time = tnl;
- strcpy(old_tbuf, buffer);
- blen = strlen(buffer);
- old_blen = blen;
- PR_Unlock(ts_time_lock);
+ sign = ( tz >= 0 ? '+' : '-' );
+ if ( tz < 0 ) {
+ tz = -tz;
+ }
+ (void)strftime( tbuf, (size_t)TBUFSIZE, "%d/%b/%Y:%H:%M:%S", tmsp);
+ sprintf( buffer, "[%s %c%02d%02d] ", tbuf, sign,
+ (int)( tz / 3600 ), (int)( tz % 3600));
+ old_time = tnl;
+ strcpy(old_tbuf, buffer);
+ blen = strlen(buffer);
+ old_blen = blen;
+ PR_Unlock(ts_time_lock);
}
- vlen = PR_vsnprintf(vbuf, SLAPI_LOG_BUFSIZ, fmt, ap);
+ vlen = PR_vsnprintf(vbuf, SLAPI_LOG_BUFSIZ, fmt, ap);
if (! vlen) {
- return -1;
+ return -1;
}
if (SLAPI_LOG_BUFSIZ - blen < vlen) {
- return -1;
+ return -1;
}
log_append_buffer2(tnl, loginfo.log_access_buffer, buffer, blen, vbuf, vlen);
diff --git a/ldap/servers/slapd/opshared.c b/ldap/servers/slapd/opshared.c
index e7f6135..a03a0a1 100644
--- a/ldap/servers/slapd/opshared.c
+++ b/ldap/servers/slapd/opshared.c
@@ -1090,9 +1090,7 @@ process_entry(Slapi_PBlock *pb, Slapi_Entry *e, int send_result)
ber_bvecfree(refscopy);
refscopy = NULL;
}
- if( NULL != tmpUrls) {
- slapi_ch_free( (void **)&tmpUrls );
- }
+ slapi_ch_free( (void **)&tmpUrls );
}
return 1; /* done with this entry */
diff --git a/ldap/servers/slapd/tools/dbscan.c b/ldap/servers/slapd/tools/dbscan.c
index 6b0f525..d84f138 100644
--- a/ldap/servers/slapd/tools/dbscan.c
+++ b/ldap/servers/slapd/tools/dbscan.c
@@ -825,10 +825,9 @@ display_entryrdn_self(DB *db, ID id, const char *nrdn, int indent)
display_entryrdn_children(db, id_stored_to_internal(elem->rdn_elem_id),
elem->rdn_elem_nrdn_rdn, indent);
bail:
- if (keybuf) {
- free(keybuf);
- }
+ free(keybuf);
cursor->c_close(cursor);
+
return;
}
@@ -866,10 +865,9 @@ display_entryrdn_parent(DB *db, ID id, const char *nrdn, int indent)
elem = (rdn_elem *)data.data;
_entryrdn_dump_rdn_elem(keybuf, elem, indent);
bail:
- if (keybuf) {
- free(keybuf);
- }
+ free(keybuf);
cursor->c_close(cursor);
+
return;
}
@@ -939,10 +937,9 @@ display_entryrdn_children(DB *db, ID id, const char *nrdn, int indent)
}
}
bail:
- if (keybuf) {
- free(keybuf);
- }
+ free(keybuf);
cursor->c_close(cursor);
+
return;
}
diff --git a/lib/base/util.cpp b/lib/base/util.cpp
index b198154..01f916d 100644
--- a/lib/base/util.cpp
+++ b/lib/base/util.cpp
@@ -253,7 +253,7 @@ static char *Bfmt[] = {
static void _util_strftime_conv(char *, int, int, char);
-#define _util_strftime_add(str) for (;(*pt = *str++); pt++);
+#define _util_strftime_add(str) for (;(*pt = *str++); pt++)
#define _util_strftime_copy(str, len) memcpy(pt, str, len); pt += len;
#define _util_strftime_fmt util_strftime
10 years, 11 months
Branch '389-ds-base-1.2.11' - 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 | 14 ++++---
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, 99 insertions(+), 34 deletions(-)
New commits:
commit 3ab5aba6252798b895953a6f2af50916d3525ceb
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!)
(cherry picked from commit 26127d5f7a96c33dfc46f3c8fc21de07455ea667)
diff --git a/ldap/servers/plugins/acl/acl.h b/ldap/servers/plugins/acl/acl.h
index 28c38e7..9cf15aa 100644
--- a/ldap/servers/plugins/acl/acl.h
+++ b/ldap/servers/plugins/acl/acl.h
@@ -866,6 +866,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 39d9f6c..8b11471 100644
--- a/ldap/servers/plugins/acl/aclparse.c
+++ b/ldap/servers/plugins/acl/aclparse.c
@@ -1935,14 +1935,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;
@@ -1974,22 +1973,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 *)) );
@@ -1998,7 +1995,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 */
@@ -2007,10 +2003,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 d3dfa52..958a4a7 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 fce8000..9391891 100644
--- a/ldap/servers/plugins/pam_passthru/pam_ptconfig.c
+++ b/ldap/servers/plugins/pam_passthru/pam_ptconfig.c
@@ -603,6 +603,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);
@@ -689,6 +690,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;
}
}
@@ -697,9 +699,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 7bc6995..fbaa35a 100644
--- a/ldap/servers/plugins/replication/repl5_replica_config.c
+++ b/ldap/servers/plugins/replication/repl5_replica_config.c
@@ -1743,7 +1743,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;
@@ -1786,7 +1786,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 b5fcadc..af5d964 100644
--- a/ldap/servers/plugins/replication/windows_inc_protocol.c
+++ b/ldap/servers/plugins/replication/windows_inc_protocol.c
@@ -1026,6 +1026,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 f22f8e8..bd28d17 100644
--- a/ldap/servers/slapd/back-ldbm/dblayer.c
+++ b/ldap/servers/slapd/back-ldbm/dblayer.c
@@ -1897,9 +1897,9 @@ dblayer_get_id2entry_size(ldbm_instance *inst)
{
struct ldbminfo *li = NULL;
char *id2entry_file = NULL;
- PRFileInfo info;
+ PRFileInfo64 info;
int rc;
- char inst_dir[MAXPATHLEN], *inst_dirp;
+ char inst_dir[MAXPATHLEN], *inst_dirp = NULL;
if (NULL == inst) {
return 0;
@@ -1908,7 +1908,10 @@ 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);
- rc = PR_GetFileInfo(id2entry_file, &info);
+ if(inst_dirp != inst_dir){
+ slapi_ch_free_string(&inst_dirp);
+ }
+ rc = PR_GetFileInfo64(id2entry_file, &info);
slapi_ch_free_string(&id2entry_file);
if (inst_dirp != inst_dir)
slapi_ch_free_string(&inst_dirp);
@@ -3069,6 +3072,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);
@@ -3084,8 +3090,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 f38c39e..a43dc21 100644
--- a/ldap/servers/slapd/entry.c
+++ b/ldap/servers/slapd/entry.c
@@ -552,6 +552,7 @@ str2entry_fast( const char *rawdn, char *s, int flags, int read_stateinfo )
}
done:
+ csnset_free(&valuecsnset);
csn_free(&attributedeletioncsn);
csn_free(&maxcsn);
LDAPDebug( LDAP_DEBUG_TRACE, "<= str2entry_fast 0x%x\n",
@@ -744,6 +745,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;
@@ -764,7 +766,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;
@@ -819,6 +820,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;
@@ -841,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;
@@ -954,6 +957,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++ )
@@ -1285,6 +1289,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 1768c7e..258f6eb 100644
--- a/ldap/servers/slapd/schema.c
+++ b/ldap/servers/slapd/schema.c
@@ -3083,11 +3083,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 )
{
@@ -3969,7 +3969,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, 11 months
Branch '389-ds-base-1.3.0' - 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 | 14 ++++---
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, 99 insertions(+), 34 deletions(-)
New commits:
commit 26127d5f7a96c33dfc46f3c8fc21de07455ea667
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 28c38e7..9cf15aa 100644
--- a/ldap/servers/plugins/acl/acl.h
+++ b/ldap/servers/plugins/acl/acl.h
@@ -866,6 +866,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 b8e51e8..32acf12 100644
--- a/ldap/servers/plugins/dna/dna.c
+++ b/ldap/servers/plugins/dna/dna.c
@@ -1516,11 +1516,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;
}
@@ -1529,9 +1531,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);
+ }
}
}
}
@@ -3341,6 +3347,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 fce8000..9391891 100644
--- a/ldap/servers/plugins/pam_passthru/pam_ptconfig.c
+++ b/ldap/servers/plugins/pam_passthru/pam_ptconfig.c
@@ -603,6 +603,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);
@@ -689,6 +690,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;
}
}
@@ -697,9 +699,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 e7fe487..e7c7420 100644
--- a/ldap/servers/plugins/replication/repl5_replica_config.c
+++ b/ldap/servers/plugins/replication/repl5_replica_config.c
@@ -1743,7 +1743,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;
@@ -1786,7 +1786,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 20a1c7a..4540fe1 100644
--- a/ldap/servers/plugins/replication/windows_inc_protocol.c
+++ b/ldap/servers/plugins/replication/windows_inc_protocol.c
@@ -1025,6 +1025,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 217b20a..0a4e640 100644
--- a/ldap/servers/slapd/back-ldbm/dblayer.c
+++ b/ldap/servers/slapd/back-ldbm/dblayer.c
@@ -1897,9 +1897,9 @@ dblayer_get_id2entry_size(ldbm_instance *inst)
{
struct ldbminfo *li = NULL;
char *id2entry_file = NULL;
- PRFileInfo info;
+ PRFileInfo64 info;
int rc;
- char inst_dir[MAXPATHLEN], *inst_dirp;
+ char inst_dir[MAXPATHLEN], *inst_dirp = NULL;
if (NULL == inst) {
return 0;
@@ -1908,7 +1908,10 @@ 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);
- rc = PR_GetFileInfo(id2entry_file, &info);
+ 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) {
return 0;
@@ -3067,6 +3070,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);
@@ -3082,8 +3088,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 c5780e4..8e184a6 100644
--- a/ldap/servers/slapd/entry.c
+++ b/ldap/servers/slapd/entry.c
@@ -566,6 +566,7 @@ str2entry_fast( const char *rawdn, char *s, int flags, int read_stateinfo )
}
done:
+ csnset_free(&valuecsnset);
csn_free(&attributedeletioncsn);
csn_free(&maxcsn);
LDAPDebug( LDAP_DEBUG_TRACE, "<= str2entry_fast 0x%x\n",
@@ -758,6 +759,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;
@@ -778,7 +780,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;
@@ -833,6 +834,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;
@@ -855,6 +857,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;
@@ -968,6 +971,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++ )
@@ -1299,6 +1303,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, 11 months