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

Remove dubious call_jio_print in ostream.cpp

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 11
    • Component/s: hotspot
    • Labels:
      None
    • Subcomponent:
    • Introduced In Version:
      11
    • Resolved In Build:
      b11

      Description

      With its current implementation, defaultStream::write(const char* s, size_t len) might randomly truncate the data written.

      The reason is that it makes use of the method jio_print(const char* s) to actually write the data to the output stream. jio_print(const char* s) expects a zero terminated string, whereas the input to defaultStream::write is a pointer to a string buffer which is not necessarily null terminated and a length field.

      Currently, defaultStream::write checks if by occasion the next char after the buffer is null. If true it calls jio_print with the input buffer. If false, the fallback is to call function "call_jio_print" which copies the input buffer into a temporary fixed size buffer, adding a terminating null. If the input data is larger than the buffer, it obviously gets truncated.

      Since defaultStream::write is the only user of jio_print, we can change its implementation/signature, to work with buffer/length input arguments and internally use a format string with precision field set to buffer length.

        Attachments

          Activity

            People

            Assignee:
            clanger Christoph Langer
            Reporter:
            clanger Christoph Langer
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: