From cc42231912189ba9e7b352a9b5e870df00793ce9 Mon Sep 17 00:00:00 2001 From: emmanuel lecharny Date: Wed, 14 Aug 2024 12:30:45 +0200 Subject: [PATCH] Fix for DIRSERVER-2409 --- .../core/partition/impl/btree/jdbm/StringSerializer.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/StringSerializer.java b/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/StringSerializer.java index 67853b17e3..252142734b 100644 --- a/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/StringSerializer.java +++ b/jdbm-partition/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/StringSerializer.java @@ -25,6 +25,7 @@ import jdbm.helper.Serializer; import org.apache.directory.api.util.Strings; +import org.apache.directory.server.i18n.I18n; /** @@ -57,6 +58,12 @@ public Object deserialize( byte[] bytes ) throws IOException { return ""; } + + // Check that we don't have a odd number of bytes (we should have an even number of bytes) + if ( ( bytes.length & 1 ) == 1 ) + { + throw new IOException( I18n.err( I18n.ERR_31001_ODD_NUMBER_OF_BYTES_IN_SERIALIZED_STRING ) ); + } char[] strchars = new char[bytes.length >> 1]; int pos = 0;