From f7ea39f6f05b6558904e31b607f44c1f66d7b2e2 Mon Sep 17 00:00:00 2001 From: emmanuel lecharny Date: Wed, 14 Aug 2024 14:06:10 +0200 Subject: [PATCH] Fix for DIRSERVER-2408 --- .../src/main/java/org/apache/directory/server/i18n/I18n.java | 1 + .../org/apache/directory/server/i18n/errors.properties | 1 + .../core/partition/impl/btree/jdbm/EntrySerializer.java | 5 +++++ 3 files changed, 7 insertions(+) diff --git a/i18n/src/main/java/org/apache/directory/server/i18n/I18n.java b/i18n/src/main/java/org/apache/directory/server/i18n/I18n.java index 71ddbd161b..ad92eed197 100644 --- a/i18n/src/main/java/org/apache/directory/server/i18n/I18n.java +++ b/i18n/src/main/java/org/apache/directory/server/i18n/I18n.java @@ -87,6 +87,7 @@ public enum I18n // apacheds-jdbm-partition errors 31000 - 31999 ERR_31000_COULD_NOT_CREATE_DIRECTORY("ERR_31000_COULD_NOT_CREATE_DIRECTORY"), ERR_31001_ODD_NUMBER_OF_BYTES_IN_SERIALIZED_STRING("ERR_31001_ODD_NUMBER_OF_BYTES_IN_SERIALIZED_STRING"), + ERR_31002_NEGATIOVE_NB_ATTRIBUTES_IN_ENTRY("ERR_31002_NEGATIOVE_NB_ATTRIBUTES_IN_ENTRY"), // apacheds-kerberos-codec errors 32000 - 32999 // apacheds-ldif-partition errors 33000 - 33999 diff --git a/i18n/src/main/resources/org/apache/directory/server/i18n/errors.properties b/i18n/src/main/resources/org/apache/directory/server/i18n/errors.properties index ffb792572b..1e1845d8d9 100644 --- a/i18n/src/main/resources/org/apache/directory/server/i18n/errors.properties +++ b/i18n/src/main/resources/org/apache/directory/server/i18n/errors.properties @@ -74,6 +74,7 @@ ERR_11000_COULD_NOT_CREATE_DIRECTORY=Could not create directory {0} # apacheds-jdbm-partition errors 31000 - 31999 ERR_31000_COULD_NOT_CREATE_DIRECTORY=Could not create directory {0} ERR_31001_ODD_NUMBER_OF_BYTES_IN_SERIALIZED_STRING=The serialized String contains an odd number of bytes +ERR_31002_NEGATIOVE_NB_ATTRIBUTES_IN_ENTRY=The number of attributes is negative # apacheds-kerberos-codec errors 32000 - 32999 # apacheds-ldif-partition errors 33000 - 33999 diff --git a/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/EntrySerializer.java b/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/EntrySerializer.java index 6624c45a6b..acae9ea09d 100644 --- a/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/EntrySerializer.java +++ b/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/EntrySerializer.java @@ -201,6 +201,11 @@ public Object deserialize( byte[] bytes ) throws IOException // Read the number of attributes int nbAttributes = in.readInt(); + + if ( nbAttributes < 0 ) + { + throw new IOException( I18n.err( I18n.ERR_31002_NEGATIOVE_NB_ATTRIBUTES_IN_ENTRY ) ); + } // Read the attributes for ( int i = 0; i < nbAttributes; i++ )