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

StringUtils#equals fails with Index OOBE on non-Strings with identical leading prefix

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.4
    • 3.5
    • None
    • None

    Description

      From the Commons User mailing list:

      StringUtils.equals(cs1,cs2) delegates to CharSequence.regionMatches(...) in a way that causes IndexOutOfBounds when either of cs1/cs2 isn't a String.

      Specifically, comparing "foo" and "foobar" for non-String CharSequences bombs due to CharSequenceUtils.regionMatches(cs1, false, 0, cs2, 0, Math.max(cs1.length(), cs2.length())) because regionMatches doesn't check for input exhaustion.

      Attachments

        Issue Links

          Activity

            People

              sebb Sebb
              sebb Sebb
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: