On Wed, 16 Sep 2026 10:57:36 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 four 
> additional commits since the last revision:
> 
>  - Update regression test
>  - Change message in body InvalidNameException
>  - Add numAttributes method and correct Rfc2253Parser
>  - Correct comment and move throw inside if

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

> 1: /*

I believe the test should also check the other methods by which an empty RDN 
might be created, even if those currently appropriately throw an 
InvalidNameException.
(e.g. `new Rdn(new BasicAttributes())`)

We also need a scenario that deserializes an empty RDN() (bytes that were 
formed on a previous version where new Rdn("") didn't throw) and verify that 
StreamCorruptedException is raised.

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

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

Reply via email to