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

Fix java.io.ObjectInputStream.PeekInputStream#skip

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P4
    • 9
    • 9
    • core-libs
    • None

    Backports

      Description

        A small typo makes skipping behave incorrectly and in the worst case scenario
        leads to an infinite recursion:

                public long skip(long n) throws IOException {
                    if (n <= 0) {
                        return 0;
                    }
                    int skipped = 0;
                    if (peekb >= 0) {
                        peekb = -1;
                        skipped++;
                        n--;
                    }
                    return skipped + skip(n);
                }

        The last line should have been like this:

                    return skipped + in.skip(n);

        The method doesn't seem to be used by its enclosing classes. I also haven't
        found any evidence an instance of PeekInputStream can escape. Nevertheless I
        believe this typo should be fixed.

        Attachments

          Issue Links

            Activity

              People

                prappo Pavel Rappo
                prappo Pavel Rappo
                Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: