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 2024/10/28 22:08:25 UTC

(directory-ldap-api) 02/02: Fix for DIRAPI-409 and 410

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

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

commit 5424edadb81372e280d7c96c0a70db784295b1c5
Author: emmanuel lecharny <el...@apache.org>
AuthorDate: Mon Oct 28 23:08:13 2024 +0100

    Fix for DIRAPI-409 and 410
---
 i18n/src/main/java/org/apache/directory/api/i18n/I18n.java       | 1 +
 .../resources/org/apache/directory/api/i18n/errors.properties    | 2 ++
 .../org/apache/directory/api/ldap/sp/JavaStoredProcUtils.java    | 9 ++++++++-
 pom.xml                                                          | 2 +-
 4 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/i18n/src/main/java/org/apache/directory/api/i18n/I18n.java b/i18n/src/main/java/org/apache/directory/api/i18n/I18n.java
index ca0cbc603..2bb60f231 100644
--- a/i18n/src/main/java/org/apache/directory/api/i18n/I18n.java
+++ b/i18n/src/main/java/org/apache/directory/api/i18n/I18n.java
@@ -627,6 +627,7 @@ public enum I18n
     ERR_04486_VALUE_ALREADY_EXISTS("ERR_04486_VALUE_ALREADY_EXISTS"),
     ERR_04487_ATTRIBUTE_IS_SINGLE_VALUED("ERR_04487_ATTRIBUTE_IS_SINGLE_VALUED"),
     ERR_04488_SYNTAX_INVALID("ERR_04488_SYNTAX_INVALID"),
+    ERR_10000_EMPTY_SP_CLASS( "ERR_10000_EMPTY_SP_CLASS" ),
       
     // ldap-client-api  4100-
     ERR_4100_TLS_HANDSHAKE_ERROR( "ERR_4100_TLS_HANDSHAKE_ERROR" ),
diff --git a/i18n/src/main/resources/org/apache/directory/api/i18n/errors.properties b/i18n/src/main/resources/org/apache/directory/api/i18n/errors.properties
index 78487928d..cbdae91fa 100644
--- a/i18n/src/main/resources/org/apache/directory/api/i18n/errors.properties
+++ b/i18n/src/main/resources/org/apache/directory/api/i18n/errors.properties
@@ -617,6 +617,8 @@ ERR_04488_SYNTAX_INVALID=Syntax invalid for ''{0}''
 
 ERR_4100_TLS_HANDSHAKE_ERROR=The TLS handshake failed
 
+ERR_10000_EMPTY_SP_CLASS=The stored procedure class file {0} is empy.
+
 # ldap-constants
 ERR_05001_UNKNOWN_AUTHENT_LEVEL=Unknown AuthenticationLevel {0}
 
diff --git a/ldap/extras/sp/src/main/java/org/apache/directory/api/ldap/sp/JavaStoredProcUtils.java b/ldap/extras/sp/src/main/java/org/apache/directory/api/ldap/sp/JavaStoredProcUtils.java
index ba6c515be..d7280d26a 100644
--- a/ldap/extras/sp/src/main/java/org/apache/directory/api/ldap/sp/JavaStoredProcUtils.java
+++ b/ldap/extras/sp/src/main/java/org/apache/directory/api/ldap/sp/JavaStoredProcUtils.java
@@ -36,6 +36,7 @@ import javax.naming.ldap.ExtendedResponse;
 import javax.naming.ldap.LdapContext;
 
 import org.apache.commons.lang.SerializationUtils;
+import org.apache.directory.api.i18n.I18n;
 import org.apache.directory.api.ldap.codec.api.LdapApiServiceFactory;
 import org.apache.directory.api.ldap.extras.extended.storedProcedure.StoredProcedureRequestImpl;
 import org.apache.directory.api.ldap.model.constants.SchemaConstants;
@@ -105,7 +106,13 @@ public final class JavaStoredProcUtils
 
         try
         {
-            in.read( buf );
+            int nbRead = in.read( buf );
+            
+            if ( nbRead == -1 ) 
+            {
+                NamingException ne = new NamingException( I18n.err( I18n.ERR_10000_EMPTY_SP_CLASS, classFileName ) );
+                throw ne;
+            }
         }
         catch ( IOException e )
         {
diff --git a/pom.xml b/pom.xml
index bd48bdeb4..f79259d2f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -52,7 +52,7 @@
     <commons.pool.version>1.6</commons.pool.version>
     <dom4j.version>1.6.1</dom4j.version>
     <findbugs.annotations.version>1.0.0</findbugs.annotations.version>
-    <forbiddenapis.version>2.2</forbiddenapis.version>
+    <forbiddenapis.version>2.6</forbiddenapis.version>
     <junit.version>4.12</junit.version>
     <log4j.version>1.2.17</log4j.version>
     <logback.version>1.2.3</logback.version>