zrhoffman / rpms / 389-ds-base

Forked from rpms/389-ds-base 3 years ago
Clone

Blame SOURCES/0094-Ticket-47735-e_uniqueid-fails-to-set-if-an-entry-is-.patch

cc3dff
From e2b8468f459647261812f542485f3481d39bd26c Mon Sep 17 00:00:00 2001
cc3dff
From: Noriko Hosoi <nhosoi@redhat.com>
cc3dff
Date: Fri, 7 Mar 2014 12:29:55 -0800
cc3dff
Subject: [PATCH] Ticket #47735 - e_uniqueid fails to set if an entry is a
cc3dff
 conflict entry
cc3dff
cc3dff
Bug Description:
cc3dff
When an entry is turned to be a conflict entry, its nsUniqueId has
cc3dff
a mdcsn info as a subtype like this:
cc3dff
 nsUniqueId;mdcsn-5319136f000200010000: c5e0d787-a58f11e3-b7f9dfd1-acc3d5e4
cc3dff
In this case, the attribute type is assigned to the berval "type"
cc3dff
as follows:
cc3dff
 type.bv_val = "nsUniqueId;mdcsn-5319136f000200010000"
cc3dff
 type.bv_len = 37
cc3dff
The subtyped stateinfo is processed in str2entry_state_information_from_type,
cc3dff
which modifies type.bv_val to "nsUniqueId", but type.bv_len remains 37.
cc3dff
str2entry_fast has this logic to set e_uniqueid, where the nsUniqueId
cc3dff
with stateinfo fails to set the value to e_uniqueid.
cc3dff
 if ( type.bv_len == 10 &&
cc3dff
      PL_strncasecmp (type.bv_val, "nsUniqueId", type.bv_len) == 0 ){
cc3dff
cc3dff
Fix Description: This patch resets the length of the type with the
cc3dff
basetype length 10 before the if expression is called for setting
cc3dff
e_uniqueid.
cc3dff
cc3dff
https://fedorahosted.org/389/ticket/47735
cc3dff
cc3dff
Reviewed by rmeggins@redhat.com (Thank you, Rich!!)
cc3dff
(cherry picked from commit 07bd2259cc45c9d5c193b15faaf0d0c60e1b723c)
cc3dff
(cherry picked from commit 6e0ffbe1bdde99cfd71a5617d89482eef4696c7f)
cc3dff
(cherry picked from commit d4350bd0724c37040a4aaf361a10918c925b7605)
cc3dff
---
cc3dff
 ldap/servers/slapd/entry.c | 60 +++++++++++++++++++++++++++-------------------
cc3dff
 1 file changed, 36 insertions(+), 24 deletions(-)
cc3dff
cc3dff
diff --git a/ldap/servers/slapd/entry.c b/ldap/servers/slapd/entry.c
cc3dff
index 60e1dfe..0d018a9 100644
cc3dff
--- a/ldap/servers/slapd/entry.c
cc3dff
+++ b/ldap/servers/slapd/entry.c
cc3dff
@@ -95,10 +95,22 @@ struct attrs_in_extension attrs_in_extension[] =
cc3dff
 /*
cc3dff
  * WARNING: s gets butchered... the base type remains.
cc3dff
  */
cc3dff
-void
cc3dff
-str2entry_state_information_from_type(char *s,CSNSet **csnset,CSN **attributedeletioncsn,CSN **maxcsn,int *value_state,int *attr_state)
cc3dff
+static void
cc3dff
+str2entry_state_information_from_type(struct berval *atype,
cc3dff
+                                      CSNSet **csnset,
cc3dff
+                                      CSN **attributedeletioncsn,
cc3dff
+                                      CSN **maxcsn,
cc3dff
+                                      int *value_state,
cc3dff
+                                      int *attr_state)
cc3dff
 {
cc3dff
-	char *p= strchr(s, ';');
cc3dff
+	char *p = NULL;
cc3dff
+	if ((NULL == atype) || (NULL == atype->bv_val)) {
cc3dff
+		return;
cc3dff
+	}
cc3dff
+	p = PL_strchr(atype->bv_val, ';');
cc3dff
+	if (p) {
cc3dff
+		atype->bv_len = p - atype->bv_val;
cc3dff
+	}
cc3dff
 	*value_state= VALUE_PRESENT;
cc3dff
 	*attr_state= ATTRIBUTE_PRESENT;
cc3dff
 	while(p!=NULL)
cc3dff
@@ -243,19 +255,20 @@ str2entry_fast( const char *rawdn, const Slapi_RDN *srdn, char *s, int flags, in
cc3dff
 		}
cc3dff
 
cc3dff
 		if ( slapi_ldif_parse_line( s, &type, &value, &freeval ) < 0 ) {
cc3dff
-			LDAPDebug( LDAP_DEBUG_TRACE,
cc3dff
-			    "<= str2entry_fast NULL (parse_line)\n", 0, 0, 0 );
cc3dff
+			LDAPDebug0Args(LDAP_DEBUG_TRACE, "<= str2entry_fast NULL (parse_line)\n");
cc3dff
 			continue;
cc3dff
 		}
cc3dff
 
cc3dff
 		/*
cc3dff
 		 * Extract the attribute and value CSNs from the attribute type.
cc3dff
-		 */		
cc3dff
+		 */
cc3dff
 		csn_free(&attributedeletioncsn); /* JCM - Do this more efficiently */
cc3dff
 		csnset_free(&valuecsnset);
cc3dff
 		value_state= VALUE_NOTFOUND;
cc3dff
 		attr_state= ATTRIBUTE_NOTFOUND;
cc3dff
-		str2entry_state_information_from_type(type.bv_val,&valuecsnset,&attributedeletioncsn,&maxcsn,&value_state,&attr_state);
cc3dff
+		str2entry_state_information_from_type(&type,
cc3dff
+		                                      &valuecsnset, &attributedeletioncsn,
cc3dff
+		                                      &maxcsn, &value_state, &attr_state);
cc3dff
 		if(!read_stateinfo)
cc3dff
 		{
cc3dff
 			/* We are not maintaining state information */
cc3dff
@@ -393,8 +406,7 @@ str2entry_fast( const char *rawdn, const Slapi_RDN *srdn, char *s, int flags, in
cc3dff
 		}
cc3dff
 
cc3dff
 		/* retrieve uniqueid */
cc3dff
-		if ( type.bv_len == SLAPI_ATTR_UNIQUEID_LENGTH && PL_strncasecmp (type.bv_val, SLAPI_ATTR_UNIQUEID, type.bv_len) == 0 ){
cc3dff
-
cc3dff
+		if ((type.bv_len == SLAPI_ATTR_UNIQUEID_LENGTH) && (PL_strcasecmp (type.bv_val, SLAPI_ATTR_UNIQUEID) == 0)) {
cc3dff
 			if (e->e_uniqueid != NULL){
cc3dff
 				LDAPDebug (LDAP_DEBUG_TRACE, 
cc3dff
 						   "str2entry_fast: entry has multiple uniqueids %s "
cc3dff
@@ -752,22 +764,21 @@ str2entry_dupcheck( const char *rawdn, char *s, int flags, int read_stateinfo )
cc3dff
     char *valuecharptr=NULL;
cc3dff
     struct berval bvvalue;
cc3dff
     int rc;
cc3dff
-	entry_attrs *ea = NULL;
cc3dff
-	int tree_attr_checking = 0;
cc3dff
-	int big_entry_attr_presence_check = 0;
cc3dff
-	int check_for_duplicate_values =
cc3dff
-			( 0 != ( flags & SLAPI_STR2ENTRY_REMOVEDUPVALS ));
cc3dff
-	Slapi_Value *value = 0;
cc3dff
-	CSN *attributedeletioncsn= NULL;
cc3dff
-	CSNSet *valuecsnset= NULL;
cc3dff
-	CSN *maxcsn= NULL;
cc3dff
-	char *normdn = NULL;
cc3dff
-	int strict = 0;
cc3dff
+    entry_attrs *ea = NULL;
cc3dff
+    int tree_attr_checking = 0;
cc3dff
+    int big_entry_attr_presence_check = 0;
cc3dff
+    int check_for_duplicate_values = ( 0 != ( flags & SLAPI_STR2ENTRY_REMOVEDUPVALS ));
cc3dff
+    Slapi_Value *value = 0;
cc3dff
+    CSN *attributedeletioncsn= NULL;
cc3dff
+    CSNSet *valuecsnset= NULL;
cc3dff
+    CSN *maxcsn= NULL;
cc3dff
+    char *normdn = NULL;
cc3dff
+    int strict = 0;
cc3dff
 
cc3dff
     /* Check if we should be performing strict validation. */
cc3dff
     strict = config_get_dn_validate_strict();
cc3dff
 
cc3dff
-	LDAPDebug( LDAP_DEBUG_TRACE, "=> str2entry_dupcheck\n", 0, 0, 0 );
cc3dff
+    LDAPDebug0Args(LDAP_DEBUG_TRACE, "=> str2entry_dupcheck\n");
cc3dff
 
cc3dff
     e = slapi_entry_alloc();
cc3dff
     slapi_entry_init(e,NULL,NULL);
cc3dff
@@ -808,7 +819,9 @@ str2entry_dupcheck( const char *rawdn, char *s, int flags, int read_stateinfo )
cc3dff
 		csnset_free(&valuecsnset);
cc3dff
 		value_state= VALUE_NOTFOUND;
cc3dff
 		attr_state= VALUE_NOTFOUND;
cc3dff
-		str2entry_state_information_from_type(type,&valuecsnset,&attributedeletioncsn,&maxcsn,&value_state,&attr_state);
cc3dff
+		str2entry_state_information_from_type(&bvtype,
cc3dff
+		                                      &valuecsnset, &attributedeletioncsn,
cc3dff
+		                                      &maxcsn, &value_state, &attr_state);
cc3dff
 		if(!read_stateinfo)
cc3dff
 		{
cc3dff
 			/* We are not maintaining state information */
cc3dff
@@ -916,8 +929,7 @@ str2entry_dupcheck( const char *rawdn, char *s, int flags, int read_stateinfo )
cc3dff
 		}
cc3dff
 
cc3dff
 		/* retrieve uniqueid */
cc3dff
-		if ( strcasecmp (type, SLAPI_ATTR_UNIQUEID) == 0 ){
cc3dff
-
cc3dff
+		if ((bvtype.bv_len == SLAPI_ATTR_UNIQUEID_LENGTH) && (PL_strcasecmp (type, SLAPI_ATTR_UNIQUEID) == 0)) {
cc3dff
 			if (e->e_uniqueid != NULL){
cc3dff
 				LDAPDebug (LDAP_DEBUG_TRACE, 
cc3dff
 						   "str2entry_dupcheck: entry has multiple uniqueids %s "
cc3dff
-- 
cc3dff
1.8.1.4
cc3dff