BigInteger.squareToLen(x, len, z) may compute incorrect results when called reflectively

XMLWordPrintable

    • Type: Bug
    • Resolution: Won't Fix
    • Priority: P4
    • tbd
    • Affects Version/s: 15
    • Component/s: core-libs
    • None
    • generic
    • generic

      The BigInteger method

      private static final int[] squareToLen(int[] x, int len, int[] z)

      may compute incorrect results when invoked via reflection and z.length > 2 * len. For example:

      x = {1, 2}
      len = 2
      with z.length = 4: {0, 1, 4, 4} (as expected)
      with z.length = 5: {0, 1, 0, 8, 0} instead of {0, 1, 4, 4, 0}

      The core issue is in implMulAdd(), where 'offset' is set to
      "out.length-offset - 1"
      instead of
      "zlen - offset - 1"
      (which requires to add zlen as argument).

      Calling a private method as such is not guaranteed to work, but if there is an error, it should probably be fixed.

            Assignee:
            Brian Burkhalter
            Reporter:
            Brian Burkhalter
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: