From 6afc3f0ae019111a1f50bb39ba2cc0b1cfd0e70c Mon Sep 17 00:00:00 2001
From: Jean-Noël Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Fri, 29 Apr 2016 07:32:27 +0000
Subject: [PATCH] DN.parent(int) added a check on size
---
opendj-core/src/main/java/org/forgerock/opendj/ldap/DN.java | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/opendj-core/src/main/java/org/forgerock/opendj/ldap/DN.java b/opendj-core/src/main/java/org/forgerock/opendj/ldap/DN.java
index 3a1a44b..d868705 100644
--- a/opendj-core/src/main/java/org/forgerock/opendj/ldap/DN.java
+++ b/opendj-core/src/main/java/org/forgerock/opendj/ldap/DN.java
@@ -785,10 +785,12 @@
* @see #localName(int) for the reverse operation (starting from the left)
*/
public DN parent(final int index) {
- // We allow size + 1 so that we can return null as the parent of the
- // Root DN.
- Reject.ifFalse(index >= 0, "index less than zero");
+ // We allow size + 1 so that we can return null as the parent of the Root DN.
+ Reject.ifTrue(index < 0, "index less than zero");
+ if (index > size) {
+ return null;
+ }
DN parentDN = this;
for (int i = 0; parentDN != null && i < index; i++) {
parentDN = parentDN.parent;
--
Gitblit v1.10.0