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

[lang] PADDING array in StringUtils overflows on '\uffff'

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.1
    • 2.2
    • lang.*
    • None
    • Operating System: Windows XP
      Platform: PC

    • 35756

    Description

      The PADDING array in class StringUtils is one entry too short.
      As declared, it overflows on '\uffff'.
      To test, run:
      StringUtils.leftPad("abcd", 10, '\ufffe') // no exception
      StringUtils.leftPad("abcd", 10, '\uffff') // ArrayIndexOutOfBoundsException

      Current code:
      private static final String[] PADDING = new String[Character.MAX_VALUE];
      Suggested fix:
      private static final String[] PADDING = new String[Character.MAX_VALUE + 1];

      Attachments

        Activity

          People

            Unassigned Unassigned
            sw@reubensivan.com Reuben Sivan
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: