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

get_dump_directory() in jfrEmergencyDump.cpp should pass correct length to jio_snprintf

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved
    • P3
    • Resolution: Fixed
    • 20
    • 21
    • hotspot
    • jfr
    • b05
    • other

    Description

      static size_t get_dump_directory() {
        const char* dump_path = JfrEmergencyDump::get_dump_path();
        if (*dump_path == '\0') {
          if (os::get_current_directory(_path_buffer, sizeof(_path_buffer)) == NULL) {
            return 0;
          }
        } else {
          strcpy(_path_buffer, dump_path);
        }
        const size_t path_len = strlen(_path_buffer);
        const int result = jio_snprintf(_path_buffer + path_len,
                                        sizeof(_path_buffer),
                                        "%s",
                                        os::file_separator());
        return (result == -1) ? 0 : strlen(_path_buffer);
      }

      Since the start address of the char buffer passing to jio_snprintf is offset by path_len, the length of the buffer (second arg to jio_snprintf) should be adjusted according.

      Attachments

        Issue Links

          Activity

            People

              ccheung Calvin Cheung
              shadowbug Shadow Bug
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: