directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r598006 - in /directory/shared/branches/bigbang/ldap/src: main/java/org/apache/directory/shared/ldap/name/RdnParser.java test/java/org/apache/directory/shared/ldap/name/LdapDNTest.java
Date Sun, 25 Nov 2007 16:40:59 GMT
Author: seelmann
Date: Sun Nov 25 08:40:58 2007
New Revision: 598006

URL: http://svn.apache.org/viewvc?rev=598006&view=rev
Log:
Fixed AIOOBE when calling 'LdapDN.isValid("a=")'

Modified:
    directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/name/RdnParser.java
    directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDNTest.java

Modified: directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/name/RdnParser.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/name/RdnParser.java?rev=598006&r1=598005&r2=598006&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/name/RdnParser.java
(original)
+++ directory/shared/branches/bigbang/ldap/src/main/java/org/apache/directory/shared/ldap/name/RdnParser.java
Sun Nov 25 08:40:58 2007
@@ -586,6 +586,12 @@
      */
     private static boolean isValidAttributeValue( byte[] bytes, Position pos )
     {
+        if( bytes.length <= pos.start )
+        {
+            // no attribute value
+            return false;
+        }
+
         byte c = bytes[pos.start];
 
         if ( c == '#' )

Modified: directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDNTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDNTest.java?rev=598006&r1=598005&r2=598006&view=diff
==============================================================================
--- directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDNTest.java
(original)
+++ directory/shared/branches/bigbang/ldap/src/test/java/org/apache/directory/shared/ldap/name/LdapDNTest.java
Sun Nov 25 08:40:58 2007
@@ -2819,4 +2819,24 @@
        LdapDN dn = new LdapDN( "uID=kevin" );
        assertEquals( "uID", dn.getRdn().getUpType() );
    }
+
+
+    /**
+     * Tests the LdapDN.isValid() method.
+     */
+    public void testIsValid()
+    {
+        assertTrue( LdapDN.isValid( "" ) );
+
+        assertFalse( LdapDN.isValid( "a" ) );
+        assertFalse( LdapDN.isValid( "a " ) );
+
+        assertFalse( LdapDN.isValid( "a=" ) );
+        assertFalse( LdapDN.isValid( "a= " ) );
+
+        assertFalse( LdapDN.isValid( "=" ) );
+        assertFalse( LdapDN.isValid( " = " ) );
+        assertFalse( LdapDN.isValid( " = a" ) );
+    }
+
 }



Mime
View raw message