Commons Lang
  1. Commons Lang
  2. LANG-3

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

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.1
    • Fix Version/s: 2.2
    • Component/s: lang.*
    • Labels:
      None
    • Environment:

      Operating System: Windows XP
      Platform: PC

      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];

        Activity

        Hide
        Stephen Colebourne added a comment -

        Patch applied, thanks

        Show
        Stephen Colebourne added a comment - Patch applied, thanks

          People

          • Assignee:
            Unassigned
            Reporter:
            Reuben Sivan
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development