Branch '389-ds-base-1.3.1' - 2 commits - ldap/servers lib/ldaputil
by Noriko Hosoi
ldap/servers/slapd/entry.c | 16 +++++++++++++---
lib/ldaputil/dbconf.c | 10 +++++-----
2 files changed, 18 insertions(+), 8 deletions(-)
New commits:
commit 093a146853e6bb44b08c36a1da22735633adbd4a
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Thu Mar 13 13:06:43 2014 -0700
Ticket #47735 - e_uniqueid fails to set if an entry is a conflict entry
Description: In commit e2b8468f459647261812f542485f3481d39bd26c,
to get the base type length when a state info is stripped from
the attribute type, the fix in str2entry_state_information_from_type
blindly returned the base type length for the ordinary sub-typed
attributes. This patch fixes it so that only when the state info
is removed, the length is reset.
https://fedorahosted.org/389/ticket/47735
Reviewed by rmeggins(a)redhat.com (Thank you, Rich!!)
(cherry picked from commit a7ac181d60b1f2ecd3640d0b610eba300b7c3cdb)
(cherry picked from commit 4ffa8247ab9dcc45137f07511d62ea33c24f76df)
diff --git a/ldap/servers/slapd/entry.c b/ldap/servers/slapd/entry.c
index 2b9f83f..0fc1358 100644
--- a/ldap/servers/slapd/entry.c
+++ b/ldap/servers/slapd/entry.c
@@ -105,13 +105,11 @@ str2entry_state_information_from_type(struct berval *atype,
int *attr_state)
{
char *p = NULL;
+ char *semicolonp = NULL;
if ((NULL == atype) || (NULL == atype->bv_val)) {
return;
}
p = PL_strchr(atype->bv_val, ';');
- if (p) {
- atype->bv_len = p - atype->bv_val;
- }
*value_state= VALUE_PRESENT;
*attr_state= ATTRIBUTE_PRESENT;
while(p!=NULL)
@@ -170,19 +168,31 @@ str2entry_state_information_from_type(struct berval *atype,
csn_init_by_csn ( *maxcsn, *attributedeletioncsn );
}
}
+ if (NULL == semicolonp) {
+ semicolonp = p; /* the first semicolon */
+ }
}
else if(strncmp(p+1,"deletedattribute", 16)==0)
{
p[0]='\0';
*attr_state= ATTRIBUTE_DELETED;
+ if (NULL == semicolonp) {
+ semicolonp = p; /* the first semicolon */
+ }
}
else if(strncmp(p+1,"deleted", 7)==0)
{
p[0]='\0';
*value_state= VALUE_DELETED;
+ if (NULL == semicolonp) {
+ semicolonp = p; /* the first semicolon */
+ }
}
p= strchr(p+1, ';');
}
+ if (semicolonp) {
+ atype->bv_len = semicolonp - atype->bv_val;
+ }
}
/* rawdn is not consumed. Caller needs to free it. */
commit cfb821cf44eee3fd977702e6a81267bac1f3625f
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Mon Mar 10 12:50:57 2014 -0700
Ticket #47740 - Coverity issue in 1.3.3
Description: Coverity 11778 - Resource leak
val was allocated by dbconf_decodeval, which was not freed if propval
failed to create.
Reviewed by mareynol(a)redhat.com (Thanks, Mark!)
(cherry picked from commit 6f51e06c606049e7ca8e0b763c683fa98b33974a)
(cherry picked from commit f3afc1198c2d9d63d6b5ad01d3fe5b9061d648a1)
diff --git a/lib/ldaputil/dbconf.c b/lib/ldaputil/dbconf.c
index e6de3b7..1ffdab7 100644
--- a/lib/ldaputil/dbconf.c
+++ b/lib/ldaputil/dbconf.c
@@ -264,20 +264,20 @@ static int dbconf_parse_propval (char *buf, char *ptr,
propval = (DBPropVal_t *)malloc(sizeof(DBPropVal_t));
if (!propval){
- if (encval) free(val);
+ if (encval && val) 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;
+ if (encval && val) free(val); /* val was allocated by dbconf_decodeval */
+
if (!propval->prop || (val && !propval->val)) {
- dbconf_free_propval(propval);
- return LDAPU_ERR_OUT_OF_MEMORY;
+ dbconf_free_propval(propval);
+ return LDAPU_ERR_OUT_OF_MEMORY;
}
- if(encval) free(val); /* val was allocated by dbconf_decodeval */
-
insert_dbinfo_propval(db_info, propval);
return LDAPU_SUCCESS;
}
10 years, 1 month
Branch '389-ds-base-1.3.2' - lib/ldaputil
by Noriko Hosoi
lib/ldaputil/dbconf.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
New commits:
commit f3afc1198c2d9d63d6b5ad01d3fe5b9061d648a1
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Mon Mar 10 12:50:57 2014 -0700
Ticket #47740 - Coverity issue in 1.3.3
Description: Coverity 11778 - Resource leak
val was allocated by dbconf_decodeval, which was not freed if propval
failed to create.
Reviewed by mareynol(a)redhat.com (Thanks, Mark!)
(cherry picked from commit 6f51e06c606049e7ca8e0b763c683fa98b33974a)
diff --git a/lib/ldaputil/dbconf.c b/lib/ldaputil/dbconf.c
index e6de3b7..1ffdab7 100644
--- a/lib/ldaputil/dbconf.c
+++ b/lib/ldaputil/dbconf.c
@@ -264,20 +264,20 @@ static int dbconf_parse_propval (char *buf, char *ptr,
propval = (DBPropVal_t *)malloc(sizeof(DBPropVal_t));
if (!propval){
- if (encval) free(val);
+ if (encval && val) 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;
+ if (encval && val) free(val); /* val was allocated by dbconf_decodeval */
+
if (!propval->prop || (val && !propval->val)) {
- dbconf_free_propval(propval);
- return LDAPU_ERR_OUT_OF_MEMORY;
+ dbconf_free_propval(propval);
+ return LDAPU_ERR_OUT_OF_MEMORY;
}
- if(encval) free(val); /* val was allocated by dbconf_decodeval */
-
insert_dbinfo_propval(db_info, propval);
return LDAPU_SUCCESS;
}
10 years, 1 month
Branch '389-ds-base-1.3.2' - ldap/servers
by Noriko Hosoi
ldap/servers/slapd/entry.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
New commits:
commit 4ffa8247ab9dcc45137f07511d62ea33c24f76df
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Thu Mar 13 13:06:43 2014 -0700
Ticket #47735 - e_uniqueid fails to set if an entry is a conflict entry
Description: In commit e2b8468f459647261812f542485f3481d39bd26c,
to get the base type length when a state info is stripped from
the attribute type, the fix in str2entry_state_information_from_type
blindly returned the base type length for the ordinary sub-typed
attributes. This patch fixes it so that only when the state info
is removed, the length is reset.
https://fedorahosted.org/389/ticket/47735
Reviewed by rmeggins(a)redhat.com (Thank you, Rich!!)
(cherry picked from commit a7ac181d60b1f2ecd3640d0b610eba300b7c3cdb)
diff --git a/ldap/servers/slapd/entry.c b/ldap/servers/slapd/entry.c
index c05d0e2..30228c3 100644
--- a/ldap/servers/slapd/entry.c
+++ b/ldap/servers/slapd/entry.c
@@ -126,13 +126,11 @@ str2entry_state_information_from_type(struct berval *atype,
int *attr_state)
{
char *p = NULL;
+ char *semicolonp = NULL;
if ((NULL == atype) || (NULL == atype->bv_val)) {
return;
}
p = PL_strchr(atype->bv_val, ';');
- if (p) {
- atype->bv_len = p - atype->bv_val;
- }
*value_state= VALUE_PRESENT;
*attr_state= ATTRIBUTE_PRESENT;
while(p!=NULL)
@@ -191,19 +189,31 @@ str2entry_state_information_from_type(struct berval *atype,
csn_init_by_csn ( *maxcsn, *attributedeletioncsn );
}
}
+ if (NULL == semicolonp) {
+ semicolonp = p; /* the first semicolon */
+ }
}
else if(strncmp(p+1,"deletedattribute", 16)==0)
{
p[0]='\0';
*attr_state= ATTRIBUTE_DELETED;
+ if (NULL == semicolonp) {
+ semicolonp = p; /* the first semicolon */
+ }
}
else if(strncmp(p+1,"deleted", 7)==0)
{
p[0]='\0';
*value_state= VALUE_DELETED;
+ if (NULL == semicolonp) {
+ semicolonp = p; /* the first semicolon */
+ }
}
p= strchr(p+1, ';');
}
+ if (semicolonp) {
+ atype->bv_len = semicolonp - atype->bv_val;
+ }
}
/* rawdn is not consumed. Caller needs to free it. */
10 years, 1 month
2 commits - ldap/servers lib/ldaputil
by Noriko Hosoi
ldap/servers/slapd/entry.c | 16 +++++++++++++---
lib/ldaputil/dbconf.c | 10 +++++-----
2 files changed, 18 insertions(+), 8 deletions(-)
New commits:
commit a7ac181d60b1f2ecd3640d0b610eba300b7c3cdb
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Thu Mar 13 13:06:43 2014 -0700
Ticket #47735 - e_uniqueid fails to set if an entry is a conflict entry
Description: In commit e2b8468f459647261812f542485f3481d39bd26c,
to get the base type length when a state info is stripped from
the attribute type, the fix in str2entry_state_information_from_type
blindly returned the base type length for the ordinary sub-typed
attributes. This patch fixes it so that only when the state info
is removed, the length is reset.
https://fedorahosted.org/389/ticket/47735
Reviewed by rmeggins(a)redhat.com (Thank you, Rich!!)
diff --git a/ldap/servers/slapd/entry.c b/ldap/servers/slapd/entry.c
index 9b4a9ab..72ece66 100644
--- a/ldap/servers/slapd/entry.c
+++ b/ldap/servers/slapd/entry.c
@@ -144,13 +144,11 @@ str2entry_state_information_from_type(struct berval *atype,
int *attr_state)
{
char *p = NULL;
+ char *semicolonp = NULL;
if ((NULL == atype) || (NULL == atype->bv_val)) {
return;
}
p = PL_strchr(atype->bv_val, ';');
- if (p) {
- atype->bv_len = p - atype->bv_val;
- }
*value_state= VALUE_PRESENT;
*attr_state= ATTRIBUTE_PRESENT;
while(p!=NULL)
@@ -209,19 +207,31 @@ str2entry_state_information_from_type(struct berval *atype,
csn_init_by_csn ( *maxcsn, *attributedeletioncsn );
}
}
+ if (NULL == semicolonp) {
+ semicolonp = p; /* the first semicolon */
+ }
}
else if(strncmp(p+1,"deletedattribute", 16)==0)
{
p[0]='\0';
*attr_state= ATTRIBUTE_DELETED;
+ if (NULL == semicolonp) {
+ semicolonp = p; /* the first semicolon */
+ }
}
else if(strncmp(p+1,"deleted", 7)==0)
{
p[0]='\0';
*value_state= VALUE_DELETED;
+ if (NULL == semicolonp) {
+ semicolonp = p; /* the first semicolon */
+ }
}
p= strchr(p+1, ';');
}
+ if (semicolonp) {
+ atype->bv_len = semicolonp - atype->bv_val;
+ }
}
/* rawdn is not consumed. Caller needs to free it. */
commit 6f51e06c606049e7ca8e0b763c683fa98b33974a
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Mon Mar 10 12:50:57 2014 -0700
Ticket #47740 - Coverity issue in 1.3.3
Description: Coverity 11778 - Resource leak
val was allocated by dbconf_decodeval, which was not freed if propval
failed to create.
Reviewed by mareynol(a)redhat.com (Thanks, Mark!)
diff --git a/lib/ldaputil/dbconf.c b/lib/ldaputil/dbconf.c
index e6de3b7..1ffdab7 100644
--- a/lib/ldaputil/dbconf.c
+++ b/lib/ldaputil/dbconf.c
@@ -264,20 +264,20 @@ static int dbconf_parse_propval (char *buf, char *ptr,
propval = (DBPropVal_t *)malloc(sizeof(DBPropVal_t));
if (!propval){
- if (encval) free(val);
+ if (encval && val) 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;
+ if (encval && val) free(val); /* val was allocated by dbconf_decodeval */
+
if (!propval->prop || (val && !propval->val)) {
- dbconf_free_propval(propval);
- return LDAPU_ERR_OUT_OF_MEMORY;
+ dbconf_free_propval(propval);
+ return LDAPU_ERR_OUT_OF_MEMORY;
}
- if(encval) free(val); /* val was allocated by dbconf_decodeval */
-
insert_dbinfo_propval(db_info, propval);
return LDAPU_SUCCESS;
}
10 years, 1 month
Branch '389-ds-base-1.2.11' - ldap/servers lib/ldaputil
by Mark Reynolds
ldap/servers/plugins/acl/acleffectiverights.c | 1
ldap/servers/plugins/replication/urp.c | 1
ldap/servers/slapd/saslbind.c | 2
lib/ldaputil/certmap.c | 152 ++++++++++++--------------
4 files changed, 77 insertions(+), 79 deletions(-)
New commits:
commit 1c552d56116cb6124d91773fa539a94033dbec1a
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Thu Mar 13 14:07:49 2014 -0400
Ticket 47740 - Fix coverity issues - Part 5
12494 - resource leak - /ldap/servers/slapd/saslbind.c
12487 - resource leak - /ldap/servers/plugins/replication/urp.c
12486 - resource leak - /ldap/servers/plugins/acl/acleffectiverights.c
12480 - resource leak - lib/ldaputil/certmap.c
12478 - resource leak - lib/ldaputil/certmap.c
12477 - resource leak - lib/ldaputil/certmap.c
https://fedorahosted.org/389/ticket/47740
Reviewed by: rmeggins(Thanks!)
(cherry picked from commit eb10369878df49fdd8a5ff572a6ebeee1716dac5)
diff --git a/ldap/servers/plugins/acl/acleffectiverights.c b/ldap/servers/plugins/acl/acleffectiverights.c
index 380dd74..53e4755 100644
--- a/ldap/servers/plugins/acl/acleffectiverights.c
+++ b/ldap/servers/plugins/acl/acleffectiverights.c
@@ -130,6 +130,7 @@ _ger_g_permission_granted (
}
else
{
+ slapi_ch_free_string(&proxydn); /* this could still have been set - free it */
requestor_sdn = &(pb->pb_op->o_sdn);
}
if ( slapi_sdn_get_dn (requestor_sdn) == NULL )
diff --git a/ldap/servers/plugins/replication/urp.c b/ldap/servers/plugins/replication/urp.c
index e236541..9787ff7 100644
--- a/ldap/servers/plugins/replication/urp.c
+++ b/ldap/servers/plugins/replication/urp.c
@@ -1248,6 +1248,7 @@ get_dn_plus_uniqueid(char *sessionid, const Slapi_DN *oldsdn, const char *unique
char *parentdn = slapi_dn_parent(slapi_sdn_get_dn(oldsdn));
slapi_rdn_add(rdn, SLAPI_ATTR_UNIQUEID, uniqueid);
newdn = slapi_ch_smprintf("%s,%s", slapi_rdn_get_rdn(rdn), parentdn);
+ slapi_ch_free_string(&parentdn);
}
slapi_rdn_free(&rdn);
return newdn;
diff --git a/ldap/servers/slapd/saslbind.c b/ldap/servers/slapd/saslbind.c
index a5db020..eb814a2 100644
--- a/ldap/servers/slapd/saslbind.c
+++ b/ldap/servers/slapd/saslbind.c
@@ -498,7 +498,7 @@ static int ids_sasl_getpluginpath(sasl_conn_t *conn, const char **path)
* 64-bit Linux machines, and /usr/lib/sasl2 on all other platforms.
*/
char *pluginpath = config_get_saslpath();
- if ((!pluginpath) || (*pluginpath == '\0')) {
+ if (!pluginpath) {
if (!(pluginpath = getenv("SASL_PATH"))) {
#if defined(LINUX) && defined(__LP64__)
pluginpath = "/usr/lib64/sasl2";
diff --git a/lib/ldaputil/certmap.c b/lib/ldaputil/certmap.c
index e27633c..aa5bafa 100644
--- a/lib/ldaputil/certmap.c
+++ b/lib/ldaputil/certmap.c
@@ -500,13 +500,13 @@ static int process_certinfo (LDAPUCertMapInfo_t *certinfo)
char *searchAttr = 0;
if (!ldapu_strcasecmp(certinfo->issuerName, "default")) {
- default_certmap_info = certinfo;
+ default_certmap_info = certinfo;
}
else if (!certinfo->issuerDN) {
- return LDAPU_ERR_NO_ISSUERDN_IN_CONFIG_FILE;
+ return LDAPU_ERR_NO_ISSUERDN_IN_CONFIG_FILE;
}
else {
- rv = ldapu_list_add_info(certmap_listinfo, certinfo);
+ rv = ldapu_list_add_info(certmap_listinfo, certinfo);
}
if (rv != LDAPU_SUCCESS) return rv;
@@ -515,21 +515,21 @@ static int process_certinfo (LDAPUCertMapInfo_t *certinfo)
rv = ldapu_certmap_info_attrval (certinfo, LDAPU_ATTR_DNCOMPS, &dncomps);
if (rv == LDAPU_SUCCESS && dncomps) {
- certinfo->dncompsState = COMPS_HAS_ATTRS;
- tolower_string(dncomps);
+ certinfo->dncompsState = COMPS_HAS_ATTRS;
+ tolower_string(dncomps);
}
else if (rv == LDAPU_FAILED) {
- certinfo->dncompsState = COMPS_COMMENTED_OUT;
- rv = LDAPU_SUCCESS;
+ certinfo->dncompsState = COMPS_COMMENTED_OUT;
+ rv = LDAPU_SUCCESS;
}
else if (rv == LDAPU_SUCCESS && !dncomps) {
- certinfo->dncompsState = COMPS_EMPTY;
- dncomps = ""; /* present but empty */
+ certinfo->dncompsState = COMPS_EMPTY;
+ dncomps = ""; /* present but empty */
}
rv = parse_into_bitmask (dncomps, &certinfo->dncomps, -1);
- if (dncomps && *dncomps) free(dncomps);
+ free(dncomps); dncomps = NULL;
if (rv != LDAPU_SUCCESS) return rv;
@@ -538,21 +538,21 @@ static int process_certinfo (LDAPUCertMapInfo_t *certinfo)
&filtercomps);
if (rv == LDAPU_SUCCESS && filtercomps) {
- certinfo->filtercompsState = COMPS_HAS_ATTRS;
- tolower_string(filtercomps);
+ certinfo->filtercompsState = COMPS_HAS_ATTRS;
+ tolower_string(filtercomps);
}
else if (rv == LDAPU_FAILED) {
- certinfo->filtercompsState = COMPS_COMMENTED_OUT;
- rv = LDAPU_SUCCESS;
+ certinfo->filtercompsState = COMPS_COMMENTED_OUT;
+ rv = LDAPU_SUCCESS;
}
else if (rv == LDAPU_SUCCESS && !filtercomps) {
- certinfo->filtercompsState = COMPS_EMPTY;
- filtercomps = ""; /* present but empty */
+ certinfo->filtercompsState = COMPS_EMPTY;
+ filtercomps = ""; /* present but empty */
}
rv = parse_into_bitmask (filtercomps, &certinfo->filtercomps, 0);
- if (filtercomps && *filtercomps) free(filtercomps);
+ if (filtercomps) free(filtercomps);
if (rv != LDAPU_SUCCESS) return rv;
@@ -560,15 +560,15 @@ static int process_certinfo (LDAPUCertMapInfo_t *certinfo)
rv = ldapu_certmap_info_attrval(certinfo, LDAPU_ATTR_CERTMAP_LDAP_ATTR,
&searchAttr);
- if (rv == LDAPU_FAILED || !searchAttr || !*searchAttr)
- rv = LDAPU_SUCCESS;
- else {
- certinfo->searchAttr = searchAttr ? strdup(searchAttr) : 0;
+ if (rv == LDAPU_FAILED || !searchAttr){
+ rv = LDAPU_SUCCESS;
+ } else {
+ certinfo->searchAttr = searchAttr;
- if (searchAttr && !certinfo->searchAttr)
- rv = LDAPU_ERR_OUT_OF_MEMORY;
- else
- rv = LDAPU_SUCCESS;
+ if (searchAttr && !certinfo->searchAttr)
+ rv = LDAPU_ERR_OUT_OF_MEMORY;
+ else
+ rv = LDAPU_SUCCESS;
}
if (rv != LDAPU_SUCCESS) return rv;
@@ -578,73 +578,69 @@ static int process_certinfo (LDAPUCertMapInfo_t *certinfo)
rv = ldapu_certmap_info_attrval(certinfo, LDAPU_ATTR_VERIFYCERT, &verify);
if (rv == LDAPU_SUCCESS) {
- if (!ldapu_strcasecmp(verify, "on"))
- certinfo->verifyCert = 1;
- else if (!ldapu_strcasecmp(verify, "off"))
- certinfo->verifyCert = 0;
- else if (!verify || !*verify) /* for mail/news backward compatibilty */
- certinfo->verifyCert = 1; /* otherwise, this should be an error */
- else
- rv = LDAPU_ERR_MISSING_VERIFYCERT_VAL;
+ if (!ldapu_strcasecmp(verify, "on"))
+ certinfo->verifyCert = 1;
+ else if (!ldapu_strcasecmp(verify, "off"))
+ certinfo->verifyCert = 0;
+ else if (!verify || !*verify) /* for mail/news backward compatibilty */
+ certinfo->verifyCert = 1; /* otherwise, this should be an error */
+ else
+ rv = LDAPU_ERR_MISSING_VERIFYCERT_VAL;
}
else if (rv == LDAPU_FAILED) rv = LDAPU_SUCCESS;
- if (verify && *verify) free(verify);
+ if (verify) free(verify);
if (rv != LDAPU_SUCCESS) return rv;
{
- PRLibrary *lib = 0;
+ PRLibrary *lib = 0;
- /* look for the library property and load it */
- rv = ldapu_certmap_info_attrval(certinfo, LDAPU_ATTR_LIBRARY, &libname);
+ /* look for the library property and load it */
+ rv = ldapu_certmap_info_attrval(certinfo, LDAPU_ATTR_LIBRARY, &libname);
- if (rv == LDAPU_SUCCESS) {
- if (libname && *libname) {
- lib = PR_LoadLibrary(libname);
- if (!lib) rv = LDAPU_ERR_UNABLE_TO_LOAD_PLUGIN;
- }
- else {
- rv = LDAPU_ERR_MISSING_LIBNAME;
- }
- }
- else if (rv == LDAPU_FAILED) rv = LDAPU_SUCCESS;
+ if (rv == LDAPU_SUCCESS) {
+ if (libname && *libname) {
+ lib = PR_LoadLibrary(libname);
+ if (!lib) rv = LDAPU_ERR_UNABLE_TO_LOAD_PLUGIN;
+ } else {
+ rv = LDAPU_ERR_MISSING_LIBNAME;
+ }
+ } else if (rv == LDAPU_FAILED) rv = LDAPU_SUCCESS;
- if (libname) free(libname);
- if (rv != LDAPU_SUCCESS) return rv;
+ if (libname) free(libname);
+ if (rv != LDAPU_SUCCESS) return rv;
- /* look for the InitFn property, find it in the libray and call it */
- rv = ldapu_certmap_info_attrval(certinfo, LDAPU_ATTR_INITFN, &fname);
+ /* look for the InitFn property, find it in the libray and call it */
+ rv = ldapu_certmap_info_attrval(certinfo, LDAPU_ATTR_INITFN, &fname);
- if (rv == LDAPU_SUCCESS) {
- if (fname && *fname) {
- /* If lib is NULL, PR_FindSymbol will search all libs loaded
- * through PR_LoadLibrary.
- */
- CertMapInitFn_t fn = (CertMapInitFn_t)PR_FindSymbol(lib, fname);
+ if (rv == LDAPU_SUCCESS) {
+ if (fname && *fname) {
+ /* If lib is NULL, PR_FindSymbol will search all libs loaded
+ * through PR_LoadLibrary.
+ */
+ CertMapInitFn_t fn = (CertMapInitFn_t)PR_FindSymbol(lib, fname);
- if (!fn) {
- rv = LDAPU_ERR_MISSING_INIT_FN_IN_LIB;
- }
- else {
- rv = (*fn)(certinfo, certinfo->issuerName,
- certinfo->issuerDN, this_dllname);
- }
- }
- else {
- rv = LDAPU_ERR_MISSING_INIT_FN_NAME;
- }
- }
- else if (lib) {
- /* If library is specified, init function must be specified */
- /* If init fn is specified, library may not be specified */
- rv = LDAPU_ERR_MISSING_INIT_FN_IN_CONFIG;
- }
- else if (rv == LDAPU_FAILED) rv = LDAPU_SUCCESS;
-
- if (fname) free(fname);
+ if (!fn) {
+ rv = LDAPU_ERR_MISSING_INIT_FN_IN_LIB;
+ } else {
+ rv = (*fn)(certinfo, certinfo->issuerName,
+ certinfo->issuerDN, this_dllname);
+ }
+ } else {
+ rv = LDAPU_ERR_MISSING_INIT_FN_NAME;
+ }
+ } else if (lib) {
+ /* If library is specified, init function must be specified */
+ /* If init fn is specified, library may not be specified */
+ rv = LDAPU_ERR_MISSING_INIT_FN_IN_CONFIG;
+ } else if (rv == LDAPU_FAILED){
+ rv = LDAPU_SUCCESS;
+ }
+
+ if (fname) free(fname);
- if (rv != LDAPU_SUCCESS) return rv;
+ if (rv != LDAPU_SUCCESS) return rv;
}
return rv;
10 years, 1 month
Branch '389-ds-base-1.3.0' - ldap/servers lib/ldaputil
by Mark Reynolds
ldap/servers/plugins/acl/acleffectiverights.c | 1
ldap/servers/plugins/replication/urp.c | 1
ldap/servers/slapd/saslbind.c | 2
lib/ldaputil/certmap.c | 152 ++++++++++++--------------
4 files changed, 77 insertions(+), 79 deletions(-)
New commits:
commit 68865024c62e36becd75f5a4614cb88d2a20b7d3
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Thu Mar 13 14:07:49 2014 -0400
Ticket 47740 - Fix coverity issues - Part 5
12494 - resource leak - /ldap/servers/slapd/saslbind.c
12487 - resource leak - /ldap/servers/plugins/replication/urp.c
12486 - resource leak - /ldap/servers/plugins/acl/acleffectiverights.c
12480 - resource leak - lib/ldaputil/certmap.c
12478 - resource leak - lib/ldaputil/certmap.c
12477 - resource leak - lib/ldaputil/certmap.c
https://fedorahosted.org/389/ticket/47740
Reviewed by: rmeggins(Thanks!)
(cherry picked from commit eb10369878df49fdd8a5ff572a6ebeee1716dac5)
diff --git a/ldap/servers/plugins/acl/acleffectiverights.c b/ldap/servers/plugins/acl/acleffectiverights.c
index 89ce79b..5bce1ab 100644
--- a/ldap/servers/plugins/acl/acleffectiverights.c
+++ b/ldap/servers/plugins/acl/acleffectiverights.c
@@ -130,6 +130,7 @@ _ger_g_permission_granted (
}
else
{
+ slapi_ch_free_string(&proxydn); /* this could still have been set - free it */
requestor_sdn = &(pb->pb_op->o_sdn);
}
if ( slapi_sdn_get_dn (requestor_sdn) == NULL )
diff --git a/ldap/servers/plugins/replication/urp.c b/ldap/servers/plugins/replication/urp.c
index 471bf8d..b6fe2ff 100644
--- a/ldap/servers/plugins/replication/urp.c
+++ b/ldap/servers/plugins/replication/urp.c
@@ -1280,6 +1280,7 @@ get_dn_plus_uniqueid(char *sessionid, const Slapi_DN *oldsdn, const char *unique
* parentdn is normalized by slapi_sdn_get_dn.
*/
newdn = slapi_ch_smprintf("%s,%s", slapi_rdn_get_rdn(rdn), parentdn);
+ slapi_ch_free_string(&parentdn);
}
slapi_rdn_free(&rdn);
return newdn;
diff --git a/ldap/servers/slapd/saslbind.c b/ldap/servers/slapd/saslbind.c
index 51c0a4e..c790bfe 100644
--- a/ldap/servers/slapd/saslbind.c
+++ b/ldap/servers/slapd/saslbind.c
@@ -528,7 +528,7 @@ static int ids_sasl_getpluginpath(sasl_conn_t *conn, const char **path)
* 64-bit Linux machines, and /usr/lib/sasl2 on all other platforms.
*/
char *pluginpath = config_get_saslpath();
- if ((!pluginpath) || (*pluginpath == '\0')) {
+ if (!pluginpath) {
if (!(pluginpath = getenv("SASL_PATH"))) {
#if defined(LINUX) && defined(__LP64__)
pluginpath = "/usr/lib64/sasl2";
diff --git a/lib/ldaputil/certmap.c b/lib/ldaputil/certmap.c
index e27633c..aa5bafa 100644
--- a/lib/ldaputil/certmap.c
+++ b/lib/ldaputil/certmap.c
@@ -500,13 +500,13 @@ static int process_certinfo (LDAPUCertMapInfo_t *certinfo)
char *searchAttr = 0;
if (!ldapu_strcasecmp(certinfo->issuerName, "default")) {
- default_certmap_info = certinfo;
+ default_certmap_info = certinfo;
}
else if (!certinfo->issuerDN) {
- return LDAPU_ERR_NO_ISSUERDN_IN_CONFIG_FILE;
+ return LDAPU_ERR_NO_ISSUERDN_IN_CONFIG_FILE;
}
else {
- rv = ldapu_list_add_info(certmap_listinfo, certinfo);
+ rv = ldapu_list_add_info(certmap_listinfo, certinfo);
}
if (rv != LDAPU_SUCCESS) return rv;
@@ -515,21 +515,21 @@ static int process_certinfo (LDAPUCertMapInfo_t *certinfo)
rv = ldapu_certmap_info_attrval (certinfo, LDAPU_ATTR_DNCOMPS, &dncomps);
if (rv == LDAPU_SUCCESS && dncomps) {
- certinfo->dncompsState = COMPS_HAS_ATTRS;
- tolower_string(dncomps);
+ certinfo->dncompsState = COMPS_HAS_ATTRS;
+ tolower_string(dncomps);
}
else if (rv == LDAPU_FAILED) {
- certinfo->dncompsState = COMPS_COMMENTED_OUT;
- rv = LDAPU_SUCCESS;
+ certinfo->dncompsState = COMPS_COMMENTED_OUT;
+ rv = LDAPU_SUCCESS;
}
else if (rv == LDAPU_SUCCESS && !dncomps) {
- certinfo->dncompsState = COMPS_EMPTY;
- dncomps = ""; /* present but empty */
+ certinfo->dncompsState = COMPS_EMPTY;
+ dncomps = ""; /* present but empty */
}
rv = parse_into_bitmask (dncomps, &certinfo->dncomps, -1);
- if (dncomps && *dncomps) free(dncomps);
+ free(dncomps); dncomps = NULL;
if (rv != LDAPU_SUCCESS) return rv;
@@ -538,21 +538,21 @@ static int process_certinfo (LDAPUCertMapInfo_t *certinfo)
&filtercomps);
if (rv == LDAPU_SUCCESS && filtercomps) {
- certinfo->filtercompsState = COMPS_HAS_ATTRS;
- tolower_string(filtercomps);
+ certinfo->filtercompsState = COMPS_HAS_ATTRS;
+ tolower_string(filtercomps);
}
else if (rv == LDAPU_FAILED) {
- certinfo->filtercompsState = COMPS_COMMENTED_OUT;
- rv = LDAPU_SUCCESS;
+ certinfo->filtercompsState = COMPS_COMMENTED_OUT;
+ rv = LDAPU_SUCCESS;
}
else if (rv == LDAPU_SUCCESS && !filtercomps) {
- certinfo->filtercompsState = COMPS_EMPTY;
- filtercomps = ""; /* present but empty */
+ certinfo->filtercompsState = COMPS_EMPTY;
+ filtercomps = ""; /* present but empty */
}
rv = parse_into_bitmask (filtercomps, &certinfo->filtercomps, 0);
- if (filtercomps && *filtercomps) free(filtercomps);
+ if (filtercomps) free(filtercomps);
if (rv != LDAPU_SUCCESS) return rv;
@@ -560,15 +560,15 @@ static int process_certinfo (LDAPUCertMapInfo_t *certinfo)
rv = ldapu_certmap_info_attrval(certinfo, LDAPU_ATTR_CERTMAP_LDAP_ATTR,
&searchAttr);
- if (rv == LDAPU_FAILED || !searchAttr || !*searchAttr)
- rv = LDAPU_SUCCESS;
- else {
- certinfo->searchAttr = searchAttr ? strdup(searchAttr) : 0;
+ if (rv == LDAPU_FAILED || !searchAttr){
+ rv = LDAPU_SUCCESS;
+ } else {
+ certinfo->searchAttr = searchAttr;
- if (searchAttr && !certinfo->searchAttr)
- rv = LDAPU_ERR_OUT_OF_MEMORY;
- else
- rv = LDAPU_SUCCESS;
+ if (searchAttr && !certinfo->searchAttr)
+ rv = LDAPU_ERR_OUT_OF_MEMORY;
+ else
+ rv = LDAPU_SUCCESS;
}
if (rv != LDAPU_SUCCESS) return rv;
@@ -578,73 +578,69 @@ static int process_certinfo (LDAPUCertMapInfo_t *certinfo)
rv = ldapu_certmap_info_attrval(certinfo, LDAPU_ATTR_VERIFYCERT, &verify);
if (rv == LDAPU_SUCCESS) {
- if (!ldapu_strcasecmp(verify, "on"))
- certinfo->verifyCert = 1;
- else if (!ldapu_strcasecmp(verify, "off"))
- certinfo->verifyCert = 0;
- else if (!verify || !*verify) /* for mail/news backward compatibilty */
- certinfo->verifyCert = 1; /* otherwise, this should be an error */
- else
- rv = LDAPU_ERR_MISSING_VERIFYCERT_VAL;
+ if (!ldapu_strcasecmp(verify, "on"))
+ certinfo->verifyCert = 1;
+ else if (!ldapu_strcasecmp(verify, "off"))
+ certinfo->verifyCert = 0;
+ else if (!verify || !*verify) /* for mail/news backward compatibilty */
+ certinfo->verifyCert = 1; /* otherwise, this should be an error */
+ else
+ rv = LDAPU_ERR_MISSING_VERIFYCERT_VAL;
}
else if (rv == LDAPU_FAILED) rv = LDAPU_SUCCESS;
- if (verify && *verify) free(verify);
+ if (verify) free(verify);
if (rv != LDAPU_SUCCESS) return rv;
{
- PRLibrary *lib = 0;
+ PRLibrary *lib = 0;
- /* look for the library property and load it */
- rv = ldapu_certmap_info_attrval(certinfo, LDAPU_ATTR_LIBRARY, &libname);
+ /* look for the library property and load it */
+ rv = ldapu_certmap_info_attrval(certinfo, LDAPU_ATTR_LIBRARY, &libname);
- if (rv == LDAPU_SUCCESS) {
- if (libname && *libname) {
- lib = PR_LoadLibrary(libname);
- if (!lib) rv = LDAPU_ERR_UNABLE_TO_LOAD_PLUGIN;
- }
- else {
- rv = LDAPU_ERR_MISSING_LIBNAME;
- }
- }
- else if (rv == LDAPU_FAILED) rv = LDAPU_SUCCESS;
+ if (rv == LDAPU_SUCCESS) {
+ if (libname && *libname) {
+ lib = PR_LoadLibrary(libname);
+ if (!lib) rv = LDAPU_ERR_UNABLE_TO_LOAD_PLUGIN;
+ } else {
+ rv = LDAPU_ERR_MISSING_LIBNAME;
+ }
+ } else if (rv == LDAPU_FAILED) rv = LDAPU_SUCCESS;
- if (libname) free(libname);
- if (rv != LDAPU_SUCCESS) return rv;
+ if (libname) free(libname);
+ if (rv != LDAPU_SUCCESS) return rv;
- /* look for the InitFn property, find it in the libray and call it */
- rv = ldapu_certmap_info_attrval(certinfo, LDAPU_ATTR_INITFN, &fname);
+ /* look for the InitFn property, find it in the libray and call it */
+ rv = ldapu_certmap_info_attrval(certinfo, LDAPU_ATTR_INITFN, &fname);
- if (rv == LDAPU_SUCCESS) {
- if (fname && *fname) {
- /* If lib is NULL, PR_FindSymbol will search all libs loaded
- * through PR_LoadLibrary.
- */
- CertMapInitFn_t fn = (CertMapInitFn_t)PR_FindSymbol(lib, fname);
+ if (rv == LDAPU_SUCCESS) {
+ if (fname && *fname) {
+ /* If lib is NULL, PR_FindSymbol will search all libs loaded
+ * through PR_LoadLibrary.
+ */
+ CertMapInitFn_t fn = (CertMapInitFn_t)PR_FindSymbol(lib, fname);
- if (!fn) {
- rv = LDAPU_ERR_MISSING_INIT_FN_IN_LIB;
- }
- else {
- rv = (*fn)(certinfo, certinfo->issuerName,
- certinfo->issuerDN, this_dllname);
- }
- }
- else {
- rv = LDAPU_ERR_MISSING_INIT_FN_NAME;
- }
- }
- else if (lib) {
- /* If library is specified, init function must be specified */
- /* If init fn is specified, library may not be specified */
- rv = LDAPU_ERR_MISSING_INIT_FN_IN_CONFIG;
- }
- else if (rv == LDAPU_FAILED) rv = LDAPU_SUCCESS;
-
- if (fname) free(fname);
+ if (!fn) {
+ rv = LDAPU_ERR_MISSING_INIT_FN_IN_LIB;
+ } else {
+ rv = (*fn)(certinfo, certinfo->issuerName,
+ certinfo->issuerDN, this_dllname);
+ }
+ } else {
+ rv = LDAPU_ERR_MISSING_INIT_FN_NAME;
+ }
+ } else if (lib) {
+ /* If library is specified, init function must be specified */
+ /* If init fn is specified, library may not be specified */
+ rv = LDAPU_ERR_MISSING_INIT_FN_IN_CONFIG;
+ } else if (rv == LDAPU_FAILED){
+ rv = LDAPU_SUCCESS;
+ }
+
+ if (fname) free(fname);
- if (rv != LDAPU_SUCCESS) return rv;
+ if (rv != LDAPU_SUCCESS) return rv;
}
return rv;
10 years, 1 month
Branch '389-ds-base-1.3.1' - ldap/servers lib/ldaputil
by Mark Reynolds
ldap/servers/plugins/acl/acleffectiverights.c | 1
ldap/servers/plugins/replication/urp.c | 1
ldap/servers/slapd/saslbind.c | 2
lib/ldaputil/certmap.c | 152 ++++++++++++--------------
4 files changed, 77 insertions(+), 79 deletions(-)
New commits:
commit 0a28515a9ac5be443342c4f7f98f9ad49d32abbd
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Thu Mar 13 14:07:49 2014 -0400
Ticket 47740 - Fix coverity issues - Part 5
12494 - resource leak - /ldap/servers/slapd/saslbind.c
12487 - resource leak - /ldap/servers/plugins/replication/urp.c
12486 - resource leak - /ldap/servers/plugins/acl/acleffectiverights.c
12480 - resource leak - lib/ldaputil/certmap.c
12478 - resource leak - lib/ldaputil/certmap.c
12477 - resource leak - lib/ldaputil/certmap.c
https://fedorahosted.org/389/ticket/47740
Reviewed by: rmeggins(Thanks!)
(cherry picked from commit eb10369878df49fdd8a5ff572a6ebeee1716dac5)
diff --git a/ldap/servers/plugins/acl/acleffectiverights.c b/ldap/servers/plugins/acl/acleffectiverights.c
index e4537af..dc22451 100644
--- a/ldap/servers/plugins/acl/acleffectiverights.c
+++ b/ldap/servers/plugins/acl/acleffectiverights.c
@@ -132,6 +132,7 @@ _ger_g_permission_granted (
}
else
{
+ slapi_ch_free_string(&proxydn); /* this could still have been set - free it */
requestor_sdn = &(pb->pb_op->o_sdn);
}
if ( slapi_sdn_get_dn (requestor_sdn) == NULL )
diff --git a/ldap/servers/plugins/replication/urp.c b/ldap/servers/plugins/replication/urp.c
index 471bf8d..b6fe2ff 100644
--- a/ldap/servers/plugins/replication/urp.c
+++ b/ldap/servers/plugins/replication/urp.c
@@ -1280,6 +1280,7 @@ get_dn_plus_uniqueid(char *sessionid, const Slapi_DN *oldsdn, const char *unique
* parentdn is normalized by slapi_sdn_get_dn.
*/
newdn = slapi_ch_smprintf("%s,%s", slapi_rdn_get_rdn(rdn), parentdn);
+ slapi_ch_free_string(&parentdn);
}
slapi_rdn_free(&rdn);
return newdn;
diff --git a/ldap/servers/slapd/saslbind.c b/ldap/servers/slapd/saslbind.c
index b405c46..c293f6f 100644
--- a/ldap/servers/slapd/saslbind.c
+++ b/ldap/servers/slapd/saslbind.c
@@ -521,7 +521,7 @@ static int ids_sasl_getpluginpath(sasl_conn_t *conn, const char **path)
* 64-bit Linux machines, and /usr/lib/sasl2 on all other platforms.
*/
char *pluginpath = config_get_saslpath();
- if ((!pluginpath) || (*pluginpath == '\0')) {
+ if (!pluginpath) {
if (!(pluginpath = getenv("SASL_PATH"))) {
#if defined(LINUX) && defined(__LP64__)
pluginpath = "/usr/lib64/sasl2";
diff --git a/lib/ldaputil/certmap.c b/lib/ldaputil/certmap.c
index e27633c..aa5bafa 100644
--- a/lib/ldaputil/certmap.c
+++ b/lib/ldaputil/certmap.c
@@ -500,13 +500,13 @@ static int process_certinfo (LDAPUCertMapInfo_t *certinfo)
char *searchAttr = 0;
if (!ldapu_strcasecmp(certinfo->issuerName, "default")) {
- default_certmap_info = certinfo;
+ default_certmap_info = certinfo;
}
else if (!certinfo->issuerDN) {
- return LDAPU_ERR_NO_ISSUERDN_IN_CONFIG_FILE;
+ return LDAPU_ERR_NO_ISSUERDN_IN_CONFIG_FILE;
}
else {
- rv = ldapu_list_add_info(certmap_listinfo, certinfo);
+ rv = ldapu_list_add_info(certmap_listinfo, certinfo);
}
if (rv != LDAPU_SUCCESS) return rv;
@@ -515,21 +515,21 @@ static int process_certinfo (LDAPUCertMapInfo_t *certinfo)
rv = ldapu_certmap_info_attrval (certinfo, LDAPU_ATTR_DNCOMPS, &dncomps);
if (rv == LDAPU_SUCCESS && dncomps) {
- certinfo->dncompsState = COMPS_HAS_ATTRS;
- tolower_string(dncomps);
+ certinfo->dncompsState = COMPS_HAS_ATTRS;
+ tolower_string(dncomps);
}
else if (rv == LDAPU_FAILED) {
- certinfo->dncompsState = COMPS_COMMENTED_OUT;
- rv = LDAPU_SUCCESS;
+ certinfo->dncompsState = COMPS_COMMENTED_OUT;
+ rv = LDAPU_SUCCESS;
}
else if (rv == LDAPU_SUCCESS && !dncomps) {
- certinfo->dncompsState = COMPS_EMPTY;
- dncomps = ""; /* present but empty */
+ certinfo->dncompsState = COMPS_EMPTY;
+ dncomps = ""; /* present but empty */
}
rv = parse_into_bitmask (dncomps, &certinfo->dncomps, -1);
- if (dncomps && *dncomps) free(dncomps);
+ free(dncomps); dncomps = NULL;
if (rv != LDAPU_SUCCESS) return rv;
@@ -538,21 +538,21 @@ static int process_certinfo (LDAPUCertMapInfo_t *certinfo)
&filtercomps);
if (rv == LDAPU_SUCCESS && filtercomps) {
- certinfo->filtercompsState = COMPS_HAS_ATTRS;
- tolower_string(filtercomps);
+ certinfo->filtercompsState = COMPS_HAS_ATTRS;
+ tolower_string(filtercomps);
}
else if (rv == LDAPU_FAILED) {
- certinfo->filtercompsState = COMPS_COMMENTED_OUT;
- rv = LDAPU_SUCCESS;
+ certinfo->filtercompsState = COMPS_COMMENTED_OUT;
+ rv = LDAPU_SUCCESS;
}
else if (rv == LDAPU_SUCCESS && !filtercomps) {
- certinfo->filtercompsState = COMPS_EMPTY;
- filtercomps = ""; /* present but empty */
+ certinfo->filtercompsState = COMPS_EMPTY;
+ filtercomps = ""; /* present but empty */
}
rv = parse_into_bitmask (filtercomps, &certinfo->filtercomps, 0);
- if (filtercomps && *filtercomps) free(filtercomps);
+ if (filtercomps) free(filtercomps);
if (rv != LDAPU_SUCCESS) return rv;
@@ -560,15 +560,15 @@ static int process_certinfo (LDAPUCertMapInfo_t *certinfo)
rv = ldapu_certmap_info_attrval(certinfo, LDAPU_ATTR_CERTMAP_LDAP_ATTR,
&searchAttr);
- if (rv == LDAPU_FAILED || !searchAttr || !*searchAttr)
- rv = LDAPU_SUCCESS;
- else {
- certinfo->searchAttr = searchAttr ? strdup(searchAttr) : 0;
+ if (rv == LDAPU_FAILED || !searchAttr){
+ rv = LDAPU_SUCCESS;
+ } else {
+ certinfo->searchAttr = searchAttr;
- if (searchAttr && !certinfo->searchAttr)
- rv = LDAPU_ERR_OUT_OF_MEMORY;
- else
- rv = LDAPU_SUCCESS;
+ if (searchAttr && !certinfo->searchAttr)
+ rv = LDAPU_ERR_OUT_OF_MEMORY;
+ else
+ rv = LDAPU_SUCCESS;
}
if (rv != LDAPU_SUCCESS) return rv;
@@ -578,73 +578,69 @@ static int process_certinfo (LDAPUCertMapInfo_t *certinfo)
rv = ldapu_certmap_info_attrval(certinfo, LDAPU_ATTR_VERIFYCERT, &verify);
if (rv == LDAPU_SUCCESS) {
- if (!ldapu_strcasecmp(verify, "on"))
- certinfo->verifyCert = 1;
- else if (!ldapu_strcasecmp(verify, "off"))
- certinfo->verifyCert = 0;
- else if (!verify || !*verify) /* for mail/news backward compatibilty */
- certinfo->verifyCert = 1; /* otherwise, this should be an error */
- else
- rv = LDAPU_ERR_MISSING_VERIFYCERT_VAL;
+ if (!ldapu_strcasecmp(verify, "on"))
+ certinfo->verifyCert = 1;
+ else if (!ldapu_strcasecmp(verify, "off"))
+ certinfo->verifyCert = 0;
+ else if (!verify || !*verify) /* for mail/news backward compatibilty */
+ certinfo->verifyCert = 1; /* otherwise, this should be an error */
+ else
+ rv = LDAPU_ERR_MISSING_VERIFYCERT_VAL;
}
else if (rv == LDAPU_FAILED) rv = LDAPU_SUCCESS;
- if (verify && *verify) free(verify);
+ if (verify) free(verify);
if (rv != LDAPU_SUCCESS) return rv;
{
- PRLibrary *lib = 0;
+ PRLibrary *lib = 0;
- /* look for the library property and load it */
- rv = ldapu_certmap_info_attrval(certinfo, LDAPU_ATTR_LIBRARY, &libname);
+ /* look for the library property and load it */
+ rv = ldapu_certmap_info_attrval(certinfo, LDAPU_ATTR_LIBRARY, &libname);
- if (rv == LDAPU_SUCCESS) {
- if (libname && *libname) {
- lib = PR_LoadLibrary(libname);
- if (!lib) rv = LDAPU_ERR_UNABLE_TO_LOAD_PLUGIN;
- }
- else {
- rv = LDAPU_ERR_MISSING_LIBNAME;
- }
- }
- else if (rv == LDAPU_FAILED) rv = LDAPU_SUCCESS;
+ if (rv == LDAPU_SUCCESS) {
+ if (libname && *libname) {
+ lib = PR_LoadLibrary(libname);
+ if (!lib) rv = LDAPU_ERR_UNABLE_TO_LOAD_PLUGIN;
+ } else {
+ rv = LDAPU_ERR_MISSING_LIBNAME;
+ }
+ } else if (rv == LDAPU_FAILED) rv = LDAPU_SUCCESS;
- if (libname) free(libname);
- if (rv != LDAPU_SUCCESS) return rv;
+ if (libname) free(libname);
+ if (rv != LDAPU_SUCCESS) return rv;
- /* look for the InitFn property, find it in the libray and call it */
- rv = ldapu_certmap_info_attrval(certinfo, LDAPU_ATTR_INITFN, &fname);
+ /* look for the InitFn property, find it in the libray and call it */
+ rv = ldapu_certmap_info_attrval(certinfo, LDAPU_ATTR_INITFN, &fname);
- if (rv == LDAPU_SUCCESS) {
- if (fname && *fname) {
- /* If lib is NULL, PR_FindSymbol will search all libs loaded
- * through PR_LoadLibrary.
- */
- CertMapInitFn_t fn = (CertMapInitFn_t)PR_FindSymbol(lib, fname);
+ if (rv == LDAPU_SUCCESS) {
+ if (fname && *fname) {
+ /* If lib is NULL, PR_FindSymbol will search all libs loaded
+ * through PR_LoadLibrary.
+ */
+ CertMapInitFn_t fn = (CertMapInitFn_t)PR_FindSymbol(lib, fname);
- if (!fn) {
- rv = LDAPU_ERR_MISSING_INIT_FN_IN_LIB;
- }
- else {
- rv = (*fn)(certinfo, certinfo->issuerName,
- certinfo->issuerDN, this_dllname);
- }
- }
- else {
- rv = LDAPU_ERR_MISSING_INIT_FN_NAME;
- }
- }
- else if (lib) {
- /* If library is specified, init function must be specified */
- /* If init fn is specified, library may not be specified */
- rv = LDAPU_ERR_MISSING_INIT_FN_IN_CONFIG;
- }
- else if (rv == LDAPU_FAILED) rv = LDAPU_SUCCESS;
-
- if (fname) free(fname);
+ if (!fn) {
+ rv = LDAPU_ERR_MISSING_INIT_FN_IN_LIB;
+ } else {
+ rv = (*fn)(certinfo, certinfo->issuerName,
+ certinfo->issuerDN, this_dllname);
+ }
+ } else {
+ rv = LDAPU_ERR_MISSING_INIT_FN_NAME;
+ }
+ } else if (lib) {
+ /* If library is specified, init function must be specified */
+ /* If init fn is specified, library may not be specified */
+ rv = LDAPU_ERR_MISSING_INIT_FN_IN_CONFIG;
+ } else if (rv == LDAPU_FAILED){
+ rv = LDAPU_SUCCESS;
+ }
+
+ if (fname) free(fname);
- if (rv != LDAPU_SUCCESS) return rv;
+ if (rv != LDAPU_SUCCESS) return rv;
}
return rv;
10 years, 1 month
Branch '389-ds-base-1.3.2' - ldap/servers lib/ldaputil
by Mark Reynolds
ldap/servers/plugins/acl/acleffectiverights.c | 1
ldap/servers/plugins/replication/urp.c | 1
ldap/servers/slapd/saslbind.c | 2
lib/ldaputil/certmap.c | 152 ++++++++++++--------------
4 files changed, 77 insertions(+), 79 deletions(-)
New commits:
commit eb10369878df49fdd8a5ff572a6ebeee1716dac5
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Thu Mar 13 14:07:49 2014 -0400
Ticket 47740 - Fix coverity issues - Part 5
12494 - resource leak - /ldap/servers/slapd/saslbind.c
12487 - resource leak - /ldap/servers/plugins/replication/urp.c
12486 - resource leak - /ldap/servers/plugins/acl/acleffectiverights.c
12480 - resource leak - lib/ldaputil/certmap.c
12478 - resource leak - lib/ldaputil/certmap.c
12477 - resource leak - lib/ldaputil/certmap.c
https://fedorahosted.org/389/ticket/47740
Reviewed by: rmeggins(Thanks!)
diff --git a/ldap/servers/plugins/acl/acleffectiverights.c b/ldap/servers/plugins/acl/acleffectiverights.c
index e4537af..dc22451 100644
--- a/ldap/servers/plugins/acl/acleffectiverights.c
+++ b/ldap/servers/plugins/acl/acleffectiverights.c
@@ -132,6 +132,7 @@ _ger_g_permission_granted (
}
else
{
+ slapi_ch_free_string(&proxydn); /* this could still have been set - free it */
requestor_sdn = &(pb->pb_op->o_sdn);
}
if ( slapi_sdn_get_dn (requestor_sdn) == NULL )
diff --git a/ldap/servers/plugins/replication/urp.c b/ldap/servers/plugins/replication/urp.c
index 471bf8d..b6fe2ff 100644
--- a/ldap/servers/plugins/replication/urp.c
+++ b/ldap/servers/plugins/replication/urp.c
@@ -1280,6 +1280,7 @@ get_dn_plus_uniqueid(char *sessionid, const Slapi_DN *oldsdn, const char *unique
* parentdn is normalized by slapi_sdn_get_dn.
*/
newdn = slapi_ch_smprintf("%s,%s", slapi_rdn_get_rdn(rdn), parentdn);
+ slapi_ch_free_string(&parentdn);
}
slapi_rdn_free(&rdn);
return newdn;
diff --git a/ldap/servers/slapd/saslbind.c b/ldap/servers/slapd/saslbind.c
index b405c46..c293f6f 100644
--- a/ldap/servers/slapd/saslbind.c
+++ b/ldap/servers/slapd/saslbind.c
@@ -521,7 +521,7 @@ static int ids_sasl_getpluginpath(sasl_conn_t *conn, const char **path)
* 64-bit Linux machines, and /usr/lib/sasl2 on all other platforms.
*/
char *pluginpath = config_get_saslpath();
- if ((!pluginpath) || (*pluginpath == '\0')) {
+ if (!pluginpath) {
if (!(pluginpath = getenv("SASL_PATH"))) {
#if defined(LINUX) && defined(__LP64__)
pluginpath = "/usr/lib64/sasl2";
diff --git a/lib/ldaputil/certmap.c b/lib/ldaputil/certmap.c
index e27633c..aa5bafa 100644
--- a/lib/ldaputil/certmap.c
+++ b/lib/ldaputil/certmap.c
@@ -500,13 +500,13 @@ static int process_certinfo (LDAPUCertMapInfo_t *certinfo)
char *searchAttr = 0;
if (!ldapu_strcasecmp(certinfo->issuerName, "default")) {
- default_certmap_info = certinfo;
+ default_certmap_info = certinfo;
}
else if (!certinfo->issuerDN) {
- return LDAPU_ERR_NO_ISSUERDN_IN_CONFIG_FILE;
+ return LDAPU_ERR_NO_ISSUERDN_IN_CONFIG_FILE;
}
else {
- rv = ldapu_list_add_info(certmap_listinfo, certinfo);
+ rv = ldapu_list_add_info(certmap_listinfo, certinfo);
}
if (rv != LDAPU_SUCCESS) return rv;
@@ -515,21 +515,21 @@ static int process_certinfo (LDAPUCertMapInfo_t *certinfo)
rv = ldapu_certmap_info_attrval (certinfo, LDAPU_ATTR_DNCOMPS, &dncomps);
if (rv == LDAPU_SUCCESS && dncomps) {
- certinfo->dncompsState = COMPS_HAS_ATTRS;
- tolower_string(dncomps);
+ certinfo->dncompsState = COMPS_HAS_ATTRS;
+ tolower_string(dncomps);
}
else if (rv == LDAPU_FAILED) {
- certinfo->dncompsState = COMPS_COMMENTED_OUT;
- rv = LDAPU_SUCCESS;
+ certinfo->dncompsState = COMPS_COMMENTED_OUT;
+ rv = LDAPU_SUCCESS;
}
else if (rv == LDAPU_SUCCESS && !dncomps) {
- certinfo->dncompsState = COMPS_EMPTY;
- dncomps = ""; /* present but empty */
+ certinfo->dncompsState = COMPS_EMPTY;
+ dncomps = ""; /* present but empty */
}
rv = parse_into_bitmask (dncomps, &certinfo->dncomps, -1);
- if (dncomps && *dncomps) free(dncomps);
+ free(dncomps); dncomps = NULL;
if (rv != LDAPU_SUCCESS) return rv;
@@ -538,21 +538,21 @@ static int process_certinfo (LDAPUCertMapInfo_t *certinfo)
&filtercomps);
if (rv == LDAPU_SUCCESS && filtercomps) {
- certinfo->filtercompsState = COMPS_HAS_ATTRS;
- tolower_string(filtercomps);
+ certinfo->filtercompsState = COMPS_HAS_ATTRS;
+ tolower_string(filtercomps);
}
else if (rv == LDAPU_FAILED) {
- certinfo->filtercompsState = COMPS_COMMENTED_OUT;
- rv = LDAPU_SUCCESS;
+ certinfo->filtercompsState = COMPS_COMMENTED_OUT;
+ rv = LDAPU_SUCCESS;
}
else if (rv == LDAPU_SUCCESS && !filtercomps) {
- certinfo->filtercompsState = COMPS_EMPTY;
- filtercomps = ""; /* present but empty */
+ certinfo->filtercompsState = COMPS_EMPTY;
+ filtercomps = ""; /* present but empty */
}
rv = parse_into_bitmask (filtercomps, &certinfo->filtercomps, 0);
- if (filtercomps && *filtercomps) free(filtercomps);
+ if (filtercomps) free(filtercomps);
if (rv != LDAPU_SUCCESS) return rv;
@@ -560,15 +560,15 @@ static int process_certinfo (LDAPUCertMapInfo_t *certinfo)
rv = ldapu_certmap_info_attrval(certinfo, LDAPU_ATTR_CERTMAP_LDAP_ATTR,
&searchAttr);
- if (rv == LDAPU_FAILED || !searchAttr || !*searchAttr)
- rv = LDAPU_SUCCESS;
- else {
- certinfo->searchAttr = searchAttr ? strdup(searchAttr) : 0;
+ if (rv == LDAPU_FAILED || !searchAttr){
+ rv = LDAPU_SUCCESS;
+ } else {
+ certinfo->searchAttr = searchAttr;
- if (searchAttr && !certinfo->searchAttr)
- rv = LDAPU_ERR_OUT_OF_MEMORY;
- else
- rv = LDAPU_SUCCESS;
+ if (searchAttr && !certinfo->searchAttr)
+ rv = LDAPU_ERR_OUT_OF_MEMORY;
+ else
+ rv = LDAPU_SUCCESS;
}
if (rv != LDAPU_SUCCESS) return rv;
@@ -578,73 +578,69 @@ static int process_certinfo (LDAPUCertMapInfo_t *certinfo)
rv = ldapu_certmap_info_attrval(certinfo, LDAPU_ATTR_VERIFYCERT, &verify);
if (rv == LDAPU_SUCCESS) {
- if (!ldapu_strcasecmp(verify, "on"))
- certinfo->verifyCert = 1;
- else if (!ldapu_strcasecmp(verify, "off"))
- certinfo->verifyCert = 0;
- else if (!verify || !*verify) /* for mail/news backward compatibilty */
- certinfo->verifyCert = 1; /* otherwise, this should be an error */
- else
- rv = LDAPU_ERR_MISSING_VERIFYCERT_VAL;
+ if (!ldapu_strcasecmp(verify, "on"))
+ certinfo->verifyCert = 1;
+ else if (!ldapu_strcasecmp(verify, "off"))
+ certinfo->verifyCert = 0;
+ else if (!verify || !*verify) /* for mail/news backward compatibilty */
+ certinfo->verifyCert = 1; /* otherwise, this should be an error */
+ else
+ rv = LDAPU_ERR_MISSING_VERIFYCERT_VAL;
}
else if (rv == LDAPU_FAILED) rv = LDAPU_SUCCESS;
- if (verify && *verify) free(verify);
+ if (verify) free(verify);
if (rv != LDAPU_SUCCESS) return rv;
{
- PRLibrary *lib = 0;
+ PRLibrary *lib = 0;
- /* look for the library property and load it */
- rv = ldapu_certmap_info_attrval(certinfo, LDAPU_ATTR_LIBRARY, &libname);
+ /* look for the library property and load it */
+ rv = ldapu_certmap_info_attrval(certinfo, LDAPU_ATTR_LIBRARY, &libname);
- if (rv == LDAPU_SUCCESS) {
- if (libname && *libname) {
- lib = PR_LoadLibrary(libname);
- if (!lib) rv = LDAPU_ERR_UNABLE_TO_LOAD_PLUGIN;
- }
- else {
- rv = LDAPU_ERR_MISSING_LIBNAME;
- }
- }
- else if (rv == LDAPU_FAILED) rv = LDAPU_SUCCESS;
+ if (rv == LDAPU_SUCCESS) {
+ if (libname && *libname) {
+ lib = PR_LoadLibrary(libname);
+ if (!lib) rv = LDAPU_ERR_UNABLE_TO_LOAD_PLUGIN;
+ } else {
+ rv = LDAPU_ERR_MISSING_LIBNAME;
+ }
+ } else if (rv == LDAPU_FAILED) rv = LDAPU_SUCCESS;
- if (libname) free(libname);
- if (rv != LDAPU_SUCCESS) return rv;
+ if (libname) free(libname);
+ if (rv != LDAPU_SUCCESS) return rv;
- /* look for the InitFn property, find it in the libray and call it */
- rv = ldapu_certmap_info_attrval(certinfo, LDAPU_ATTR_INITFN, &fname);
+ /* look for the InitFn property, find it in the libray and call it */
+ rv = ldapu_certmap_info_attrval(certinfo, LDAPU_ATTR_INITFN, &fname);
- if (rv == LDAPU_SUCCESS) {
- if (fname && *fname) {
- /* If lib is NULL, PR_FindSymbol will search all libs loaded
- * through PR_LoadLibrary.
- */
- CertMapInitFn_t fn = (CertMapInitFn_t)PR_FindSymbol(lib, fname);
+ if (rv == LDAPU_SUCCESS) {
+ if (fname && *fname) {
+ /* If lib is NULL, PR_FindSymbol will search all libs loaded
+ * through PR_LoadLibrary.
+ */
+ CertMapInitFn_t fn = (CertMapInitFn_t)PR_FindSymbol(lib, fname);
- if (!fn) {
- rv = LDAPU_ERR_MISSING_INIT_FN_IN_LIB;
- }
- else {
- rv = (*fn)(certinfo, certinfo->issuerName,
- certinfo->issuerDN, this_dllname);
- }
- }
- else {
- rv = LDAPU_ERR_MISSING_INIT_FN_NAME;
- }
- }
- else if (lib) {
- /* If library is specified, init function must be specified */
- /* If init fn is specified, library may not be specified */
- rv = LDAPU_ERR_MISSING_INIT_FN_IN_CONFIG;
- }
- else if (rv == LDAPU_FAILED) rv = LDAPU_SUCCESS;
-
- if (fname) free(fname);
+ if (!fn) {
+ rv = LDAPU_ERR_MISSING_INIT_FN_IN_LIB;
+ } else {
+ rv = (*fn)(certinfo, certinfo->issuerName,
+ certinfo->issuerDN, this_dllname);
+ }
+ } else {
+ rv = LDAPU_ERR_MISSING_INIT_FN_NAME;
+ }
+ } else if (lib) {
+ /* If library is specified, init function must be specified */
+ /* If init fn is specified, library may not be specified */
+ rv = LDAPU_ERR_MISSING_INIT_FN_IN_CONFIG;
+ } else if (rv == LDAPU_FAILED){
+ rv = LDAPU_SUCCESS;
+ }
+
+ if (fname) free(fname);
- if (rv != LDAPU_SUCCESS) return rv;
+ if (rv != LDAPU_SUCCESS) return rv;
}
return rv;
10 years, 1 month
ldap/servers lib/ldaputil
by Mark Reynolds
ldap/servers/plugins/acl/acleffectiverights.c | 1
ldap/servers/plugins/replication/urp.c | 1
ldap/servers/slapd/saslbind.c | 1
lib/ldaputil/certmap.c | 152 ++++++++++++--------------
4 files changed, 77 insertions(+), 78 deletions(-)
New commits:
commit b9901f14706138cc0e4a53ee96bbbb26c74ce069
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Thu Mar 13 14:07:49 2014 -0400
Ticket 47740 - Fix coverity issues - Part 5
12494 - resource leak - /ldap/servers/slapd/saslbind.c
12487 - resource leak - /ldap/servers/plugins/replication/urp.c
12486 - resource leak - /ldap/servers/plugins/acl/acleffectiverights.c
12480 - resource leak - lib/ldaputil/certmap.c
12478 - resource leak - lib/ldaputil/certmap.c
12477 - resource leak - lib/ldaputil/certmap.c
https://fedorahosted.org/389/ticket/47740
Reviewed by: rmeggins(Thanks!)
diff --git a/ldap/servers/plugins/acl/acleffectiverights.c b/ldap/servers/plugins/acl/acleffectiverights.c
index e4537af..dc22451 100644
--- a/ldap/servers/plugins/acl/acleffectiverights.c
+++ b/ldap/servers/plugins/acl/acleffectiverights.c
@@ -132,6 +132,7 @@ _ger_g_permission_granted (
}
else
{
+ slapi_ch_free_string(&proxydn); /* this could still have been set - free it */
requestor_sdn = &(pb->pb_op->o_sdn);
}
if ( slapi_sdn_get_dn (requestor_sdn) == NULL )
diff --git a/ldap/servers/plugins/replication/urp.c b/ldap/servers/plugins/replication/urp.c
index 471bf8d..b6fe2ff 100644
--- a/ldap/servers/plugins/replication/urp.c
+++ b/ldap/servers/plugins/replication/urp.c
@@ -1280,6 +1280,7 @@ get_dn_plus_uniqueid(char *sessionid, const Slapi_DN *oldsdn, const char *unique
* parentdn is normalized by slapi_sdn_get_dn.
*/
newdn = slapi_ch_smprintf("%s,%s", slapi_rdn_get_rdn(rdn), parentdn);
+ slapi_ch_free_string(&parentdn);
}
slapi_rdn_free(&rdn);
return newdn;
diff --git a/ldap/servers/slapd/saslbind.c b/ldap/servers/slapd/saslbind.c
index ba606eb..6f53aea 100644
--- a/ldap/servers/slapd/saslbind.c
+++ b/ldap/servers/slapd/saslbind.c
@@ -522,6 +522,7 @@ static int ids_sasl_getpluginpath(sasl_conn_t *conn, const char **path)
*/
char *pluginpath = config_get_saslpath();
if ((!pluginpath) || (*pluginpath == '\0')) {
+ slapi_ch_free_string(&pluginpath);
pluginpath = ldaputil_get_saslpath();
}
*path = pluginpath;
diff --git a/lib/ldaputil/certmap.c b/lib/ldaputil/certmap.c
index e27633c..aa5bafa 100644
--- a/lib/ldaputil/certmap.c
+++ b/lib/ldaputil/certmap.c
@@ -500,13 +500,13 @@ static int process_certinfo (LDAPUCertMapInfo_t *certinfo)
char *searchAttr = 0;
if (!ldapu_strcasecmp(certinfo->issuerName, "default")) {
- default_certmap_info = certinfo;
+ default_certmap_info = certinfo;
}
else if (!certinfo->issuerDN) {
- return LDAPU_ERR_NO_ISSUERDN_IN_CONFIG_FILE;
+ return LDAPU_ERR_NO_ISSUERDN_IN_CONFIG_FILE;
}
else {
- rv = ldapu_list_add_info(certmap_listinfo, certinfo);
+ rv = ldapu_list_add_info(certmap_listinfo, certinfo);
}
if (rv != LDAPU_SUCCESS) return rv;
@@ -515,21 +515,21 @@ static int process_certinfo (LDAPUCertMapInfo_t *certinfo)
rv = ldapu_certmap_info_attrval (certinfo, LDAPU_ATTR_DNCOMPS, &dncomps);
if (rv == LDAPU_SUCCESS && dncomps) {
- certinfo->dncompsState = COMPS_HAS_ATTRS;
- tolower_string(dncomps);
+ certinfo->dncompsState = COMPS_HAS_ATTRS;
+ tolower_string(dncomps);
}
else if (rv == LDAPU_FAILED) {
- certinfo->dncompsState = COMPS_COMMENTED_OUT;
- rv = LDAPU_SUCCESS;
+ certinfo->dncompsState = COMPS_COMMENTED_OUT;
+ rv = LDAPU_SUCCESS;
}
else if (rv == LDAPU_SUCCESS && !dncomps) {
- certinfo->dncompsState = COMPS_EMPTY;
- dncomps = ""; /* present but empty */
+ certinfo->dncompsState = COMPS_EMPTY;
+ dncomps = ""; /* present but empty */
}
rv = parse_into_bitmask (dncomps, &certinfo->dncomps, -1);
- if (dncomps && *dncomps) free(dncomps);
+ free(dncomps); dncomps = NULL;
if (rv != LDAPU_SUCCESS) return rv;
@@ -538,21 +538,21 @@ static int process_certinfo (LDAPUCertMapInfo_t *certinfo)
&filtercomps);
if (rv == LDAPU_SUCCESS && filtercomps) {
- certinfo->filtercompsState = COMPS_HAS_ATTRS;
- tolower_string(filtercomps);
+ certinfo->filtercompsState = COMPS_HAS_ATTRS;
+ tolower_string(filtercomps);
}
else if (rv == LDAPU_FAILED) {
- certinfo->filtercompsState = COMPS_COMMENTED_OUT;
- rv = LDAPU_SUCCESS;
+ certinfo->filtercompsState = COMPS_COMMENTED_OUT;
+ rv = LDAPU_SUCCESS;
}
else if (rv == LDAPU_SUCCESS && !filtercomps) {
- certinfo->filtercompsState = COMPS_EMPTY;
- filtercomps = ""; /* present but empty */
+ certinfo->filtercompsState = COMPS_EMPTY;
+ filtercomps = ""; /* present but empty */
}
rv = parse_into_bitmask (filtercomps, &certinfo->filtercomps, 0);
- if (filtercomps && *filtercomps) free(filtercomps);
+ if (filtercomps) free(filtercomps);
if (rv != LDAPU_SUCCESS) return rv;
@@ -560,15 +560,15 @@ static int process_certinfo (LDAPUCertMapInfo_t *certinfo)
rv = ldapu_certmap_info_attrval(certinfo, LDAPU_ATTR_CERTMAP_LDAP_ATTR,
&searchAttr);
- if (rv == LDAPU_FAILED || !searchAttr || !*searchAttr)
- rv = LDAPU_SUCCESS;
- else {
- certinfo->searchAttr = searchAttr ? strdup(searchAttr) : 0;
+ if (rv == LDAPU_FAILED || !searchAttr){
+ rv = LDAPU_SUCCESS;
+ } else {
+ certinfo->searchAttr = searchAttr;
- if (searchAttr && !certinfo->searchAttr)
- rv = LDAPU_ERR_OUT_OF_MEMORY;
- else
- rv = LDAPU_SUCCESS;
+ if (searchAttr && !certinfo->searchAttr)
+ rv = LDAPU_ERR_OUT_OF_MEMORY;
+ else
+ rv = LDAPU_SUCCESS;
}
if (rv != LDAPU_SUCCESS) return rv;
@@ -578,73 +578,69 @@ static int process_certinfo (LDAPUCertMapInfo_t *certinfo)
rv = ldapu_certmap_info_attrval(certinfo, LDAPU_ATTR_VERIFYCERT, &verify);
if (rv == LDAPU_SUCCESS) {
- if (!ldapu_strcasecmp(verify, "on"))
- certinfo->verifyCert = 1;
- else if (!ldapu_strcasecmp(verify, "off"))
- certinfo->verifyCert = 0;
- else if (!verify || !*verify) /* for mail/news backward compatibilty */
- certinfo->verifyCert = 1; /* otherwise, this should be an error */
- else
- rv = LDAPU_ERR_MISSING_VERIFYCERT_VAL;
+ if (!ldapu_strcasecmp(verify, "on"))
+ certinfo->verifyCert = 1;
+ else if (!ldapu_strcasecmp(verify, "off"))
+ certinfo->verifyCert = 0;
+ else if (!verify || !*verify) /* for mail/news backward compatibilty */
+ certinfo->verifyCert = 1; /* otherwise, this should be an error */
+ else
+ rv = LDAPU_ERR_MISSING_VERIFYCERT_VAL;
}
else if (rv == LDAPU_FAILED) rv = LDAPU_SUCCESS;
- if (verify && *verify) free(verify);
+ if (verify) free(verify);
if (rv != LDAPU_SUCCESS) return rv;
{
- PRLibrary *lib = 0;
+ PRLibrary *lib = 0;
- /* look for the library property and load it */
- rv = ldapu_certmap_info_attrval(certinfo, LDAPU_ATTR_LIBRARY, &libname);
+ /* look for the library property and load it */
+ rv = ldapu_certmap_info_attrval(certinfo, LDAPU_ATTR_LIBRARY, &libname);
- if (rv == LDAPU_SUCCESS) {
- if (libname && *libname) {
- lib = PR_LoadLibrary(libname);
- if (!lib) rv = LDAPU_ERR_UNABLE_TO_LOAD_PLUGIN;
- }
- else {
- rv = LDAPU_ERR_MISSING_LIBNAME;
- }
- }
- else if (rv == LDAPU_FAILED) rv = LDAPU_SUCCESS;
+ if (rv == LDAPU_SUCCESS) {
+ if (libname && *libname) {
+ lib = PR_LoadLibrary(libname);
+ if (!lib) rv = LDAPU_ERR_UNABLE_TO_LOAD_PLUGIN;
+ } else {
+ rv = LDAPU_ERR_MISSING_LIBNAME;
+ }
+ } else if (rv == LDAPU_FAILED) rv = LDAPU_SUCCESS;
- if (libname) free(libname);
- if (rv != LDAPU_SUCCESS) return rv;
+ if (libname) free(libname);
+ if (rv != LDAPU_SUCCESS) return rv;
- /* look for the InitFn property, find it in the libray and call it */
- rv = ldapu_certmap_info_attrval(certinfo, LDAPU_ATTR_INITFN, &fname);
+ /* look for the InitFn property, find it in the libray and call it */
+ rv = ldapu_certmap_info_attrval(certinfo, LDAPU_ATTR_INITFN, &fname);
- if (rv == LDAPU_SUCCESS) {
- if (fname && *fname) {
- /* If lib is NULL, PR_FindSymbol will search all libs loaded
- * through PR_LoadLibrary.
- */
- CertMapInitFn_t fn = (CertMapInitFn_t)PR_FindSymbol(lib, fname);
+ if (rv == LDAPU_SUCCESS) {
+ if (fname && *fname) {
+ /* If lib is NULL, PR_FindSymbol will search all libs loaded
+ * through PR_LoadLibrary.
+ */
+ CertMapInitFn_t fn = (CertMapInitFn_t)PR_FindSymbol(lib, fname);
- if (!fn) {
- rv = LDAPU_ERR_MISSING_INIT_FN_IN_LIB;
- }
- else {
- rv = (*fn)(certinfo, certinfo->issuerName,
- certinfo->issuerDN, this_dllname);
- }
- }
- else {
- rv = LDAPU_ERR_MISSING_INIT_FN_NAME;
- }
- }
- else if (lib) {
- /* If library is specified, init function must be specified */
- /* If init fn is specified, library may not be specified */
- rv = LDAPU_ERR_MISSING_INIT_FN_IN_CONFIG;
- }
- else if (rv == LDAPU_FAILED) rv = LDAPU_SUCCESS;
-
- if (fname) free(fname);
+ if (!fn) {
+ rv = LDAPU_ERR_MISSING_INIT_FN_IN_LIB;
+ } else {
+ rv = (*fn)(certinfo, certinfo->issuerName,
+ certinfo->issuerDN, this_dllname);
+ }
+ } else {
+ rv = LDAPU_ERR_MISSING_INIT_FN_NAME;
+ }
+ } else if (lib) {
+ /* If library is specified, init function must be specified */
+ /* If init fn is specified, library may not be specified */
+ rv = LDAPU_ERR_MISSING_INIT_FN_IN_CONFIG;
+ } else if (rv == LDAPU_FAILED){
+ rv = LDAPU_SUCCESS;
+ }
+
+ if (fname) free(fname);
- if (rv != LDAPU_SUCCESS) return rv;
+ if (rv != LDAPU_SUCCESS) return rv;
}
return rv;
10 years, 1 month
Branch '389-ds-base-1.2.11' - ldap/servers
by Mark Reynolds
ldap/servers/plugins/acl/aclplugin.c | 8 ++-----
ldap/servers/plugins/chainingdb/cb_controls.c | 14 +++++++-----
ldap/servers/plugins/chainingdb/cb_instance.c | 18 ++++++++--------
ldap/servers/plugins/replication/repl5_replica.c | 3 +-
ldap/servers/plugins/replication/repl5_replica_config.c | 13 ++++++++---
ldap/servers/slapd/back-ldbm/upgrade.c | 3 ++
ldap/servers/slapd/main.c | 5 ++--
ldap/servers/slapd/proxyauth.c | 12 +++++-----
8 files changed, 43 insertions(+), 33 deletions(-)
New commits:
commit 85d062b3468663691188d22f58edb2a448e5e447
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Wed Mar 12 16:58:32 2014 -0400
Ticket 47740 - Fix coverity erorrs - Part 4
12498 - resource leak - /ldap/servers/plugins/chainingdn/cb_instance.c
12490 - resource leak - /ldap/servers/plugins/chainingdn/cb_controls.c
12489 - resource leak - /ldap/servers/plugins/replication/repl5_replica_config.c
12488 - resource leak - /ldap/servers/slapd/main.c
12485 - resource leak - /ldap/servers/plugins/replication/repl5_replica_config.c
12484 - resource leak - /ldap/servers/plugins/replication/repl5_replica_config.c
12483 - resource leak - /ldap/servers/slapd/back-ldbm/upgrade.c
12482 - resource leak - /ldap/servers/plugins/replication/repl5_replica.c
12481 - resource leak - /ldap/servers/plugins/acl/aclplugin.c
12476 - resource leak - /ldap/servers/slapd/back-ldbm/upgrade.c
12475 - resource leak - /ldap/servers/slapd/back-ldbm/upgrade.c
https://fedorahosted.org/389/ticket/47740
Reviewed by: nhosoi(Thanks!)
diff --git a/ldap/servers/plugins/acl/aclplugin.c b/ldap/servers/plugins/acl/aclplugin.c
index 0d35425..5250e0d 100644
--- a/ldap/servers/plugins/acl/aclplugin.c
+++ b/ldap/servers/plugins/acl/aclplugin.c
@@ -197,7 +197,7 @@ aclplugin_preop_modify ( Slapi_PBlock *pb )
int
aclplugin_preop_common( Slapi_PBlock *pb )
{
- char *proxy_dn; /* id being assumed */
+ char *proxy_dn = NULL; /* id being assumed */
char *dn; /* proxy master */
char *errtext = NULL;
int lderr;
@@ -221,9 +221,7 @@ aclplugin_preop_common( Slapi_PBlock *pb )
* The proxy_dn is the id being assumed, while dn
* is the "proxy master".
*/
- proxy_dn = NULL;
- if ( LDAP_SUCCESS != ( lderr = proxyauth_get_dn( pb, &proxy_dn,
- &errtext ))) {
+ if ( LDAP_SUCCESS != ( lderr = proxyauth_get_dn( pb, &proxy_dn, &errtext ))) {
/*
* Fatal error -- send a result to the client and arrange to skip
* any further processing.
@@ -231,7 +229,7 @@ aclplugin_preop_common( Slapi_PBlock *pb )
slapi_send_ldap_result( pb, lderr, NULL, errtext, 0, NULL );
TNF_PROBE_1_DEBUG(aclplugin_preop_common_end ,"ACL","",
tnf_string,proxid_error,"");
-
+ slapi_ch_free_string(&proxy_dn);
return 1; /* skip any further processing */
}
slapi_pblock_get ( pb, SLAPI_REQUESTOR_DN, &dn );
diff --git a/ldap/servers/plugins/chainingdb/cb_controls.c b/ldap/servers/plugins/chainingdb/cb_controls.c
index 2a698a0..e1fc9c3 100644
--- a/ldap/servers/plugins/chainingdb/cb_controls.c
+++ b/ldap/servers/plugins/chainingdb/cb_controls.c
@@ -200,20 +200,22 @@ int cb_update_controls( Slapi_PBlock * pb,
char * requestor,*rootdn;
char * requestorCopy=NULL;
- rootdn=cb_get_rootdn();
+ rootdn = cb_get_rootdn();
slapi_pblock_get( pb, SLAPI_REQUESTOR_NDN, &requestor );
requestorCopy = slapi_ch_strdup(requestor);
slapi_dn_ignore_case(requestorCopy);
if (!strcmp( requestorCopy, rootdn )) { /* UTF8- aware */
slapi_log_error( SLAPI_LOG_PLUGIN,CB_PLUGIN_SUBSYSTEM,
- "Use of user <%s> incompatible with proxied auth. control\n",rootdn);
- rc=LDAP_UNAVAILABLE_CRITICAL_EXTENSION;
- slapi_ch_free((void **)&requestorCopy);
+ "Use of user <%s> incompatible with proxied auth. control\n",
+ rootdn);
+ rc = LDAP_UNAVAILABLE_CRITICAL_EXTENSION;
+ slapi_ch_free_string(&rootdn);
+ slapi_ch_free_string(&requestorCopy);
break;
}
- slapi_ch_free((void **)&rootdn);
- slapi_ch_free((void **)&requestorCopy);
+ slapi_ch_free_string(&rootdn);
+ slapi_ch_free_string(&requestorCopy);
}
addauth=0;
diff --git a/ldap/servers/plugins/chainingdb/cb_instance.c b/ldap/servers/plugins/chainingdb/cb_instance.c
index ce7675b..86bb635 100644
--- a/ldap/servers/plugins/chainingdb/cb_instance.c
+++ b/ldap/servers/plugins/chainingdb/cb_instance.c
@@ -738,11 +738,11 @@ static int cb_instance_hosturl_set(void *arg, void *value, char *errorbuf, int p
if ((LDAP_SUCCESS == rc) && apply) {
- slapi_rwlock_wrlock(inst->rwl_config_lock);
-
- if (( phase != CB_CONFIG_PHASE_INITIALIZATION ) &&
- ( phase != CB_CONFIG_PHASE_STARTUP )) {
+ slapi_rwlock_wrlock(inst->rwl_config_lock);
+ if (( phase != CB_CONFIG_PHASE_INITIALIZATION ) &&
+ ( phase != CB_CONFIG_PHASE_STARTUP ))
+ {
/* Dynamic modification */
/* Don't free char * pointer now */
/* STore them in a waste basket */
@@ -766,17 +766,17 @@ static int cb_instance_hosturl_set(void *arg, void *value, char *errorbuf, int p
/* the url and update the configuration */
if ((ludp->lud_host==NULL) || (strlen(ludp->lud_host)==0)) {
- inst->pool->hostname=(char *)slapi_ch_strdup((char *)get_localhost_DNS());
+ inst->pool->hostname = get_localhost_DNS();
} else {
- inst->pool->hostname = slapi_ch_strdup( ludp->lud_host );
+ inst->pool->hostname = slapi_ch_strdup( ludp->lud_host );
}
- inst->pool->url = slapi_ch_strdup( url);
- inst->pool->secure = secure;
+ inst->pool->url = slapi_ch_strdup( url);
+ inst->pool->secure = secure;
if ((ludp->lud_port==0) && inst->pool->secure)
inst->pool->port=CB_LDAP_SECURE_PORT;
else
- inst->pool->port = ludp->lud_port;
+ inst->pool->port = ludp->lud_port;
/* Build a charray of <host>:<port> */
/* hostname is of the form <host>[:port] <host>[:port] */
diff --git a/ldap/servers/plugins/replication/repl5_replica.c b/ldap/servers/plugins/replication/repl5_replica.c
index 8187be9..82c30c1 100644
--- a/ldap/servers/plugins/replication/repl5_replica.c
+++ b/ldap/servers/plugins/replication/repl5_replica.c
@@ -2232,6 +2232,7 @@ _replica_configure_ruv (Replica *r, PRBool isLocked)
"failed to recreate replica ruv tombstone entry"
" (%s); LDAP error - %d\n",
slapi_sdn_get_dn(r->repl_root), rc);
+ slapi_ch_free_string(&generation);
goto done;
}
}
@@ -2239,7 +2240,7 @@ _replica_configure_ruv (Replica *r, PRBool isLocked)
#undef RUV_UPDATE_FULL
}
- slapi_ch_free((void **)&generation);
+ slapi_ch_free_string(&generation);
return_value = 0;
}
else
diff --git a/ldap/servers/plugins/replication/repl5_replica_config.c b/ldap/servers/plugins/replication/repl5_replica_config.c
index d020ffb..1390ab4 100644
--- a/ldap/servers/plugins/replication/repl5_replica_config.c
+++ b/ldap/servers/plugins/replication/repl5_replica_config.c
@@ -1022,8 +1022,6 @@ static int replica_execute_cl2ldif_task (Object *r, char *returntext)
}
PR_snprintf (fName, MAXPATHLEN, "%s/%s.ldif", clDir, replica_get_name (replica));
- slapi_ch_free_string (&clDir);
-
slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name,
"Beginning changelog export of replica \"%s\"\n",
replica_get_name(replica));
@@ -1042,6 +1040,8 @@ static int replica_execute_cl2ldif_task (Object *r, char *returntext)
rc = LDAP_OPERATIONS_ERROR;
}
bail:
+ slapi_ch_free_string (&clDir);
+
return rc;
}
@@ -1097,7 +1097,6 @@ static int replica_execute_ldif2cl_task (Object *r, char *returntext)
"Beginning changelog import of replica \"%s\"\n",
replica_get_name(replica));
imprc = cl5ImportLDIF (clDir, fName, rlist);
- slapi_ch_free_string (&clDir);
if (CL5_SUCCESS == imprc)
{
slapi_log_error(SLAPI_LOG_FATAL, repl_plugin_name,
@@ -1127,8 +1126,11 @@ static int replica_execute_ldif2cl_task (Object *r, char *returntext)
config.dir?config.dir:"null config dir");
rc = LDAP_OPERATIONS_ERROR;
}
+
bail:
+ slapi_ch_free_string(&clDir);
changelog5_config_done(&config);
+
/* if cl5ImportLDIF returned an error, report it first. */
return imprc?imprc:rc;
}
@@ -2095,9 +2097,12 @@ replica_send_cleanruv_task(Repl_Agmt *agmt, cleanruv_data *clean_data)
rc = ldap_modify_ext_s( ld, repl_dn, mods, NULL, NULL);
if(rc != LDAP_SUCCESS){
+ char *hostname = agmt_get_hostname(agmt);
+
cleanruv_log(clean_data->task, CLEANALLRUV_ID, "Failed to add CLEANRUV task (%s) to replica "
"(%s). You will need to manually run the CLEANRUV task on this replica (%s) error (%d)",
- repl_dn, agmt_get_long_name(agmt), agmt_get_hostname(agmt), rc);
+ repl_dn, agmt_get_long_name(agmt), hostname, rc);
+ slapi_ch_free_string(&hostname);
}
slapi_ch_free_string(&repl_dn);
slapi_sdn_free(&sdn);
diff --git a/ldap/servers/slapd/back-ldbm/upgrade.c b/ldap/servers/slapd/back-ldbm/upgrade.c
index a10ee9b..16d784e 100644
--- a/ldap/servers/slapd/back-ldbm/upgrade.c
+++ b/ldap/servers/slapd/back-ldbm/upgrade.c
@@ -168,6 +168,7 @@ check_db_version( struct ldbminfo *li, int *action )
*action = 0;
dbversion_read(li, li->li_directory, &ldbmversion, &dataversion);
if (NULL == ldbmversion || '\0' == *ldbmversion) {
+ slapi_ch_free_string(&ldbmversion);
slapi_ch_free_string(&dataversion);
return 0;
}
@@ -251,6 +252,8 @@ check_db_inst_version( ldbm_instance *inst )
dbversion_read(inst->inst_li, inst_dirp, &ldbmversion, &dataversion);
if (NULL == ldbmversion || '\0' == *ldbmversion) {
+ slapi_ch_free_string(&ldbmversion);
+ slapi_ch_free_string(&dataversion);
return rval;
}
diff --git a/ldap/servers/slapd/main.c b/ldap/servers/slapd/main.c
index 53cb5c8..737da5d 100644
--- a/ldap/servers/slapd/main.c
+++ b/ldap/servers/slapd/main.c
@@ -2916,7 +2916,7 @@ slapd_debug_level_string2level( const char *s )
char *cur, *next, *scopy;
level = 0;
- cur = scopy = slapi_ch_strdup( s );
+ scopy = slapi_ch_strdup( s );
for ( cur = scopy; cur != NULL; cur = next ) {
if (( next = strchr( cur, '+' )) != NULL ) {
@@ -2936,12 +2936,13 @@ slapd_debug_level_string2level( const char *s )
if ( NULL == slapd_debug_level_map[i].dle_string ) {
fprintf( stderr, "Unrecognized debug level \"%s\"\n", cur );
+ slapi_ch_free_string(&scopy);
return -1;
}
}
}
- slapi_ch_free( (void **)&scopy );
+ slapi_ch_free_string(&scopy);
return level;
}
diff --git a/ldap/servers/slapd/proxyauth.c b/ldap/servers/slapd/proxyauth.c
index 562ac93..17b6a05 100644
--- a/ldap/servers/slapd/proxyauth.c
+++ b/ldap/servers/slapd/proxyauth.c
@@ -181,11 +181,11 @@ parse_LDAPProxyAuth(struct berval *spec_ber, int version, char **errtextp,
int
proxyauth_get_dn( Slapi_PBlock *pb, char **proxydnp, char **errtextp )
{
- char *dn = 0;
- LDAPProxyAuth *spec = 0;
- int rv, lderr = LDAP_SUCCESS; /* optimistic */
+ char *dn = 0;
+ LDAPProxyAuth *spec = 0;
+ int rv, lderr = LDAP_SUCCESS; /* optimistic */
- BEGIN
+ BEGIN
struct berval *spec_ber;
LDAPControl **controls;
int present;
@@ -233,12 +233,12 @@ proxyauth_get_dn( Slapi_PBlock *pb, char **proxydnp, char **errtextp )
}
END
- if (spec) delete_LDAPProxyAuth(spec);
+ if (spec) delete_LDAPProxyAuth(spec);
if ( NULL != proxydnp ) {
*proxydnp = dn;
} else {
- slapi_ch_free( (void **)&dn );
+ slapi_ch_free_string(&dn);
}
return lderr;
10 years, 1 month