Sebb created LANG-806:
-------------------------

             Summary: RandomStringUtils can enter infinite loop if chosen char 
does not meet letter/digit requirements
                 Key: LANG-806
                 URL: https://issues.apache.org/jira/browse/LANG-806
             Project: Commons Lang
          Issue Type: Bug
    Affects Versions: 3.1, 2.6
            Reporter: Sebb
            Assignee: Sebb


If numbers == true or digits == true, then an infinite loop can result if the 
selection process never returns a char that passes the validation test.

This can occur with

RandomStringUtils.random(1, -1, 1, true, true)

because the gap is 2, i.e. random.nextInt(gap) + start == 0

This is trivial to fix; the code should check that start >=0 and end > start 
(unless start==end==0).

It can also occur if the provided char array or array subset does not contain 
any valid chars.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to