Uploaded image for project: 'XMLBeans'
  1. XMLBeans
  2. XMLBEANS-474

NegativeArraySizeException thrown from TextSaver.resize

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • Version 2.5
    • Version 5.2.0
    • None
    • None

    Description

      TextSever.resize()

      does not check if "newLen" is negative which can happen if requested size is more than ( Integer.MAX_VALUE / 2)

      consider core java implementation AbstractStringBuilder:expandCapacity:

      void expandCapacity(int minimumCapacity) {
      int newCapacity = (value.length + 1) * 2;
      if (newCapacity < 0)

      { newCapacity = Integer.MAX_VALUE; }

      else if (minimumCapacity > newCapacity)

      { newCapacity = minimumCapacity; }

      value = Arrays.copyOf(value, newCapacity);
      }

      Here is the exception stack trace:

      Nov 18 16:09:31 localhost java.lang.NegativeArraySizeException
      Nov 18 16:09:31 localhost at
      org.apache.xmlbeans.impl.store.Saver$TextSaver.resize(Saver.java:1695)
      Nov 18 16:09:31 localhost at
      org.apache.xmlbeans.impl.store.Saver$TextSaver.preEmit(Saver.java:1300)
      Nov 18 16:09:31 localhost at
      org.apache.xmlbeans.impl.store.Saver$TextSaver.emit(Saver.java:1231)
      Nov 18 16:09:31 localhost at
      org.apache.xmlbeans.impl.store.Saver$TextSaver.emitAttrHelper(Saver.java:1027)
      Nov 18 16:09:31 localhost at
      org.apache.xmlbeans.impl.store.Saver$TextSaver.emitElement(Saver.java:966)
      Nov 18 16:09:31 localhost at
      org.apache.xmlbeans.impl.store.Saver.processElement(Saver.java:476)
      Nov 18 16:09:31 localhost at
      org.apache.xmlbeans.impl.store.Saver.process(Saver.java:307)
      Nov 18 16:09:31 localhost at
      org.apache.xmlbeans.impl.store.Saver$TextSaver.saveToString(Saver.java:1859)
      Nov 18 16:09:31 localhost at
      org.apache.xmlbeans.impl.store.Cursor._xmlText(Cursor.java:546)
      Nov 18 16:09:31 localhost at
      org.apache.xmlbeans.impl.store.Cursor.xmlText(Cursor.java:2436)
      Nov 18 16:09:31 localhost at
      org.apache.xmlbeans.impl.values.XmlObjectBase.xmlText(XmlObjectBase.java:1489)

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              danfaer Dan Faershtein
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 20m
                  20m