Browse Source

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.
Endi S. Dewata 15 years ago
parent
commit
072b7bef4f
2 changed files with 8 additions and 2 deletions
  1. 1 0
      ldap/servers/slapd/attrlist.c
  2. 7 2
      ldap/servers/slapd/result.c

+ 1 - 0
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 );
 }    

+ 7 - 2
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 )