Uploaded image for project: 'Commons Lang'
  1. Commons Lang
  2. LANG-1287

RandomStringUtils#random can enter infinite loop if end parameter is to small

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.5
    • 3.6
    • lang.*
    • None

    Description

      I faced that the random method can cause an infinite loop. It can be caused if the end parameter is too low for generating either numbers (< 48) or letters (<65). I added some exception tests to make the cases clear. Basically, if we call the random function with for example numbers = true && end < 48 the validation for Character.isDigit(ch) will fail and we increment count count++.

      Ivan Morozov https://github.com/apache/commons-lang/pull/211

      Attachments

        Activity

          People

            pascalschumacher Pascal Schumacher
            pascalschumacher Pascal Schumacher
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: