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

call_jio_print ignores its "len" argument

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 7
    • Fix Version/s: hs10
    • Component/s: hotspot
    • Labels:
      None
    • Subcomponent:
    • Resolved In Build:
      b14
    • CPU:
      generic
    • OS:
      generic

      Backports

        Description

        call_jio_print(const char* s, size_t len) exists because jio_print(const char* s) doesn't take a length argument, instead assuming that its argument is null-terminated. call_jio_print carefully allocates a buffer, copies the correct number of characters from its argument to the buffer, null-terminates the buffer, and (but!) then hands the source argument to jio_print, which prints until it finds a null terminator.

        In the most benign case, if the argument happens to be null-terminated in the right place, the correct result is produced. If the argument continues on past the given number of characters (e.g., it's a substring of a longer string), the argument is printed until its terminating null. In the case that the argument wasn't null terminated, but depended on the length, jio_print would wander off through memory finding things to print until it came to a null byte, seg-faulted, or whatever.

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                pbk Peter Kessler
                Reporter:
                pbk Peter Kessler
                Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: