Uploaded image for project: 'Commons Codec'
  1. Commons Codec
  2. CODEC-314

PercentCodec.insertAlwaysEncodeChars throws IndexOutOfBoundException

    XMLWordPrintableJSON

Details

    Description

      The insertAlwaysEncodeChars() method takes in a random byte array (through the constructor of PercentCodec class) and processes it byte by byte. Each byte is passed to insertAlwaysEncodeChar() to set the corresponding bit in the BitSet object alwaysEncodeChars to true by calling the set() method of the BitSet object. As BitSet only accept positive index, if any byte is negative, it will cause IndexOutOfBoundsException when calling the set() method.

      Possible fix could add a conditional check to ensure only valid bytes (positive or zero) are processed.

      We found this bug using fuzzing by way of OSS-Fuzz. It is reported at https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=64362.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              arthur.chan Sheung Chi Chan
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: