Uploaded image for project: 'Xerces2-J'
  1. Xerces2-J
  2. XERCESJ-1257

buffer overflow in UTF8Reader for characters out of BMP

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Reopened
    • Minor
    • Resolution: Unresolved
    • 2.9.0
    • None
    • None
    • Any

    Description

      There is a ArrayOutOfBoundsException in org.apache.xerces.impl.io.UTF8Reader, in read(char[],int,int) for 4-byte utf-8 chars.

      Imagine a following scenario. read() has a buffer of size N, and it reads N-1 ascii chars, and stores it in the output buffer. Let the Nth char be the first byte of a 4 byte utf-8 char. The other 3 bytes are fetched by invoking read() on the input stream. From these a surrogate pair of java chars is made, however, method does not check if both chars can fit into the output buffer ... In most cases, they would fit into the ouput buffer (e.g. if there are some other multi-byte chars in the fetched text), so the bug is very rare, but it still happens.

      Attachments

        1. XERCESJ-1257_tests.patch
          3 kB
          Robert Muir
        2. UTF8Reader.patch
          0.8 kB
          Robert Stojnic
        3. TestXerces.java
          1 kB
          Robert Stojnic

        Issue Links

          Activity

            People

              mrglavas@ca.ibm.com Michael Glavassevich
              rainmansr Robert Stojnic
              Votes:
              7 Vote for this issue
              Watchers:
              9 Start watching this issue

              Dates

                Created:
                Updated: