On Wed, 2 Sep 2026 12:44:06 GMT, Timofei Fedotov <[email protected]> wrote:

>> Rfc2253Parser silently accepted an empty RDN (no attributeTypeAndValue pair) 
>> instead of
>> throwing InvalidNameException. Rdn.getType()/getValue() then indexed an empty
>> internal list, throwing an uncaught IndexOutOfBoundsException instead of the 
>> documented
>> exception.
>> 
>> Two independent entry points:
>> 
>> Rdn("") - the original fuzzer-found crash.
>> LdapName("cn=x,") / LdapName.add("") - a string with a trailing , or ;, 
>> which never goes
>> through Rdn(String) at all (LdapName builds the RDN directly via 
>> Rfc2253Parser).
>> 
>> Add one check, rdn.size() == 0, throw InvalidNameException, placed in
>> 
>> Rfc2253Parser.doParse(Rdn) - the single method both paths funnel through.
>> 
>> Also add a regression check that "cn=a,,cn=b" still throws as before.
>> 
>> 
>> 
>> 
>> ---------
>> - [x] I confirm that I make this contribution in accordance with the 
>> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).
>
> Timofei Fedotov has updated the pull request incrementally with one 
> additional commit since the last revision:
> 
>   Add regression test

test/jdk/javax/naming/ldap/Rdn/EmptyRdnTest.java line 33:

> 31:  *          ("returns the ... type" / "returns the ... value", never an
> 32:  *          exception other than InvalidNameException at construction 
> time).
> 33:  * @run main EmptyRdnTest

Given the kind of tests being run in this main method, I think it will be 
better to convert this to a junit test and run each of them as a separate test 
method.

While at it, instead of explicitly referring to the test class name here, jtreg 
allows the usage of the `${test.main.class}` placeholder for test actions (you 
can find examples in existing tests in the JDK). Using that placeholder 
prevents the chances of (copy/pasted) incorrect test class name references 
which can then result in launching a completely unrelated test (and that can 
sometimes go unnoticed).

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/32648#discussion_r4024957679

Reply via email to