directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r1496650 - in /directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators: AddRequestDecorator.java ModifyRequestDecorator.java
Date Tue, 25 Jun 2013 21:57:20 GMT
Author: elecharny
Date: Tue Jun 25 21:57:20 2013
New Revision: 1496650

URL: http://svn.apache.org/r1496650
Log:
Fixed a wrong encoding of an AddRequest when we try to add an Attribute with some null value

Modified:
    directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/AddRequestDecorator.java
    directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/ModifyRequestDecorator.java

Modified: directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/AddRequestDecorator.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/AddRequestDecorator.java?rev=1496650&r1=1496649&r2=1496650&view=diff
==============================================================================
--- directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/AddRequestDecorator.java
(original)
+++ directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/AddRequestDecorator.java
Tue Jun 25 21:57:20 2013
@@ -392,12 +392,25 @@ public final class AddRequestDecorator e
 
                     for ( Value<?> value : attribute )
                     {
-                        int valueLength = value.getBytes().length;
-                        localValuesLength += 1 + TLV.getNbBytes( valueLength ) + valueLength;
+                        if ( value.getBytes() == null )
+                        {
+                            localValuesLength += 1 + 1;
+                        }
+                        else
+                        {
+                            int valueLength = value.getBytes().length;
+                            localValuesLength += 1 + TLV.getNbBytes( valueLength ) + valueLength;
+                        }
                     }
 
                     localAttributeLength += 1 + TLV.getNbBytes( localValuesLength ) + localValuesLength;
                 }
+                else
+                {
+                    // No value : we still have to store the encapsulating Sequence
+                    localValuesLength = 1 + 1;
+                    localAttributeLength += 1 + 1 + localValuesLength;
+                }
 
                 // add the attribute length to the attributes length
                 entryLength += 1 + TLV.getNbBytes( localAttributeLength ) + localAttributeLength;
@@ -488,6 +501,10 @@ public final class AddRequestDecorator e
                             BerValue.encode( buffer, value.getBytes() );
                         }
                     }
+                    else
+                    {
+                        BerValue.encode( buffer, Strings.EMPTY_BYTES );
+                    }
 
                     // Go to the next attribute number;
                     attributeNumber++;

Modified: directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/ModifyRequestDecorator.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/ModifyRequestDecorator.java?rev=1496650&r1=1496649&r2=1496650&view=diff
==============================================================================
--- directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/ModifyRequestDecorator.java
(original)
+++ directory/shared/trunk/ldap/codec/core/src/main/java/org/apache/directory/api/ldap/codec/decorators/ModifyRequestDecorator.java
Tue Jun 25 21:57:20 2013
@@ -38,6 +38,7 @@ import org.apache.directory.api.ldap.mod
 import org.apache.directory.api.ldap.model.entry.DefaultModification;
 import org.apache.directory.api.ldap.model.entry.Modification;
 import org.apache.directory.api.ldap.model.entry.ModificationOperation;
+import org.apache.directory.api.ldap.model.entry.Value;
 import org.apache.directory.api.ldap.model.exception.LdapException;
 import org.apache.directory.api.ldap.model.message.Control;
 import org.apache.directory.api.ldap.model.message.ModifyRequest;
@@ -520,7 +521,7 @@ public class ModifyRequestDecorator exte
                 // Get all the values
                 if ( modification.getAttribute().size() != 0 )
                 {
-                    for ( org.apache.directory.api.ldap.model.entry.Value<?> value
: modification.getAttribute() )
+                    for ( Value<?> value : modification.getAttribute() )
                     {
                         localValuesLength += 1 + TLV.getNbBytes( value.getBytes().length
) + value.getBytes().length;
                     }



Mime
View raw message