amoralej / rpms / 389-ds-base

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

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

cc3dff
From a0489deaa9b3f72dca120f3b1622039f92a3e437 Mon Sep 17 00:00:00 2001
cc3dff
From: Noriko Hosoi <nhosoi@redhat.com>
cc3dff
Date: Thu, 13 Mar 2014 13:06:43 -0700
cc3dff
Subject: [PATCH] Ticket #47735 - e_uniqueid fails to set if an entry is a
cc3dff
 conflict entry
cc3dff
cc3dff
Description: In commit e2b8468f459647261812f542485f3481d39bd26c,
cc3dff
to get the base type length when a state info is stripped from
cc3dff
the attribute type, the fix in str2entry_state_information_from_type
cc3dff
blindly returned the base type length for the ordinary sub-typed
cc3dff
attributes.  This patch fixes it so that only when the state info
cc3dff
is removed, the length is reset.
cc3dff
cc3dff
https://fedorahosted.org/389/ticket/47735
cc3dff
cc3dff
Reviewed by rmeggins@redhat.com (Thank you, Rich!!)
cc3dff
(cherry picked from commit a7ac181d60b1f2ecd3640d0b610eba300b7c3cdb)
cc3dff
(cherry picked from commit 4ffa8247ab9dcc45137f07511d62ea33c24f76df)
cc3dff
(cherry picked from commit 093a146853e6bb44b08c36a1da22735633adbd4a)
cc3dff
(cherry picked from commit 2bb0f1b2b9b1c69118d8c8db1c5426eb7d7690ea)
cc3dff
---
cc3dff
 ldap/servers/slapd/entry.c | 16 +++++++++++++---
cc3dff
 1 file changed, 13 insertions(+), 3 deletions(-)
cc3dff
cc3dff
diff --git a/ldap/servers/slapd/entry.c b/ldap/servers/slapd/entry.c
cc3dff
index 0d018a9..5306da2 100644
cc3dff
--- a/ldap/servers/slapd/entry.c
cc3dff
+++ b/ldap/servers/slapd/entry.c
cc3dff
@@ -104,13 +104,11 @@ str2entry_state_information_from_type(struct berval *atype,
cc3dff
                                       int *attr_state)
cc3dff
 {
cc3dff
 	char *p = NULL;
cc3dff
+	char *semicolonp = 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
@@ -169,19 +167,31 @@ str2entry_state_information_from_type(struct berval *atype,
cc3dff
 					csn_init_by_csn ( *maxcsn, *attributedeletioncsn );
cc3dff
 				}
cc3dff
 			}
cc3dff
+			if (NULL == semicolonp) {
cc3dff
+				semicolonp = p; /* the first semicolon */
cc3dff
+			}
cc3dff
 		}
cc3dff
 		else if(strncmp(p+1,"deletedattribute", 16)==0)
cc3dff
 		{
cc3dff
 			p[0]='\0';
cc3dff
 			*attr_state= ATTRIBUTE_DELETED;
cc3dff
+			if (NULL == semicolonp) {
cc3dff
+				semicolonp = p; /* the first semicolon */
cc3dff
+			}
cc3dff
 		}
cc3dff
 		else if(strncmp(p+1,"deleted", 7)==0)
cc3dff
 		{
cc3dff
 			p[0]='\0';
cc3dff
 			*value_state= VALUE_DELETED;
cc3dff
+			if (NULL == semicolonp) {
cc3dff
+				semicolonp = p; /* the first semicolon */
cc3dff
+			}
cc3dff
 		}
cc3dff
 		p= strchr(p+1, ';');
cc3dff
 	}
cc3dff
+	if (semicolonp) {
cc3dff
+		atype->bv_len = semicolonp - atype->bv_val;
cc3dff
+	}
cc3dff
 }
cc3dff
 
cc3dff
 /* rawdn is not consumed.  Caller needs to free it. */
cc3dff
-- 
cc3dff
1.8.1.4
cc3dff