mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Jean-Noël Rouvignac
28.33.2016 6afc3f0ae019111a1f50bb39ba2cc0b1cfd0e70c
DN.parent(int) added a check on size
1 files modified
8 ■■■■■ changed files
opendj-core/src/main/java/org/forgerock/opendj/ldap/DN.java 8 ●●●●● patch | view | raw | blame | history
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;