directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r190041 - /directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/grammars/SearchRequestGrammar.java
Date Fri, 10 Jun 2005 23:55:14 GMT
Author: elecharny
Date: Fri Jun 10 16:55:13 2005
New Revision: 190041

URL: http://svn.apache.org/viewcvs?rev=190041&view=rev
Log:
Fixed the length control of the attributes list.

Modified:
    directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/grammars/SearchRequestGrammar.java

Modified: directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/grammars/SearchRequestGrammar.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/grammars/SearchRequestGrammar.java?rev=190041&r1=190040&r2=190041&view=diff
==============================================================================
--- directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/grammars/SearchRequestGrammar.java
(original)
+++ directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/grammars/SearchRequestGrammar.java
Fri Jun 10 16:55:13 2005
@@ -723,6 +723,7 @@
         // AttributeDescriptionList ::= SEQUENCE OF AttributeDescription (Length)
         //    ...
         // We have to check the length
+        // We also have to store the expected length of the list.
         super.transitions[LdapStatesEnum.SEARCH_REQUEST_ATTRIBUTE_DESCRIPTION_LIST_LENGTH][0x30]
=
             new GrammarTransition( LdapStatesEnum.SEARCH_REQUEST_ATTRIBUTE_DESCRIPTION_LIST_LENGTH,
                 LdapStatesEnum.SEARCH_REQUEST_ATTRIBUTE_DESCRIPTION_LIST_VALUE,
@@ -740,6 +741,7 @@
                         TLV                  tlv = ldapMessageContainer.getCurrentTLV();
 
                         checkLength( searchRequest, tlv );
+                        searchRequest.setAttributesExpectedLength(tlv.getLength().getLength());
                         return;
                     }
                 } );
@@ -749,7 +751,8 @@
         // AttributeDescriptionList ::= SEQUENCE OF AttributeDescription (Length)
         //    ...
         // We have to create an array of elements to store the list of attributes
-        // to retrieve. We don't know yet how many attributes we will read.
+        // to retrieve. We don't know yet how many attributes we will read so we
+        // will allocate an ArrayList.
         super.transitions[LdapStatesEnum.SEARCH_REQUEST_ATTRIBUTE_DESCRIPTION_LIST_VALUE][0x30]
=
             new GrammarTransition( LdapStatesEnum.SEARCH_REQUEST_ATTRIBUTE_DESCRIPTION_LIST_VALUE,
                 LdapStatesEnum.SEARCH_REQUEST_ATTRIBUTE_DESCRIPTION_TAG,
@@ -794,8 +797,16 @@
 
                         TLV                  tlv = ldapMessageContainer.getCurrentTLV();
 
-                        // checkLength( searchRequest, tlv );
-                        // TODO : Fix the check, as we need to check length against the SEQ
OF.
+                        int expectedLength = searchRequest.getAttributesExpectedLength();
+
+                        int currentLength  = tlv.getLength().getLength() + tlv.getSize();
+
+                        if ( expectedLength < currentLength )
+                        {
+                            throw new DecoderException(
+                                "The current length is longer than the expected length" );
+                        }
+
                         return;
                     }
                 } );



Mime
View raw message