From e24c2780b6d44c7e5d386e70a1fb3346149ccdc9 Mon Sep 17 00:00:00 2001
From: Valery Kharseko <vharseko@3a-systems.ru>
Date: Tue, 04 Aug 2026 07:15:33 +0000
Subject: [PATCH] Fix CodeQL note-severity alerts: array logging and uncaught NumberFormatException (#817)
---
opendj-server-legacy/src/test/java/org/opends/server/replication/common/CSNTest.java | 23 +++++++++++++++++++++++
1 files changed, 23 insertions(+), 0 deletions(-)
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/replication/common/CSNTest.java b/opendj-server-legacy/src/test/java/org/opends/server/replication/common/CSNTest.java
index 1c65a05..d92e96d 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/replication/common/CSNTest.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/replication/common/CSNTest.java
@@ -22,6 +22,7 @@
import java.util.Iterator;
import java.util.List;
+import org.forgerock.i18n.LocalizedIllegalArgumentException;
import org.opends.server.replication.ReplicationTestCase;
import org.opends.server.util.TimeThread;
import org.testng.annotations.DataProvider;
@@ -74,6 +75,28 @@
"The encoding/decoding of CSN is not reversible for toString()");
}
+ /** Create invalid CSN string representations. */
+ @DataProvider(name = "invalidCSNStrings")
+ public Object[][] createInvalidCSNStrings()
+ {
+ return new Object[][] {
+ { null },
+ { "" },
+ { "\u0001" }, // truncated CSN read from a legacy replication message
+ { "0000000000012abc002d0000007" }, // one character too short
+ { "000000000001zabc002d0000007b" }, // non hexadecimal timestamp
+ { "0000000000012abc002d0000007z" }, // non hexadecimal seqnum
+ };
+ }
+
+ /** Test constructor from an invalid String. */
+ @Test(dataProvider = "invalidCSNStrings",
+ expectedExceptions = LocalizedIllegalArgumentException.class)
+ public void csnDecodeInvalidString(String str) throws Exception
+ {
+ new CSN(str);
+ }
+
/** Create CSN. */
@DataProvider(name = "createCSN")
public Object[][] createCSNData()
--
Gitblit v1.10.0