Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8245038

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

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Won't Fix
    • Affects Version/s: 15
    • Fix Version/s: tbd
    • Component/s: core-libs
    • Labels:
      None
    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Description

      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.

        Attachments

          Activity

            People

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

              Dates

              Created:
              Updated:
              Resolved: