RFR 8224789 : Parsing repetition count in regex does not detect numeric overflow

Ivan Gerasimov ivan.gerasimov at oracle.com
Tue May 28 17:55:51 UTC 2019

Thank you Roger for reviewing!

On 5/28/19 9:33 AM, Roger Riggs wrote:
> Hi Ivan,
> test/jdk/java/util/regex/RegExTest.java:
> 4954: The test should print the failing exception information and
> 4951: a message if the Pattern.compile does not fail to distinguish 
> that failure from any others.
Yes, it will be useful, if the test fails.
So, I added some debug output.

The webrev was updated in place:

> I don't think there is a need for so many cases of values > 2^31; 
> there is no different code path for all those values.
> They are fairly cheap, but redundant.
I wanted to cover cases when the number would overflow 64-bit integer, 
so that the test would fail if the count were implemented as a long.

Also, I tried to cover different configurations of the quantifier {N}, 
{N,}, {N,M} with both N and M overflowing int, unsigned int, long, 
unsigned long.

With kind regards,

> Otherwise, looks fine.
> Thanks, Roger
> On 05/25/2019 02:28 AM, Ivan Gerasimov wrote:
>> Hello!
>> When Pattern.compile() parses the repetition count in the expressions 
>> like '.{100}', '.{1,2}' or '.{3,}' it fails to detect numeric 
>> overflow if the result is still non-negative.
>> Could you please help review the patch?
>> BUGURL: https://bugs.openjdk.java.net/browse/JDK-8224789
>> WEBREV: http://cr.openjdk.java.net/~igerasim/8224789/00/webrev/
>> Also, reading a char at line 3274 is done with skip(), so the 
>> exception thrown at 3315 displays the position of the error more 
>> accurately.

With kind regards,
Ivan Gerasimov

More information about the core-libs-dev mailing list