Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-1571

CachedOutputStream#writeCacheTo(StringBuilder, int) fails with StringIndexOutOfBoundsException

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.1
    • 2.1.1
    • Core
    • None
    • Novice

    Description

      public void writeCacheTo(StringBuilder out, int limit) throws IOException {
      ...
      if ((count + x) > limit)

      { x = count - limit; <<< this has to be: x = limit - count; }

      out.append(new String(bytes, 0, x));
      count += x;
      ...
      }

      If limit is reached x becomes negative and String construction fails with

      java.lang.StringIndexOutOfBoundsException: String index out of range: -784
      at java.lang.String.checkBounds(String.java:368)
      at java.lang.String.<init>(String.java:457)
      at org.apache.cxf.io.CachedOutputStream.writeCacheTo(CachedOutputStream.java:272)

      Attachments

        Activity

          People

            bmargulies Benson Margulies
            axelviii Axel Dehning
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: