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

ChannelInputStream.readNBytes(int) incorrectly calls readAllBytes()

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 18
    • Fix Version/s: 18
    • Component/s: core-libs
    • Labels:
      None
    • Subcomponent:
    • Introduced In Version:
      18
    • Resolved In Build:
      b19
    • CPU:
      generic
    • OS:
      generic

      Description

      JDK-8268435 contains a cut-and-paste error which calls readNBytes() from the readAllBytes() implementation:

              if (!(ch instanceof SeekableByteChannel sbc))
                  return super.readAllBytes();

      https://github.com/openjdk/jdk/commit/0786d8b7b367e3aa3ffa54a3e339572938378dca#diff-21e4ff89fd54955e45fcd085ae8c08033b6c92de7f98ab0c836d4f754117ececR171

      Since IntputStream.readAllBytes() calls readNBytes() again, this results in a stack overflow (rather than incorrect data being returned).

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              fweimer Florian Weimer
              Reporter:
              fweimer Florian Weimer
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: