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;
}