[#712] Fix StringIndexOutOfBoundsException on blank bind rule in ACI#715
Open
vharseko wants to merge 1 commit into
Open
[#712] Fix StringIndexOutOfBoundsException on blank bind rule in ACI#715vharseko wants to merge 1 commit into
vharseko wants to merge 1 commit into
Conversation
…nk bind rule in ACI BindRule.decode checked the input length before trimming, so an all-whitespace bind rule such as "( )" passed the empty-input guard and then crashed on charAt(0) of the trimmed-empty string with an unchecked StringIndexOutOfBoundsException instead of a clean AciException. Trim first, then treat a blank bind rule as empty (return null) so the malformed ACI is rejected with AciException. New AciBodyTest reproducer from the issue asserts the blank bind rule is rejected with AciException.
maximthomas
approved these changes
Jul 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #712.
Bug
An ACI containing a blank bind rule (only whitespace between the parentheses) crashes
Aci.decodewith an uncaughtjava.lang.StringIndexOutOfBoundsExceptioninstead of being rejected with anAciException. Reproducer from the issue:Root cause
BindRule.decodeguards the empty input before trimming:Decoding
( )recurses intoBindRule.decode(" ")(the parentheses stripped). The whitespace string has length 10, so it passes thelength() == 0guard;input.trim()then yields"", andcharAt(0)on the empty string throws an uncheckedStringIndexOutOfBoundsException. Being aRuntimeException, it escapes the aci-value validation paths instead of producing a clean decode error.Fix
Trim first, then treat a blank (all-whitespace) bind rule as empty and return
null— matching the original author's intent for empty input. The outer decode then rejects the malformed ACI withAciException(WARN_ACI_SYNTAX_INVALID_BIND_RULE_SYNTAX).This is the same class of defect as #666 (
StackOverflowErroron repetitive targets) and #676 (ArrayIndexOutOfBoundsExceptionon truncated percent-encoding): a malformed ACI must yieldAciException, never an unchecked runtime exception. Consistent with #676, the defect is fixed at the parsing source rather than swallowed by a broad catch.Tests
AciBodyTest.decodeBlankBindRuleThrowsAciException— the exact reproducer from the issue expectsAciException.AciBodyTestpasses locally (mvn -pl opendj-server-legacy test -Dtest=AciBodyTest): 8 tests, 0 failures.