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

ObjectInputStream.readFully range check incorrect

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P2
    • 18
    • None
    • core-libs

    Backports

      Description

        ObjectInputStream.readFully(byte[], off, len) throws IndexOutOfBoundsException when passed the length is less than the offset.
        It is treating the length as the toOffset.
        The replacement of the range check should have used checkFromIndexSize instead of checkFromToIndex.

        java.lang.IndexOutOfBoundsException: Range [4, 0) out of bounds for length 10
        at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:100)
        at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckFromToIndex(Preconditions.java:112)
        at java.base/jdk.internal.util.Preconditions.checkFromToIndex(Preconditions.java:349)
        at java.base/java.util.Objects.checkFromToIndex(Objects.java:385)
        at java.base/java.io.ObjectInputStream.readFully(ObjectInputStream.java:1207)
        at javasoft.sqe.tests.api.java.io.Serialization.ObjectInputStream.ReadFullyTests.ReadFully0007(ReadFullyTests.java:276)
        at javasoft.sqe.tests.api.java.io.Serialization.ObjectInputStream.ReadFullyTests.run(ReadFullyTests.java:66)

        Attachments

          Issue Links

            Activity

              People

                rriggs Roger Riggs
                rriggs Roger Riggs
                Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: