ldap/servers/slapd/attrlist.c | 1 +
ldap/servers/slapd/result.c | 9 +++++++--
2 files changed, 8 insertions(+), 2 deletions(-)
New commits:
commit 072b7bef4f301aed7c81cef5a6de47ffa40418b0
Author: Endi S. Dewata <edewata(a)redhat.com>
Date: Tue Nov 2 13:50:42 2010 -0400
Bug 643979 - Strange byte sequence for attribute with no values (nsslapd-referral)
https://bugzilla.redhat.com/show_bug.cgi?id=643979
There are two problems being fixed:
1. The cn=config is not supposed to store empty attribute. The
attrlist_merge_valuearray() has been modified not to create
a new attribute if the value provided is NULL.
2. If an attribute doesn't have any value, it should not be sent
to the client. The encode_attr_2() has been modified to check
whether the attribute has any values before starting to do
BER-encoding.
diff --git a/ldap/servers/slapd/attrlist.c b/ldap/servers/slapd/attrlist.c
index 9c32990..cdf9e6b 100644
--- a/ldap/servers/slapd/attrlist.c
+++ b/ldap/servers/slapd/attrlist.c
@@ -110,6 +110,7 @@ void
attrlist_merge_valuearray(Slapi_Attr **alist, const char *type, Slapi_Value **vals)
{
Slapi_Attr **a= NULL;
+ if (!vals) return;
attrlist_find_or_create(alist, type, &a);
valueset_add_valuearray( &(*a)->a_present_values, vals );
}
diff --git a/ldap/servers/slapd/result.c b/ldap/servers/slapd/result.c
index 218b7b9..16d964c 100644
--- a/ldap/servers/slapd/result.c
+++ b/ldap/servers/slapd/result.c
@@ -723,6 +723,13 @@ encode_attr_2(
{
char *attrs[2] = { NULL, NULL };
+ Slapi_Value *v;
+ int i = slapi_valueset_first_value(vs,&v);
+
+ if (i==-1)
+ {
+ return( 0 );
+ }
attrs[0] = (char*)attribute_type;
@@ -743,8 +750,6 @@ encode_attr_2(
if ( ! attrsonly )
{
- Slapi_Value *v;
- int i= slapi_valueset_first_value(vs,&v);
while(i!=-1)
{
if ( ber_printf( ber, "o", v->bv.bv_val,v->bv.bv_len ) == -1 )