You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2026/09/07 15:02:17 UTC

(directory-ldap-api) branch master updated: Fixed a potential String Index OOB error

This is an automated email from the ASF dual-hosted git repository.

asf-gitbox-commits pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/directory-ldap-api.git


The following commit(s) were added to refs/heads/master by this push:
     new 816214644 Fixed a potential String Index OOB error
816214644 is described below

commit 816214644673a629c94873a8a382692ca6ff3a8d
Author: emmanuel lecharny <el...@apache.org>
AuthorDate: Mon Sep 7 17:02:13 2026 +0200

    Fixed a potential String Index OOB error
---
 .../api/ldap/model/schema/parsers/OpenLdapSchemaParser.java   |  4 +++-
 .../ldap/model/schema/parsers/OpenLdapSchemaParserTest.java   | 11 ++++++++++-
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/OpenLdapSchemaParser.java b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/OpenLdapSchemaParser.java
index cffd3f614..2b709484a 100644
--- a/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/OpenLdapSchemaParser.java
+++ b/ldap/model/src/main/java/org/apache/directory/api/ldap/model/schema/parsers/OpenLdapSchemaParser.java
@@ -953,10 +953,11 @@ public class OpenLdapSchemaParser
     {
         return isEscape( pos, pos.start );
     }
+    
 
     private static boolean isEscape( PosSchema pos, int index ) throws LdapSchemaException
     {
-        if ( ( pos.line == null ) || ( pos.line.length() - index < 2 ) || pos.line.charAt( index ) != ESCAPE )
+        if ( ( pos.line == null ) || ( pos.line.length() - index < 3 ) || pos.line.charAt( index ) != ESCAPE )
         {
             return false;
         }
@@ -975,6 +976,7 @@ public class OpenLdapSchemaParser
         return isEscape;
     }
     
+    
     /**
      * 
      * @param reader The stream reader
diff --git a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/parsers/OpenLdapSchemaParserTest.java b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/parsers/OpenLdapSchemaParserTest.java
index 8de300880..1c37ed5dd 100644
--- a/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/parsers/OpenLdapSchemaParserTest.java
+++ b/ldap/model/src/test/java/org/apache/directory/api/ldap/model/schema/parsers/OpenLdapSchemaParserTest.java
@@ -32,7 +32,6 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-import org.apache.directory.api.ldap.model.exception.LdapSchemaException;
 import org.apache.directory.api.ldap.model.schema.AttributeType;
 import org.apache.directory.api.ldap.model.schema.ObjectClass;
 import org.apache.directory.api.ldap.model.schema.ObjectClassTypeEnum;
@@ -494,4 +493,14 @@ public class OpenLdapSchemaParserTest
             parser.parse( "AttributeType ( 1.2.3 NAME (" );
         });
     }
+    
+    
+    @Test
+    public void testTooShort() throws Exception
+    {
+        assertThrows( ParseException.class , () ->
+        {
+            parser.parse(  "ObjectClass( 1.1 DESC 'x\\5" );
+        });
+    }
 }