From a37956520f3678c3975979570eb3c163da584e5f Mon Sep 17 00:00:00 2001 From: Ludwig Krispenz Date: Jan 16 2015 10:40:52 +0000 Subject: Ticket 47964 - v2 - Incorrect search result after replacing an empty attribute Bug Description: when a replace operation for a nonexisting attribute is done without providing new values the entry is stored with incorrect meta data: an empty deleted value without attribute deletion csn. Fix Description: in the delete phase of the replace operation already create the attribute to set the deletion csn. It would be created anyway in the add part of the replace operation. The function to calculate the required size to write the entry needs also to be adjusted. https://fedorahosted.org/389/ticket/47964 Reviewed by: Rich, thanks --- diff --git a/ldap/servers/slapd/entry.c b/ldap/servers/slapd/entry.c index 0679eb7..70c7f13 100644 --- a/ldap/servers/slapd/entry.c +++ b/ldap/servers/slapd/entry.c @@ -1536,6 +1536,8 @@ entry2str_internal_size_attrlist( const Slapi_Attr *attrlist, int entry2str_ctrl * We need to add the size for that. */ elen += 1 + LDIF_CSNPREFIX_MAXLENGTH + CSN_STRSIZE; + /* need also space for ";deletedattribute;deleted" */ + elen += DELETED_ATTR_STRSIZE + DELETED_VALUE_STRSIZE; } } } diff --git a/ldap/servers/slapd/entrywsi.c b/ldap/servers/slapd/entrywsi.c index c8055d8..be83580 100644 --- a/ldap/servers/slapd/entrywsi.c +++ b/ldap/servers/slapd/entrywsi.c @@ -680,9 +680,13 @@ entry_delete_present_values_wsi(Slapi_Entry *e, const char *type, struct berval } retVal = LDAP_NO_SUCH_ATTRIBUTE; } - if ((LDAP_MOD_REPLACE == mod_op) && replacevals && replacevals[0]) + if ((LDAP_MOD_REPLACE == mod_op)) { - /* Create a new attribute and set the adcsn */ + /* Create a new attribute and set the adcsn + * We need to do this always to set the deletion csn + * The attribute would otherwise be created in the + * entry_add_.. function + */ Slapi_Attr *a = slapi_attr_new(); slapi_attr_init(a, type); attr_set_deletion_csn(a,csn);