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

Exceptions::fthrow needs to ensure it truncates to a valid utf8 string

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P4
    • 24
    • 23
    • hotspot
    • None
    • b09

    Description

      In Exceptions::fthrow we have:

      void Exceptions::fthrow(JavaThread* thread, const char* file, int line, Symbol* h_name, const char* format, ...) {
        const int max_msg_size = 1024;
        va_list ap;
        va_start(ap, format);
        char msg[max_msg_size];
        os::vsnprintf(msg, max_msg_size, format, ap);
        va_end(ap);
        _throw_msg(thread, file, line, h_name, msg);
      }

      The incoming format string and any subsequent char* args are expected to be valid UTF8 sequences. The expanded string will be converted back to UTF16 to become the java.lang.String that holds the detail message of the exception. But we pass vsnprintf a buffer of 1024 which means the expanded string may be truncated, but we have no guarantee it will be truncated such that it is still a valid UTF8 sequence - we may end on a partial multi-byte character.

      Attachments

        Issue Links

          Activity

            People

              dholmes David Holmes
              dholmes David Holmes
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: